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-02 23:26:15 +0400
committerJason Perkins <starkos@industriousone.com>2011-06-02 23:26:15 +0400
commit2580bd7798aa41ae14fd1503ed0534aaec7f94ba (patch)
tree6f10aba5be648e589de5bdda6ce8b529f44ae52c /tests
parenta315c34f15f0b90eb2c611a676cabe07b2a1db5b (diff)
Added support for key-value fields to the API
Diffstat (limited to 'tests')
-rw-r--r--tests/baking/test_merging.lua108
-rw-r--r--tests/base/test_api.lua32
-rw-r--r--tests/base/test_baking.lua12
-rw-r--r--tests/premake4.lua5
4 files changed, 143 insertions, 14 deletions
diff --git a/tests/baking/test_merging.lua b/tests/baking/test_merging.lua
new file mode 100644
index 0000000..c6b7d1e
--- /dev/null
+++ b/tests/baking/test_merging.lua
@@ -0,0 +1,108 @@
+--
+-- tests/baking/test_merging.lua
+-- Verifies different field types are merged properly during baking.
+-- Copyright (c) 2011 Jason Perkins and the Premake project
+--
+
+ T.baking_merging = { }
+ local suite = T.baking_merging
+
+--
+-- Setup code
+--
+
+ local sln, prj, cfg
+ function suite.setup()
+ sln = solution "MySolution"
+ configurations { "Debug", "Release" }
+ end
+
+ local function prepare()
+ premake.bake.buildconfigs()
+ prj = premake.solution.getproject(sln, 1)
+ end
+
+
+--
+-- String value tests
+--
+
+ function suite.Strings_AreReplaced()
+ kind "SharedLib"
+ project "MyProject"
+ kind "StaticLib"
+ prepare()
+ test.isequal("StaticLib", prj.kind)
+ end
+
+ function suite.Strings_KeepPreviousValue()
+ kind "SharedLib"
+ project "MyProject"
+ prepare()
+ test.isequal("SharedLib", prj.kind)
+ end
+
+
+--
+-- List tests
+--
+
+ function suite.Lists_KeepPreviousValue()
+ project "MyProject"
+ prepare()
+ test.isequal("Debug:Release", table.concat(prj.configurations, ":"))
+ end
+
+ function suite.Lists_AreJoined()
+ defines { "SOLUTION" }
+ project "MyProject"
+ defines { "PROJECT" }
+ prepare()
+ test.isequal("SOLUTION:PROJECT", table.concat(prj.defines, ":"))
+ end
+
+ function suite.Lists_RemoveDuplicates()
+ defines { "SOLUTION", "DUPLICATE" }
+ project "MyProject"
+ defines { "PROJECT", "DUPLICATE" }
+ prepare()
+ test.isequal("SOLUTION:DUPLICATE:PROJECT", table.concat(prj.defines, ":"))
+ end
+
+ function suite.Lists_FlattensNestedTables()
+ defines { "ROOT", { "NESTED" } }
+ project "MyProject"
+ prepare()
+ test.isequal("ROOT:NESTED", table.concat(prj.defines, ":"))
+ end
+
+
+--
+-- Key/value tests
+--
+
+ function suite.KeyValue_AreMerged()
+ vpaths { ["sln"] = "Solution" }
+ project "MyProject"
+ vpaths { ["prj"] = "Project" }
+ prepare()
+ test.isequal("Solution", prj.vpaths["sln"])
+ test.isequal("Project", prj.vpaths["prj"])
+ end
+
+ function suite.KeyValue_OverwritesOldValues()
+ vpaths { ["sln"] = "Solution", ["prj"] = "Solution2" }
+ project "MyProject"
+ vpaths { ["prj"] = "Project" }
+ prepare()
+ test.isequal("Project", prj.vpaths["prj"])
+ 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 854610d..98d116d 100644
--- a/tests/base/test_api.lua
+++ b/tests/base/test_api.lua
@@ -1,7 +1,7 @@
--
-- tests/base/test_api.lua
-- Automated test suite for the project API support functions.
--- Copyright (c) 2008-2010 Jason Perkins and the Premake project
+-- Copyright (c) 2008-2011 Jason Perkins and the Premake project
--
T.api = { }
@@ -121,6 +121,36 @@
--
+-- premake.setkeyvalue() tests
+--
+
+ function suite.setkeyvalue_InsertsValues_OnTable()
+ premake.CurrentConfiguration = { }
+ premake.setkeyvalue("config", "vpaths", { ["*.h"] = "Headers" })
+ test.isequal("Headers", premake.CurrentConfiguration.vpaths["*.h"])
+ end
+
+ function suite.setkeyvalue_RaisesError_OnString()
+ premake.CurrentConfiguration = { }
+ ok, err = pcall(function () premake.setkeyvalue("config", "vpaths", "Headers") end)
+ test.isfalse(ok)
+ end
+
+ function suite.setkeyvalue_RaisesError_OnNonStringKey()
+ premake.CurrentConfiguration = { }
+ ok, err = pcall(function () premake.setkeyvalue("config", "vpaths", { [1] = "Headers" }) end)
+ test.isfalse(ok)
+ end
+
+ function suite.setkeyvalue_RaisesError_OnNonStringValue()
+ premake.CurrentConfiguration = { }
+ ok, err = pcall(function () premake.setkeyvalue("config", "vpaths", { ["*.h"] = 1 }) end)
+ test.isfalse(ok)
+ end
+
+
+
+--
-- accessor tests
--
diff --git a/tests/base/test_baking.lua b/tests/base/test_baking.lua
index c446e16..c8168ce 100644
--- a/tests/base/test_baking.lua
+++ b/tests/base/test_baking.lua
@@ -57,18 +57,6 @@
-- Tests
--
- function suite.SolutionFields()
- prepare()
- test.isequal("Debug:Release", table.concat(cfg.configurations,":"))
- end
-
-
- function suite.ProjectFields()
- prepare()
- test.isequal("C", cfg.language)
- end
-
-
function suite.ProjectWideSettings()
prepare()
test.isequal("SOLUTION:PROJECT:NATIVE", table.concat(prj.defines,":"))
diff --git a/tests/premake4.lua b/tests/premake4.lua
index a4512be..992dd40 100644
--- a/tests/premake4.lua
+++ b/tests/premake4.lua
@@ -48,7 +48,6 @@
dofile("test_gmake_cs.lua")
dofile("base/test_api.lua")
dofile("base/test_action.lua")
- dofile("base/test_baking.lua")
dofile("base/test_config.lua")
dofile("base/test_location.lua")
dofile("base/test_os.lua")
@@ -58,6 +57,10 @@
dofile("tools/test_gcc.lua")
dofile("base/test_config_bug.lua")
+ -- Baking tests
+ dofile("base/test_baking.lua")
+ dofile("baking/test_merging.lua")
+
-- Clean tests
dofile("actions/test_clean.lua")