Clean up vpath tests before porting back to stable

This commit is contained in:
Jason Perkins 2012-12-14 10:00:51 -05:00
parent cb2435faf6
commit e4d62bd307

View File

@ -13,17 +13,16 @@
-- Setup and teardown
--
local sln, prj, cfg
local cwd
local sln
function suite.setup()
sln = test.createsolution()
cwd = os.getcwd() .. '/'
end
local function prepare()
prj = premake.solution.getproject_ng(sln, 1)
cfg = project.getconfig(prj, "Debug")
local function run()
local prj = premake.solution.getproject_ng(sln, 1)
local cfg = project.getconfig(prj, "Debug")
return project.getvpath(prj, cfg.files[1])
end
@ -33,50 +32,44 @@
function suite.ReturnsOriginalPath_OnNoVpaths()
files { "hello.c" }
prepare()
test.isequal(cfg.files[1], project.getvpath(prj, cfg.files[1]))
test.isequal(path.join(os.getcwd(), "hello.c"), run())
end
function suite.ReturnsOriginalPath_OnNoMatches()
files { "hello.c" }
vpaths { ["Headers"] = "**.h" }
prepare()
test.isequal(cfg.files[1], project.getvpath(prj, cfg.files[1]))
test.isequal(path.join(os.getcwd(), "hello.c"), run())
end
function suite.CanStripPaths()
files { "src/myproject/hello.c" }
vpaths { [""] = "src" }
prepare()
test.isequal("hello.c", project.getvpath(prj, cfg.files[1]))
run()
test.isequal("hello.c", run())
end
function suite.CanTrimLeadingPaths()
files { "src/myproject/hello.c" }
vpaths { ["*"] = "src" }
prepare()
test.isequal("myproject/hello.c", project.getvpath(prj, cfg.files[1]))
test.isequal("myproject/hello.c", run())
end
function suite.PatternMayIncludeTrailingSlash()
files { "src/myproject/hello.c" }
vpaths { [""] = "src/myproject/" }
prepare()
test.isequal("hello.c", project.getvpath(prj, cfg.files[1]))
test.isequal("hello.c", run())
end
function suite.SimpleReplacementPatterns()
files { "src/myproject/hello.c" }
vpaths { ["sources"] = "src/myproject" }
prepare()
test.isequal("sources/hello.c", project.getvpath(prj, cfg.files[1]))
test.isequal("sources/hello.c", run())
end
function suite.ExactFilenameMatch()
files { "src/hello.c" }
vpaths { ["sources"] = "src/hello.c" }
prepare()
test.isequal("sources/hello.c", project.getvpath(prj, cfg.files[1]))
test.isequal("sources/hello.c", run())
end
@ -87,57 +80,49 @@
function suite.MatchFilePattern_ToGroup_Flat()
files { "src/myproject/hello.h" }
vpaths { ["Headers"] = "**.h" }
prepare()
test.isequal("Headers/hello.h", project.getvpath(prj, cfg.files[1]))
test.isequal("Headers/hello.h", run())
end
function suite.MatchFilePattern_ToNone_Flat()
files { "src/myproject/hello.h" }
vpaths { [""] = "**.h" }
prepare()
test.isequal("hello.h", project.getvpath(prj, cfg.files[1]))
test.isequal("hello.h", run())
end
function suite.MatchFilePattern_ToNestedGroup_Flat()
files { "src/myproject/hello.h" }
vpaths { ["Source/Headers"] = "**.h" }
prepare()
test.isequal("Source/Headers/hello.h", project.getvpath(prj, cfg.files[1]))
test.isequal("Source/Headers/hello.h", run())
end
function suite.MatchFilePattern_ToGroup_WithTrailingSlash()
files { "src/myproject/hello.h" }
vpaths { ["Headers/"] = "**.h" }
prepare()
test.isequal("Headers/hello.h", project.getvpath(prj, cfg.files[1]))
test.isequal("Headers/hello.h", run())
end
function suite.MatchFilePattern_ToNestedGroup_Flat()
files { "src/myproject/hello.h" }
vpaths { ["Group/Headers"] = "**.h" }
prepare()
test.isequal("Group/Headers/hello.h", project.getvpath(prj, cfg.files[1]))
test.isequal("Group/Headers/hello.h", run())
end
function suite.MatchFilePattern_ToGroup_Nested()
files { "src/myproject/hello.h" }
vpaths { ["Headers/*"] = "**.h" }
prepare()
test.isequal("Headers/src/myproject/hello.h", project.getvpath(prj, cfg.files[1]))
test.isequal("Headers/src/myproject/hello.h", run())
end
function suite.MatchFilePattern_ToGroup_Nested_OneStar()
files { "src/myproject/hello.h" }
vpaths { ["Headers/*"] = "**.h" }
prepare()
test.isequal("Headers/src/myproject/hello.h", project.getvpath(prj, cfg.files[1]))
test.isequal("Headers/src/myproject/hello.h", run())
end
function suite.MatchFilePatternWithPath_ToGroup_Nested()
files { "src/myproject/hello.h" }
vpaths { ["Headers/*"] = "src/**.h" }
prepare()
test.isequal("Headers/myproject/hello.h", project.getvpath(prj, cfg.files[1]))
test.isequal("Headers/myproject/hello.h", run())
end
@ -149,22 +134,19 @@
location "build"
files "src/hello.h"
vpaths { [""] = "src" }
prepare()
test.isequal("hello.h", project.getvpath(prj, cfg.files[1]))
test.isequal("hello.h", run())
end
function suite.MatchFilePattern_OnProjectLocationSet()
location "build"
files "src/hello.h"
vpaths { ["Headers"] = "**.h" }
prepare()
test.isequal("Headers/hello.h", project.getvpath(prj, cfg.files[1]))
test.isequal("Headers/hello.h", run())
end
function suite.MatchFilePatternWithPath_OnProjectLocationSet()
location "build"
files "src/hello.h"
vpaths { ["Headers"] = "src/**.h" }
prepare()
test.isequal("Headers/hello.h", project.getvpath(prj, cfg.files[1]))
test.isequal("Headers/hello.h", run())
end