2011-12-21 00:03:45 +00:00
|
|
|
--
|
|
|
|
-- tests/project/test_eachconfig.lua
|
|
|
|
-- Test the project object configuration iterator function.
|
2012-02-19 17:31:20 +00:00
|
|
|
-- Copyright (c) 2011-2012 Jason Perkins and the Premake project
|
2011-12-21 00:03:45 +00:00
|
|
|
--
|
|
|
|
|
|
|
|
T.project_eachconfig = { }
|
|
|
|
local suite = T.project_eachconfig
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Setup and teardown
|
|
|
|
--
|
|
|
|
|
|
|
|
local sln, prj
|
|
|
|
|
|
|
|
function suite.setup()
|
|
|
|
sln = solution("MySolution")
|
|
|
|
end
|
|
|
|
|
|
|
|
local function prepare()
|
2012-02-19 17:31:20 +00:00
|
|
|
project("MyProject")
|
|
|
|
prj = premake.solution.getproject_ng(sln, 1)
|
|
|
|
for cfg in premake5.project.eachconfig(prj, field) do
|
|
|
|
_p(2,'%s:%s', cfg.buildcfg or "", cfg.platform or "")
|
2011-12-28 21:44:09 +00:00
|
|
|
end
|
2011-12-21 00:03:45 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- If no configurations have been defined, the iterator
|
|
|
|
-- should not return any values.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.returnsNoValues_onNoConfigurationsAndNoPlatforms()
|
|
|
|
prepare()
|
2012-02-19 17:31:20 +00:00
|
|
|
test.isemptycapture()
|
2011-12-21 00:03:45 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- If platforms have been defined, but no configurations, the
|
|
|
|
-- iterator should still not return any values.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.returnsNoValues_onNoConfigurationsButPlatforms()
|
|
|
|
platforms { "x32", "x64" }
|
|
|
|
prepare()
|
2012-02-19 17:31:20 +00:00
|
|
|
test.isemptycapture()
|
2011-12-21 00:03:45 +00:00
|
|
|
end
|
2011-12-28 21:44:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Configurations should be iterated in the order in which they
|
|
|
|
-- appear in the script.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.iteratesConfigsInOrder()
|
|
|
|
configurations { "Debug", "Profile", "Release", "Deploy" }
|
2012-02-19 17:31:20 +00:00
|
|
|
prepare()
|
|
|
|
test.capture [[
|
|
|
|
Debug:
|
|
|
|
Profile:
|
|
|
|
Release:
|
|
|
|
Deploy:
|
|
|
|
]]
|
2011-12-28 21:44:09 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- If platforms are supplied, they should be paired with build
|
|
|
|
-- configurations, with the order of both maintained.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.pairsConfigsAndPlatformsInOrder()
|
|
|
|
configurations { "Debug", "Release" }
|
|
|
|
platforms { "x32", "x64" }
|
2012-02-19 17:31:20 +00:00
|
|
|
prepare()
|
|
|
|
test.capture [[
|
|
|
|
Debug:x32
|
|
|
|
Debug:x64
|
|
|
|
Release:x32
|
|
|
|
Release:x64
|
|
|
|
]]
|
2012-01-18 00:04:46 +00:00
|
|
|
end
|
2012-04-11 22:56:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Test the mapping of a build configuration from solution to project.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.mapsBuildCfg_toBuildCfg()
|
|
|
|
configurations { "SolutionDebug", "Release" }
|
|
|
|
configmaps { ["SolutionDebug"] = "ProjectDebug" }
|
|
|
|
prepare()
|
|
|
|
test.capture [[
|
|
|
|
ProjectDebug:
|
|
|
|
Release:
|
|
|
|
]]
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Test mapping a platform from solution to project.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.mapsPlatform_toPlatform()
|
|
|
|
configurations { "Debug", "Release" }
|
|
|
|
platforms { "Win32", "Xbox360" }
|
|
|
|
configmaps { ["Xbox360"] = "x64" }
|
|
|
|
prepare()
|
|
|
|
test.capture [[
|
|
|
|
Debug:Win32
|
|
|
|
Debug:x64
|
|
|
|
]]
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Test mapping a build configuration to a build config/platform pair.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.mapsBuildCfg_toBuildCfgAndPlatform()
|
|
|
|
configurations { "Debug", "Release" }
|
|
|
|
configmaps { ["Debug"] = { "Debug", "Win32" } }
|
|
|
|
prepare()
|
|
|
|
test.capture [[
|
|
|
|
Debug:Win32
|
|
|
|
Release:
|
|
|
|
]]
|
|
|
|
end
|
|
|
|
|