diff options
author | Jason Perkins <starkos@industriousone.com> | 2011-07-20 02:07:30 +0400 |
---|---|---|
committer | Jason Perkins <starkos@industriousone.com> | 2011-07-20 02:07:30 +0400 |
commit | 38692f2e193c7d2ba2c463f3bcdd1e445a785f15 (patch) | |
tree | 3dce989d8d4ec7f8440728ded3142421eec64712 /tests | |
parent | a06602621f46f5f9e3f0144a7c73677c6872dbfa (diff) |
Flipped vpaths syntax, now ['group']={'pattern(s)'...}
Diffstat (limited to 'tests')
-rw-r--r-- | tests/actions/vstudio/vc2010/test_filters.lua | 6 | ||||
-rw-r--r-- | tests/baking/test_merging.lua | 25 | ||||
-rw-r--r-- | tests/base/test_api.lua | 33 | ||||
-rw-r--r-- | tests/project/test_vpaths.lua | 32 |
4 files changed, 46 insertions, 50 deletions
diff --git a/tests/actions/vstudio/vc2010/test_filters.lua b/tests/actions/vstudio/vc2010/test_filters.lua index f603015..32e70b9 100644 --- a/tests/actions/vstudio/vc2010/test_filters.lua +++ b/tests/actions/vstudio/vc2010/test_filters.lua @@ -80,7 +80,7 @@ function suite.UniqueIdentifiers_ListVpaths()
files { "hello.c", "goodbye.c" }
- vpaths { ["**.c"] = "Source Files" }
+ vpaths { ["Source Files"] = "**.c" }
prepare()
vc2010.filteridgroup(prj)
test.capture [[
@@ -95,7 +95,7 @@ function suite.UniqueIdentifiers_ListRealAndVpaths()
files { "hello.h", "goodbye.c" }
- vpaths { ["*.c"] = "Source Files", ["*.h"] = "Header Files" }
+ vpaths { ["Source Files"] = "*.c", ["Header Files"] = "*.h" }
prepare()
vc2010.filteridgroup(prj)
test.capture [[
@@ -144,7 +144,7 @@ function suite.FileFilters_HasFilter_OnVpath()
files { "src/hello.c" }
- vpaths { ["**.c"] = "Source Files" }
+ vpaths { ["Source Files"] = "**.c" }
prepare()
vc2010.filefiltergroup(prj, "ClCompile")
test.capture [[
diff --git a/tests/baking/test_merging.lua b/tests/baking/test_merging.lua index c6b7d1e..6cce7d9 100644 --- a/tests/baking/test_merging.lua +++ b/tests/baking/test_merging.lua @@ -82,27 +82,18 @@ -- function suite.KeyValue_AreMerged() - vpaths { ["sln"] = "Solution" } + vpaths { ["Solution"] = "*.sln" } project "MyProject" - vpaths { ["prj"] = "Project" } + vpaths { ["Project"] = "*.prj" } prepare() - test.isequal("Solution", prj.vpaths["sln"]) - test.isequal("Project", prj.vpaths["prj"]) + test.isequal({"*.sln"}, prj.vpaths["Solution"]) + test.isequal({"*.prj"}, prj.vpaths["Project"]) end - function suite.KeyValue_OverwritesOldValues() - vpaths { ["sln"] = "Solution", ["prj"] = "Solution2" } + function suite.KeyValue_MergesValues() + vpaths { ["Solution"] = "*.sln", ["Project"] = "*.prj" } project "MyProject" - vpaths { ["prj"] = "Project" } + vpaths { ["Project"] = "*.prjx" } prepare() - test.isequal("Project", prj.vpaths["prj"]) + test.isequal({"*.prj","*.prjx"}, prj.vpaths["Project"]) end - - function suite.KeyValue_FlattensNestedTables() - vpaths { ["r"] = "Root", { ["n"] = "Nested" } } - project "MyProject" - prepare() - test.isequal("Root", prj.vpaths["r"]) - test.isequal("Nested", prj.vpaths["n"]) - end - diff --git a/tests/base/test_api.lua b/tests/base/test_api.lua index 98d116d..7727d4b 100644 --- a/tests/base/test_api.lua +++ b/tests/base/test_api.lua @@ -124,10 +124,22 @@ -- premake.setkeyvalue() tests -- - function suite.setkeyvalue_InsertsValues_OnTable() + function suite.setkeyvalue_Inserts_OnStringValue() premake.CurrentConfiguration = { } - premake.setkeyvalue("config", "vpaths", { ["*.h"] = "Headers" }) - test.isequal("Headers", premake.CurrentConfiguration.vpaths["*.h"]) + premake.setkeyvalue("config", "vpaths", { ["Headers"] = "*.h" }) + test.isequal({"*.h"}, premake.CurrentConfiguration.vpaths["Headers"]) + end + + function suite.setkeyvalue_Inserts_OnTableValue() + premake.CurrentConfiguration = { } + premake.setkeyvalue("config", "vpaths", { ["Headers"] = {"*.h","*.hpp"} }) + test.isequal({"*.h","*.hpp"}, premake.CurrentConfiguration.vpaths["Headers"]) + end + + function suite.setkeyvalue_Inserts_OnEmptyStringKey() + premake.CurrentConfiguration = { } + premake.setkeyvalue("config", "vpaths", { [""] = "src" }) + test.isequal({"src"}, premake.CurrentConfiguration.vpaths[""]) end function suite.setkeyvalue_RaisesError_OnString() @@ -136,18 +148,19 @@ test.isfalse(ok) end - function suite.setkeyvalue_RaisesError_OnNonStringKey() + function suite.setkeyvalue_InsertsString_IntoExistingKey() premake.CurrentConfiguration = { } - ok, err = pcall(function () premake.setkeyvalue("config", "vpaths", { [1] = "Headers" }) end) - test.isfalse(ok) + premake.setkeyvalue("config", "vpaths", { ["Headers"] = "*.h" }) + premake.setkeyvalue("config", "vpaths", { ["Headers"] = "*.hpp" }) + test.isequal({"*.h","*.hpp"}, premake.CurrentConfiguration.vpaths["Headers"]) end - function suite.setkeyvalue_RaisesError_OnNonStringValue() + function suite.setkeyvalue_InsertsTable_IntoExistingKey() premake.CurrentConfiguration = { } - ok, err = pcall(function () premake.setkeyvalue("config", "vpaths", { ["*.h"] = 1 }) end) - test.isfalse(ok) + premake.setkeyvalue("config", "vpaths", { ["Headers"] = {"*.h"} }) + premake.setkeyvalue("config", "vpaths", { ["Headers"] = {"*.hpp"} }) + test.isequal({"*.h","*.hpp"}, premake.CurrentConfiguration.vpaths["Headers"]) end - -- diff --git a/tests/project/test_vpaths.lua b/tests/project/test_vpaths.lua index f4832e2..49631e2 100644 --- a/tests/project/test_vpaths.lua +++ b/tests/project/test_vpaths.lua @@ -34,28 +34,25 @@ end function suite.ReturnsOriginalPath_OnNoMatches() - vpaths { ["**.h"] = "Headers" } + vpaths { ["Headers"] = "**.h" } prepare() test.isequal("hello.c", project.getvpath(prj, "hello.c")) end - function suite.CanTrimLeadingPaths() - vpaths { ["src"] = "" } + vpaths { [""] = "src" } prepare() test.isequal("myproject/hello.c", project.getvpath(prj, "src/myproject/hello.c")) end - function suite.PatternMayIncludeTrailingSlash() - vpaths { ["src/myproject/"] = "" } + vpaths { [""] = "src/myproject/" } prepare() test.isequal("hello.c", project.getvpath(prj, "src/myproject/hello.c")) end - function suite.SimpleReplacementPatterns() - vpaths { ["src/myproject"] = "sources" } + vpaths { ["sources"] = "src/myproject" } prepare() test.isequal("sources/hello.c", project.getvpath(prj, "src/myproject/hello.c")) end @@ -66,54 +63,49 @@ -- function suite.MatchFilePattern_ToGroup_Flat() - vpaths { ["**.h"] = "Headers" } + vpaths { ["Headers"] = "**.h" } prepare() test.isequal("Headers/hello.h", project.getvpath(prj, "src/myproject/hello.h")) end - function suite.MatchFilePattern_ToNestedGroup_Flat() - vpaths { ["**.h"] = "Source/Headers" } + vpaths { ["Source/Headers"] = "**.h" } prepare() test.isequal("Source/Headers/hello.h", project.getvpath(prj, "src/myproject/hello.h")) end - function suite.MatchFilePattern_ToGroup_WithTrailingSlash() - vpaths { ["**.h"] = "Headers/" } + vpaths { ["Headers/"] = "**.h" } prepare() test.isequal("Headers/hello.h", project.getvpath(prj, "src/myproject/hello.h")) end - function suite.MatchFilePattern_ToNestedGroup_Flat() - vpaths { ["**.h"] = "Group/Headers" } + vpaths { ["Group/Headers"] = "**.h" } prepare() test.isequal("Group/Headers/hello.h", project.getvpath(prj, "src/myproject/hello.h")) end - function suite.MatchFilePattern_ToGroup_Nested() - vpaths { ["**.h"] = "Headers/**" } + vpaths { ["Headers/**"] = "**.h" } 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/*" } + vpaths { ["Headers/*"] = "**.h" } 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/**" } + vpaths { ["Headers/**"] = "src/**.h" } prepare() test.isequal("Headers/myproject/hello.h", project.getvpath(prj, "src/myproject/hello.h")) end + -- -- Test directory dot patterns -- |