2012-01-22 17:19:43 +00:00
|
|
|
--
|
|
|
|
-- tests/project/test_getconfig.lua
|
|
|
|
-- Test the project object configuration accessor.
|
|
|
|
-- Copyright (c) 2011-2012 Jason Perkins and the Premake project
|
|
|
|
--
|
|
|
|
|
|
|
|
T.project_getconfig = { }
|
|
|
|
local suite = T.project_getconfig
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Setup and teardown
|
|
|
|
--
|
|
|
|
|
|
|
|
local sln, prj, cfg
|
|
|
|
|
|
|
|
function suite.setup()
|
2012-06-11 23:11:21 +00:00
|
|
|
sln = solution("MySolution")
|
|
|
|
configurations { "Debug", "Release" }
|
2012-01-22 17:19:43 +00:00
|
|
|
end
|
|
|
|
|
2012-06-11 23:11:21 +00:00
|
|
|
local function prepare(buildcfg, platform)
|
2013-09-13 15:52:00 +00:00
|
|
|
prj = premake.solution.getproject(sln, 1)
|
2013-09-13 15:15:36 +00:00
|
|
|
cfg = premake.project.getconfig(prj, buildcfg or "Debug", platform)
|
2012-05-08 19:37:12 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2012-01-22 17:19:43 +00:00
|
|
|
--
|
|
|
|
-- If the target system is not specified, the current operating environment
|
|
|
|
-- should be used as the default.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.usesCurrentOS_onNoSystemSpecified()
|
|
|
|
_OS = "linux"
|
2012-06-11 23:11:21 +00:00
|
|
|
project ("MyProject")
|
2012-01-22 17:19:43 +00:00
|
|
|
configuration { "linux" }
|
|
|
|
defines { "correct" }
|
|
|
|
prepare()
|
|
|
|
test.isequal("correct", cfg.defines[1])
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- If the current action specifies a target operating environment (i.e.
|
|
|
|
-- Visual Studio targets Windows), that should override the current
|
|
|
|
-- operating environment.
|
|
|
|
--
|
|
|
|
|
2012-04-25 23:10:37 +00:00
|
|
|
function suite.actionOverridesOS()
|
2012-01-22 17:19:43 +00:00
|
|
|
_OS = "linux"
|
|
|
|
_ACTION = "vs2005"
|
2012-06-11 23:11:21 +00:00
|
|
|
project ("MyProject")
|
2012-01-22 17:19:43 +00:00
|
|
|
configuration { "windows" }
|
|
|
|
defines { "correct" }
|
|
|
|
prepare()
|
|
|
|
test.isequal("correct", cfg.defines[1])
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- If a target system is specified in a configuration, it should override
|
|
|
|
-- the current operating environment, as well as the tool's target OS.
|
|
|
|
--
|
|
|
|
|
2012-04-25 23:10:37 +00:00
|
|
|
function suite.usesCfgSystem()
|
2012-01-22 17:19:43 +00:00
|
|
|
_OS = "linux"
|
|
|
|
_ACTION = "vs2005"
|
2012-06-11 23:11:21 +00:00
|
|
|
project ("MyProject")
|
2012-01-22 17:19:43 +00:00
|
|
|
system "macosx"
|
|
|
|
configuration { "macosx" }
|
|
|
|
defines { "correct" }
|
|
|
|
prepare()
|
|
|
|
test.isequal("correct", cfg.defines[1])
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- The current action should be taken into account.
|
|
|
|
--
|
|
|
|
|
2012-04-25 23:10:37 +00:00
|
|
|
function suite.appliesActionToFilters()
|
2012-01-22 17:19:43 +00:00
|
|
|
_ACTION = "vs2005"
|
2012-06-11 23:11:21 +00:00
|
|
|
project ("MyProject")
|
2012-01-22 17:19:43 +00:00
|
|
|
configuration { "vs2005" }
|
|
|
|
defines { "correct" }
|
|
|
|
prepare()
|
|
|
|
test.isequal("correct", cfg.defines[1])
|
|
|
|
end
|
2012-05-23 20:34:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
--
|
2012-11-17 20:49:06 +00:00
|
|
|
-- If the platform matches an architecture identifier, and none was set,
|
|
|
|
-- the configuration's architecture should be set to match.
|
2012-05-23 20:34:28 +00:00
|
|
|
--
|
|
|
|
|
2012-11-17 20:49:06 +00:00
|
|
|
function suite.setsArchitecture_onMatchingPlatform()
|
|
|
|
platforms { "x32", "x64" }
|
2012-06-11 23:11:21 +00:00
|
|
|
project ("MyProject")
|
2012-11-17 20:49:06 +00:00
|
|
|
prepare("Debug", "x32")
|
|
|
|
test.isequal("x32", cfg.architecture)
|
2012-05-23 20:34:28 +00:00
|
|
|
end
|
|
|
|
|
2012-06-11 23:11:21 +00:00
|
|
|
|
|
|
|
--
|
2012-11-17 20:49:06 +00:00
|
|
|
-- If the platform matches an architecture, it should not modify any
|
|
|
|
-- currently set value.
|
2012-06-11 23:11:21 +00:00
|
|
|
--
|
|
|
|
|
2012-11-17 20:49:06 +00:00
|
|
|
function suite.doesNotOverride_onMatchingPlatform()
|
|
|
|
platforms { "x32", "x64" }
|
2012-06-11 23:11:21 +00:00
|
|
|
project ("MyProject")
|
2012-11-17 20:49:06 +00:00
|
|
|
architecture "x64"
|
|
|
|
prepare("Debug", "x32")
|
|
|
|
test.isequal("x64", cfg.architecture)
|
2012-06-11 23:11:21 +00:00
|
|
|
end
|