2012-01-22 17:19:43 +00:00
|
|
|
--
|
|
|
|
-- tests/project/test_getconfig.lua
|
|
|
|
-- Test the project object configuration accessor.
|
2014-04-25 15:53:01 +00:00
|
|
|
-- Copyright (c) 2011-2014 Jason Perkins and the Premake project
|
2012-01-22 17:19:43 +00:00
|
|
|
--
|
|
|
|
|
2017-08-01 16:46:12 +00:00
|
|
|
local p = premake
|
2013-11-14 13:52:55 +00:00
|
|
|
local suite = test.declare("project_getconfig")
|
2012-01-22 17:19:43 +00:00
|
|
|
|
|
|
|
--
|
|
|
|
-- Setup and teardown
|
|
|
|
--
|
|
|
|
|
2015-08-28 20:16:14 +00:00
|
|
|
local wks, prj, cfg
|
2012-01-22 17:19:43 +00:00
|
|
|
|
|
|
|
function suite.setup()
|
2015-08-30 15:38:35 +00:00
|
|
|
wks = workspace("MyWorkspace")
|
2012-06-11 23:11:21 +00:00
|
|
|
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)
|
2015-08-28 20:16:14 +00:00
|
|
|
prj = wks.projects[1]
|
2013-11-14 13:52:55 +00:00
|
|
|
cfg = test.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()
|
2017-04-11 20:39:25 +00:00
|
|
|
_TARGET_OS = "linux"
|
2012-06-11 23:11:21 +00:00
|
|
|
project ("MyProject")
|
2014-04-25 15:53:01 +00:00
|
|
|
filter { "system:linux" }
|
2012-01-22 17:19:43 +00:00
|
|
|
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()
|
2017-04-11 20:39:25 +00:00
|
|
|
_TARGET_OS = "linux"
|
2017-08-01 16:46:12 +00:00
|
|
|
p.action.set("vs2005")
|
2012-06-11 23:11:21 +00:00
|
|
|
project ("MyProject")
|
2014-04-25 15:53:01 +00:00
|
|
|
filter { "system:windows" }
|
2012-01-22 17:19:43 +00:00
|
|
|
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()
|
2017-04-11 20:39:25 +00:00
|
|
|
_TARGET_OS = "linux"
|
2017-08-01 16:46:12 +00:00
|
|
|
p.action.set("vs2005")
|
2012-06-11 23:11:21 +00:00
|
|
|
project ("MyProject")
|
2012-01-22 17:19:43 +00:00
|
|
|
system "macosx"
|
2014-04-25 15:53:01 +00:00
|
|
|
filter { "system:macosx" }
|
2012-01-22 17:19:43 +00:00
|
|
|
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()
|
2017-08-01 16:46:12 +00:00
|
|
|
p.action.set("vs2005")
|
2012-06-11 23:11:21 +00:00
|
|
|
project ("MyProject")
|
2014-04-25 15:53:01 +00:00
|
|
|
filter { "action:vs2005" }
|
2012-01-22 17:19:43 +00:00
|
|
|
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()
|
2015-04-13 22:27:11 +00:00
|
|
|
platforms { "x86", "x86_64" }
|
2012-06-11 23:11:21 +00:00
|
|
|
project ("MyProject")
|
2015-04-10 13:02:19 +00:00
|
|
|
prepare("Debug", "x86")
|
|
|
|
test.isequal("x86", 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()
|
2015-04-10 13:02:19 +00:00
|
|
|
platforms { "x86", "x64" }
|
2012-06-11 23:11:21 +00:00
|
|
|
project ("MyProject")
|
2015-04-10 13:02:19 +00:00
|
|
|
architecture "x86_64"
|
|
|
|
prepare("Debug", "x86")
|
|
|
|
test.isequal("x86_64", cfg.architecture)
|
2012-06-11 23:11:21 +00:00
|
|
|
end
|