2011-06-09 19:15:39 +00:00
|
|
|
--
|
|
|
|
-- tests/project/test_vpaths.lua
|
|
|
|
-- Automated test suite for the project support functions.
|
2012-02-02 01:00:24 +00:00
|
|
|
-- Copyright (c) 2011-2012 Jason Perkins and the Premake project
|
2011-06-09 19:15:39 +00:00
|
|
|
--
|
|
|
|
|
|
|
|
T.project_vpaths = { }
|
|
|
|
local suite = T.project_vpaths
|
2012-02-02 01:00:24 +00:00
|
|
|
local project = premake5.project
|
2011-06-09 19:15:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Setup and teardown
|
|
|
|
--
|
|
|
|
|
2012-04-25 23:10:37 +00:00
|
|
|
local sln, prj, cfg
|
2012-07-06 21:01:50 +00:00
|
|
|
local cwd
|
2012-04-25 23:10:37 +00:00
|
|
|
|
2011-06-09 19:15:39 +00:00
|
|
|
function suite.setup()
|
|
|
|
sln = test.createsolution()
|
2012-07-06 21:01:50 +00:00
|
|
|
cwd = os.getcwd() .. '/'
|
2011-06-09 19:15:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
local function prepare()
|
2012-02-02 01:00:24 +00:00
|
|
|
prj = premake.solution.getproject_ng(sln, 1)
|
2012-04-25 23:10:37 +00:00
|
|
|
cfg = project.getconfig(prj, "Debug")
|
2011-06-09 19:15:39 +00:00
|
|
|
end
|
2011-07-01 19:05:16 +00:00
|
|
|
|
2011-06-09 19:15:39 +00:00
|
|
|
|
|
|
|
--
|
|
|
|
-- Test simple replacements
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.ReturnsOriginalPath_OnNoVpaths()
|
2012-07-06 21:01:50 +00:00
|
|
|
files { "hello.c" }
|
2011-06-09 19:15:39 +00:00
|
|
|
prepare()
|
2012-07-06 21:01:50 +00:00
|
|
|
test.isequal(cfg.files[1], project.getvpath(prj, cfg.files[1]))
|
2011-06-09 19:15:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.ReturnsOriginalPath_OnNoMatches()
|
2012-07-06 21:01:50 +00:00
|
|
|
files { "hello.c" }
|
2011-07-19 22:07:30 +00:00
|
|
|
vpaths { ["Headers"] = "**.h" }
|
2011-06-09 19:15:39 +00:00
|
|
|
prepare()
|
2012-07-06 21:01:50 +00:00
|
|
|
test.isequal(cfg.files[1], project.getvpath(prj, cfg.files[1]))
|
2011-06-09 19:15:39 +00:00
|
|
|
end
|
|
|
|
|
2012-11-14 17:42:53 +00:00
|
|
|
function suite.CanStripPaths()
|
2012-07-06 21:01:50 +00:00
|
|
|
files { "src/myproject/hello.c" }
|
2011-07-19 22:07:30 +00:00
|
|
|
vpaths { [""] = "src" }
|
2011-06-09 19:15:39 +00:00
|
|
|
prepare()
|
2012-11-14 17:42:53 +00:00
|
|
|
test.isequal("hello.c", project.getvpath(prj, cfg.files[1]))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.CanTrimLeadingPaths()
|
|
|
|
files { "src/myproject/hello.c" }
|
|
|
|
vpaths { ["*"] = "src" }
|
|
|
|
prepare()
|
2012-07-06 21:01:50 +00:00
|
|
|
test.isequal("myproject/hello.c", project.getvpath(prj, cfg.files[1]))
|
2011-06-09 19:15:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.PatternMayIncludeTrailingSlash()
|
2012-07-06 21:01:50 +00:00
|
|
|
files { "src/myproject/hello.c" }
|
2011-07-19 22:07:30 +00:00
|
|
|
vpaths { [""] = "src/myproject/" }
|
2011-06-09 19:15:39 +00:00
|
|
|
prepare()
|
2012-07-06 21:01:50 +00:00
|
|
|
test.isequal("hello.c", project.getvpath(prj, cfg.files[1]))
|
2011-06-09 19:15:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.SimpleReplacementPatterns()
|
2012-07-06 21:01:50 +00:00
|
|
|
files { "src/myproject/hello.c" }
|
2011-07-19 22:07:30 +00:00
|
|
|
vpaths { ["sources"] = "src/myproject" }
|
2011-06-09 19:15:39 +00:00
|
|
|
prepare()
|
2012-07-06 21:01:50 +00:00
|
|
|
test.isequal("sources/hello.c", project.getvpath(prj, cfg.files[1]))
|
2011-06-09 19:15:39 +00:00
|
|
|
end
|
|
|
|
|
2012-09-18 15:24:18 +00:00
|
|
|
function suite.ExactFilenameMatch()
|
|
|
|
files { "src/hello.c" }
|
|
|
|
vpaths { ["sources"] = "src/hello.c" }
|
|
|
|
prepare()
|
|
|
|
test.isequal("sources/hello.c", project.getvpath(prj, cfg.files[1]))
|
|
|
|
end
|
|
|
|
|
2011-07-01 19:05:16 +00:00
|
|
|
|
2011-06-09 19:15:39 +00:00
|
|
|
--
|
|
|
|
-- Test wildcard patterns
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.MatchFilePattern_ToGroup_Flat()
|
2012-07-06 21:01:50 +00:00
|
|
|
files { "src/myproject/hello.h" }
|
2011-07-19 22:07:30 +00:00
|
|
|
vpaths { ["Headers"] = "**.h" }
|
2011-06-09 19:15:39 +00:00
|
|
|
prepare()
|
2012-07-06 21:01:50 +00:00
|
|
|
test.isequal("Headers/hello.h", project.getvpath(prj, cfg.files[1]))
|
2011-06-09 19:15:39 +00:00
|
|
|
end
|
|
|
|
|
2012-11-14 17:42:53 +00:00
|
|
|
function suite.MatchFilePattern_ToNone_Flat()
|
|
|
|
files { "src/myproject/hello.h" }
|
|
|
|
vpaths { [""] = "**.h" }
|
|
|
|
prepare()
|
|
|
|
test.isequal("hello.h", project.getvpath(prj, cfg.files[1]))
|
|
|
|
end
|
|
|
|
|
2011-06-09 19:15:39 +00:00
|
|
|
function suite.MatchFilePattern_ToNestedGroup_Flat()
|
2012-07-06 21:01:50 +00:00
|
|
|
files { "src/myproject/hello.h" }
|
2011-07-19 22:07:30 +00:00
|
|
|
vpaths { ["Source/Headers"] = "**.h" }
|
2011-06-09 19:15:39 +00:00
|
|
|
prepare()
|
2012-07-06 21:01:50 +00:00
|
|
|
test.isequal("Source/Headers/hello.h", project.getvpath(prj, cfg.files[1]))
|
2011-06-09 19:15:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.MatchFilePattern_ToGroup_WithTrailingSlash()
|
2012-07-06 21:01:50 +00:00
|
|
|
files { "src/myproject/hello.h" }
|
2011-07-19 22:07:30 +00:00
|
|
|
vpaths { ["Headers/"] = "**.h" }
|
2011-06-09 19:15:39 +00:00
|
|
|
prepare()
|
2012-07-06 21:01:50 +00:00
|
|
|
test.isequal("Headers/hello.h", project.getvpath(prj, cfg.files[1]))
|
2011-06-09 19:15:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.MatchFilePattern_ToNestedGroup_Flat()
|
2012-07-06 21:01:50 +00:00
|
|
|
files { "src/myproject/hello.h" }
|
2011-07-19 22:07:30 +00:00
|
|
|
vpaths { ["Group/Headers"] = "**.h" }
|
2011-06-09 19:15:39 +00:00
|
|
|
prepare()
|
2012-07-06 21:01:50 +00:00
|
|
|
test.isequal("Group/Headers/hello.h", project.getvpath(prj, cfg.files[1]))
|
2011-06-09 19:15:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.MatchFilePattern_ToGroup_Nested()
|
2012-07-06 21:01:50 +00:00
|
|
|
files { "src/myproject/hello.h" }
|
2012-11-14 17:42:53 +00:00
|
|
|
vpaths { ["Headers/*"] = "**.h" }
|
2011-06-09 19:15:39 +00:00
|
|
|
prepare()
|
2012-07-06 21:01:50 +00:00
|
|
|
test.isequal("Headers/src/myproject/hello.h", project.getvpath(prj, cfg.files[1]))
|
2011-06-09 19:15:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.MatchFilePattern_ToGroup_Nested_OneStar()
|
2012-07-06 21:01:50 +00:00
|
|
|
files { "src/myproject/hello.h" }
|
2011-07-19 22:07:30 +00:00
|
|
|
vpaths { ["Headers/*"] = "**.h" }
|
2011-06-09 19:15:39 +00:00
|
|
|
prepare()
|
2012-07-06 21:01:50 +00:00
|
|
|
test.isequal("Headers/src/myproject/hello.h", project.getvpath(prj, cfg.files[1]))
|
2011-06-09 19:15:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.MatchFilePatternWithPath_ToGroup_Nested()
|
2012-07-06 21:01:50 +00:00
|
|
|
files { "src/myproject/hello.h" }
|
2012-11-14 17:42:53 +00:00
|
|
|
vpaths { ["Headers/*"] = "src/**.h" }
|
2011-06-09 19:15:39 +00:00
|
|
|
prepare()
|
2012-07-06 21:01:50 +00:00
|
|
|
test.isequal("Headers/myproject/hello.h", project.getvpath(prj, cfg.files[1]))
|
2011-06-09 19:15:39 +00:00
|
|
|
end
|
2011-07-01 19:05:16 +00:00
|
|
|
|
|
|
|
|
2011-08-22 20:35:51 +00:00
|
|
|
--
|
|
|
|
-- Test with project locations
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.MatchPath_OnProjectLocationSet()
|
|
|
|
location "build"
|
|
|
|
files "src/hello.h"
|
|
|
|
vpaths { [""] = "src" }
|
|
|
|
prepare()
|
2012-04-25 23:10:37 +00:00
|
|
|
test.isequal("hello.h", project.getvpath(prj, cfg.files[1]))
|
2011-08-22 20:35:51 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.MatchFilePattern_OnProjectLocationSet()
|
|
|
|
location "build"
|
|
|
|
files "src/hello.h"
|
|
|
|
vpaths { ["Headers"] = "**.h" }
|
|
|
|
prepare()
|
2012-04-25 23:10:37 +00:00
|
|
|
test.isequal("Headers/hello.h", project.getvpath(prj, cfg.files[1]))
|
2011-08-22 20:35:51 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.MatchFilePatternWithPath_OnProjectLocationSet()
|
|
|
|
location "build"
|
|
|
|
files "src/hello.h"
|
|
|
|
vpaths { ["Headers"] = "src/**.h" }
|
|
|
|
prepare()
|
2012-04-25 23:10:37 +00:00
|
|
|
test.isequal("Headers/hello.h", project.getvpath(prj, cfg.files[1]))
|
2011-08-22 20:35:51 +00:00
|
|
|
end
|