Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/premake-4.x-stable.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJason Perkins <starkos@industriousone.com>2011-06-09 23:15:39 +0400
committerJason Perkins <starkos@industriousone.com>2011-06-09 23:15:39 +0400
commit96be30af0f63306753416a5948351cfcb46bc00a (patch)
tree127bb0671201503ddfadef74081026b3b856b1c5 /tests
parent2580bd7798aa41ae14fd1503ed0534aaec7f94ba (diff)
Added project.getvpath() to map from real paths
Diffstat (limited to 'tests')
-rw-r--r--tests/premake4.lua5
-rw-r--r--tests/project/test_vpaths.lua112
2 files changed, 116 insertions, 1 deletions
diff --git a/tests/premake4.lua b/tests/premake4.lua
index 992dd40..071ebdd 100644
--- a/tests/premake4.lua
+++ b/tests/premake4.lua
@@ -40,7 +40,6 @@
dofile("test_dofile.lua")
dofile("test_string.lua")
dofile("test_premake.lua")
- dofile("test_project.lua")
dofile("test_platforms.lua")
dofile("test_targets.lua")
dofile("test_keywords.lua")
@@ -57,6 +56,10 @@
dofile("tools/test_gcc.lua")
dofile("base/test_config_bug.lua")
+ -- Project API tests
+ dofile("test_project.lua")
+ dofile("project/test_vpaths.lua")
+
-- Baking tests
dofile("base/test_baking.lua")
dofile("baking/test_merging.lua")
diff --git a/tests/project/test_vpaths.lua b/tests/project/test_vpaths.lua
new file mode 100644
index 0000000..c7b2e1d
--- /dev/null
+++ b/tests/project/test_vpaths.lua
@@ -0,0 +1,112 @@
+--
+-- tests/project/test_vpaths.lua
+-- Automated test suite for the project support functions.
+-- Copyright (c) 2011 Jason Perkins and the Premake project
+--
+
+ T.project_vpaths = { }
+ local suite = T.project_vpaths
+ local project = premake.project
+
+
+--
+-- Setup and teardown
+--
+
+ local sln, prj
+ function suite.setup()
+ sln = test.createsolution()
+ end
+
+ local function prepare()
+ premake.bake.buildconfigs()
+ prj = premake.solution.getproject(sln, 1)
+ end
+
+--
+-- Test simple replacements
+--
+
+ function suite.ReturnsOriginalPath_OnNoVpaths()
+ prepare()
+ test.isequal("hello.c", project.getvpath(prj, "hello.c"))
+ end
+
+ function suite.ReturnsOriginalPath_OnNoMatches()
+ vpaths { ["**.h"] = "Headers" }
+ prepare()
+ test.isequal("hello.c", project.getvpath(prj, "hello.c"))
+ end
+
+
+ function suite.CanTrimLeadingPaths()
+ vpaths { ["src"] = "" }
+ prepare()
+ test.isequal("myproject/hello.c", project.getvpath(prj, "src/myproject/hello.c"))
+ end
+
+
+ function suite.PatternMayIncludeTrailingSlash()
+ vpaths { ["src/myproject/"] = "" }
+ prepare()
+ test.isequal("hello.c", project.getvpath(prj, "src/myproject/hello.c"))
+ end
+
+
+ function suite.SimpleReplacementPatterns()
+ vpaths { ["src/myproject"] = "sources" }
+ prepare()
+ test.isequal("sources/hello.c", project.getvpath(prj, "src/myproject/hello.c"))
+ end
+
+--
+-- Test wildcard patterns
+--
+
+ function suite.MatchFilePattern_ToGroup_Flat()
+ vpaths { ["**.h"] = "Headers" }
+ prepare()
+ test.isequal("Headers/hello.h", project.getvpath(prj, "src/myproject/hello.h"))
+ end
+
+
+ function suite.MatchFilePattern_ToNestedGroup_Flat()
+ vpaths { ["**.h"] = "Source/Headers" }
+ prepare()
+ test.isequal("Source/Headers/hello.h", project.getvpath(prj, "src/myproject/hello.h"))
+ end
+
+
+ function suite.MatchFilePattern_ToGroup_WithTrailingSlash()
+ vpaths { ["**.h"] = "Headers/" }
+ prepare()
+ test.isequal("Headers/hello.h", project.getvpath(prj, "src/myproject/hello.h"))
+ end
+
+
+ function suite.MatchFilePattern_ToNestedGroup_Flat()
+ vpaths { ["**.h"] = "Group/Headers" }
+ prepare()
+ test.isequal("Group/Headers/hello.h", project.getvpath(prj, "src/myproject/hello.h"))
+ end
+
+
+ function suite.MatchFilePattern_ToGroup_Nested()
+ vpaths { ["**.h"] = "Headers/**" }
+ prepare()
+ test.isequal("Headers/src/myproject/hello.h", project.getvpath(prj, "src/myproject/hello.h"))
+ end
+
+
+ function suite.MatchFilePattern_ToGroup_Nested_OneStar()
+ vpaths { ["**.h"] = "Headers/*" }
+ prepare()
+ test.isequal("Headers/src/myproject/hello.h", project.getvpath(prj, "src/myproject/hello.h"))
+ end
+
+
+ function suite.MatchFilePatternWithPath_ToGroup_Nested()
+ vpaths { ["src/**.h"] = "Headers/**" }
+ prepare()
+ test.isequal("Headers/myproject/hello.h", project.getvpath(prj, "src/myproject/hello.h"))
+ end