Permalink
Browse files

Cleaned up test suite for new oven

  • Loading branch information...
1 parent 63307dc commit 9a2829b0062d29c71109f7583fd215e195ba1461 @starkos starkos committed Apr 16, 2012
Showing with 373 additions and 334 deletions.
  1. +89 −0 tests/oven/test_basics.lua
  2. +154 −0 tests/oven/test_lists.lua
  3. +39 −0 tests/oven/test_objects.lua
  4. +87 −0 tests/oven/test_removes.lua
  5. +4 −1 tests/premake4.lua
  6. +0 −333 tests/project/test_baking.lua
View
@@ -0,0 +1,89 @@
+--
+-- tests/oven/test_basics.lua
+-- Test the Premake oven, which handles flattening of configurations.
+-- Copyright (c) 2011-2012 Jason Perkins and the Premake project
+--
+
+ T.oven_basics = { }
+ local suite = T.oven_basics
+ local oven = premake5.oven
+
+
+--
+-- Setup and teardown
+--
+
+ local sln, prj
+
+ function suite.setup()
+ sln = solution("MySolution")
+ end
+
+
+--
+-- When a solution is baked, a reference to that solution should be
+-- placed in the resulting configuration.
+--
+
+ function suite.solutionSet_whenCalledOnSolution()
+ local cfg = oven.bake(sln)
+ test.istrue(sln == cfg.solution)
+ end
+
+
+--
+-- When a project is baked, a reference to that project should be
+-- placed in the resulting configuration.
+--
+
+ function suite.solutionSet_whenCalledOnSolution()
+ prj = project("MyProject")
+ local cfg = oven.bake(prj)
+ test.istrue(prj == cfg.project)
+ end
+
+
+--
+-- Test pulling "project global" values, which are associated with
+-- all configurations in the project.
+--
+
+ function suite.callPullProjectLevelConfig()
+ prj = project("MyProject")
+ files { "hello.cpp" }
+ cfg = oven.bake(prj, {}, "files")
+ test.isequal("hello.cpp", cfg.files[1]:sub(-9))
+ end
+
+
+--
+-- The keywords field should NOT be included in the configuration objects
+-- returned by the backing process.
+--
+
+ function suite.noKeywordsInBakingResults()
+ configuration("Debug")
+ defines("DEBUG")
+ cfg = oven.bake(sln)
+ test.isnil(cfg.keywords)
+ end
+
+
+--
+-- Requests for a single field should return just that value.
+--
+
+ function suite.fieldValueReturned_onFilterFieldPresent()
+ configuration("Debug")
+ kind "SharedLib"
+ cfg = oven.bake(sln, {"Debug"}, "kind")
+ test.isequal("SharedLib", cfg.kind)
+ end
+
+ function suite.otherFieldsNotReturned_onFilterFieldPresent()
+ configuration("Debug")
+ kind("SharedLib")
+ defines("DEBUG")
+ cfg = oven.bake(sln, {"Debug"}, "kind")
+ test.isnil(cfg.defines)
+ end
View
@@ -0,0 +1,154 @@
+--
+-- tests/oven/test_lists.lua
+-- Test the Premake oven list handling.
+-- Copyright (c) 2011-2012 Jason Perkins and the Premake project
+--
+
+ T.oven_lists = { }
+ local suite = T.oven_lists
+ local oven = premake5.oven
+
+
+--
+-- Setup and teardown
+--
+
+ local sln, prj
+
+ function suite.setup()
+ sln = solution("MySolution")
+ end
+
+
+--
+-- API values that are not set in any configuration should be initialized
+-- with empty defaults (makes downstream usage easier).
+--
+
+ function suite.emptyDefaultsSet_forMissingApiValues()
+ local cfg = oven.bake(sln)
+ test.isequal(0, #cfg.defines)
+ end
+
+
+--
+-- Values defined at the solution level should be included in configurations
+-- built from the solution.
+--
+
+ function suite.solutionValuePresent_onSolutionConfig()
+ defines "SOLUTION"
+ local cfg = oven.bake(sln)
+ test.isequal("SOLUTION", table.concat(cfg.defines))
+ end
+
+
+--
+-- Values defined at the project level should be included in configurations
+-- built from the project.
+--
+
+ function suite.projectValuePreset_onProjectConfig()
+ prj = project "MyProject"
+ defines "PROJECT"
+ local cfg = oven.bake(prj)
+ test.isequal("PROJECT", table.concat(cfg.defines))
+ end
+
+
+--
+-- Values defined at the solution level should also be present in
+-- configurations built from projects within that solution.
+--
+
+ function suite.solutionValuePresent_onProjectConfig()
+ defines("SOLUTION")
+ prj = project("MyProject")
+ local cfg = oven.bake(prj)
+ test.isequal("SOLUTION", table.concat(cfg.defines))
+ end
+
+
+--
+-- When a list value is present at both the solution and project
+-- level, the values should be merged, with the solution values
+-- coming first.
+--
+
+ function suite.solutionAndProjectValuesMerged_onProjectConfig()
+ defines("SOLUTION")
+ prj = project("MyProject")
+ defines("PROJECT")
+ local cfg = oven.bake(prj)
+ test.isequal("SOLUTION|PROJECT", table.concat(cfg.defines, "|"))
+ end
+
+
+--
+-- A value specified in a block with more general terms should appear
+-- in more specific configurations.
+--
+
+ function suite.valueFromGeneralConfigPreset_onMoreSpecificConfig()
+ defines("SOLUTION")
+ local cfg = oven.bake(sln, {"Debug"})
+ test.isequal("SOLUTION", table.concat(cfg.defines))
+ end
+
+ function suite.valueFromGeneralConfigPreset_onMoreSpecificConfig()
+ configuration("Debug")
+ defines("DEBUG")
+ local cfg = oven.bake(sln, {"Debug","Windows"})
+ test.isequal("DEBUG", table.concat(cfg.defines))
+ end
+
+
+--
+-- Values present in a specific configuration should only be included
+-- if a matching filter term is present.
+--
+
+ function suite.configValueNotPresent_ifNoMatchingFilterTerm()
+ configuration("Debug")
+ defines("DEBUG")
+ cfg = oven.bake(sln)
+ test.isequal(0, #cfg.defines)
+ end
+
+ function suite.configValuePresent_ifMatchingFilterTerm()
+ configuration("Debug")
+ kind "SharedLib"
+ cfg = oven.bake(sln, {"Debug"})
+ test.isequal("SharedLib", cfg.kind)
+ end
+
+
+--
+-- When values for a field are present in solution and project configurations,
+-- all should be copied, with the solution values first.
+--
+
+ function suite.solutionAndProjectAndConfigValuesMerged()
+ defines("SOLUTION")
+ configuration("Debug")
+ defines("SLN_DEBUG")
+ prj = project("MyProject")
+ defines("PROJECT")
+ configuration("Debug")
+ defines("PRJ_DEBUG")
+ cfg = oven.bake(prj , {"Debug"})
+ test.isequal("SOLUTION|SLN_DEBUG|PROJECT|PRJ_DEBUG", table.concat(cfg.defines, "|"))
+ end
+
+
+--
+-- Duplicate values should be removed from list values.
+--
+
+ function suite.removesDuplicateValues()
+ defines { "SOLUTION", "DUPLICATE" }
+ prj = project("MyProject")
+ defines { "PROJECT", "DUPLICATE" }
+ cfg = oven.bake(prj, {"Debug"})
+ test.isequal("SOLUTION|DUPLICATE|PROJECT", table.concat(cfg.defines, "|"))
+ end
@@ -0,0 +1,39 @@
+--
+-- tests/oven/test_objects.lua
+-- Test Premake oven handling of objects.
+-- Copyright (c) 2011-2012 Jason Perkins and the Premake project
+--
+
+ T.oven_objects = { }
+ local suite = T.oven_objects
+ local oven = premake5.oven
+
+
+--
+-- Setup and teardown
+--
+
+ local sln, prj
+
+ function suite.setup()
+ sln = solution("MySolution")
+ end
+
+
+--
+-- Object values should be merged into baked results.
+--
+
+ function suite.objectValuesAreMerged()
+ buildrule { description="test" }
+ cfg = oven.bake(sln)
+ test.isequal("test", cfg.buildrule.description)
+ end
+
+ function suite.objectValueOverwritten_onMultipleValues()
+ buildrule { description="sln" }
+ prj = project("MyProject")
+ buildrule { description="prj" }
+ cfg = oven.bake(prj, {"Debug"})
+ test.isequal("prj", cfg.buildrule.description)
+ end
@@ -0,0 +1,87 @@
+--
+-- tests/oven/test_removes.lua
+-- Test the Premake oven ability to remove values from lists.
+-- Copyright (c) 2011-2012 Jason Perkins and the Premake project
+--
+
+ T.oven_removes = { }
+ local suite = T.oven_removes
+ local oven = premake5.oven
+
+
+--
+-- Setup and teardown
+--
+
+ local sln, prj
+
+ function suite.setup()
+ sln = solution("MySolution")
+ end
+
+
+--
+-- Check removing a value with an exact match.
+--
+
+ function suite.remove_onExactValueMatch()
+ flags { "Symbols", "Optimize", "NoRTTI" }
+ removeflags "Optimize"
+ cfg = oven.bake(sln)
+ test.isequal("Symbols|NoRTTI", table.concat(cfg.flags, "|"))
+ end
+
+ function suite.remove_onMultipleValues()
+ flags { "Symbols", "NoExceptions", "Optimize", "NoRTTI" }
+ removeflags { "NoExceptions", "NoRTTI" }
+ cfg = oven.bake(sln)
+ test.isequal("Symbols|Optimize", table.concat(cfg.flags, "|"))
+ end
+
+
+--
+-- Remove should also accept wildcards.
+--
+
+ function suite.remove_onWildcard()
+ defines { "WIN32", "WIN64", "LINUX", "MACOSX" }
+ removedefines { "WIN*" }
+ cfg = oven.bake(sln)
+ test.isequal("LINUX|MACOSX", table.concat(cfg.defines, "|"))
+ end
+
+--
+-- Remove should removed both indexed and keyed values.
+--
+
+ function suite.remove_onExactValueMatch()
+ flags { "Symbols", "Optimize", "NoRTTI" }
+ removeflags "Optimize"
+ cfg = oven.bake(sln)
+ test.isnil(cfg.flags.Optimize)
+ end
+
+--
+-- Remove should also work with file paths.
+--
+
+ function suite.remove_onFileField()
+ files { "hello.c", "goodbye.c" }
+ removefiles { "goodbye.c" }
+ cfg = oven.bake(sln)
+ test.isequal(path.join(os.getcwd(), "hello.c"), table.concat(cfg.files))
+ end
+
+--
+-- Remove should work on container-level fields too.
+--
+
+ function suite.remove_onContainerField()
+ configurations { "Debug", "Release" }
+ local prj = project "MyProject"
+ removeconfigurations { "Debug" }
+
+ cfg = oven.merge({}, sln)
+ cfg = oven.merge(cfg, prj)
+ test.isequal({ "Release" }, cfg.configurations)
+ end
View
@@ -61,7 +61,6 @@
-- Project object tests
dofile("test_project.lua")
- dofile("project/test_baking.lua")
dofile("project/test_eachconfig.lua")
dofile("project/test_filtering.lua")
dofile("project/test_getconfig.lua")
@@ -83,7 +82,11 @@
-- Baking tests
dofile("base/test_baking.lua")
+ dofile("oven/test_basics.lua")
dofile("oven/test_keyvalues.lua")
+ dofile("oven/test_lists.lua")
+ dofile("oven/test_objects.lua")
+ dofile("oven/test_removes.lua")
-- Toolset tests
dofile("tools/test_gcc.lua")
Oops, something went wrong.

0 comments on commit 9a2829b

Please sign in to comment.