This repository has been archived on 2022-12-23. You can view files and clone it, but cannot push or open issues or pull requests.
fuck-premake-old2/tests/project/test_config_maps.lua

166 lines
3.9 KiB
Lua

--
-- tests/project/test_config_maps.lua
-- Test mapping from solution to project configurations.
-- Copyright (c) 2012-2014 Jason Perkins and the Premake project
--
local suite = test.declare("project_config_maps")
--
-- Setup and teardown
--
local sln, prj, cfg
function suite.setup()
sln = solution("MySolution")
configurations { "Debug", "Release" }
end
local function prepare(buildcfg, platform)
prj = sln.projects[1]
cfg = test.getconfig(prj, buildcfg or "Debug", platform)
end
--
-- When no configuration is specified in the project, the solution
-- settings should map directly to a configuration object.
--
function suite.solutionConfig_onNoProjectConfigs()
project ("MyProject")
prepare()
test.isequal("Debug", cfg.buildcfg)
end
--
-- If a project configuration mapping exists, it should be taken into
-- account when fetching the configuration object.
--
function suite.appliesCfgMapping_onBuildCfgMap()
project ("MyProject")
configmap { ["Debug"] = "Development" }
prepare()
test.isequal("Development", cfg.buildcfg)
end
function suite.appliesCfgMapping_onPlatformMap()
platforms { "Shared", "Static" }
project ("MyProject")
configmap { ["Shared"] = "DLL" }
prepare("Debug", "Shared")
test.isequal("DLL", cfg.platform)
end
--
-- If a configuration mapping exists, can also use the mapped value
-- to fetch the configuration.
--
function suite.fetchesMappedCfg_onBuildCfgMap()
project ("MyProject")
configmap { ["Debug"] = "Development" }
prepare("Development")
test.isequal("Development", cfg.buildcfg)
end
function suite.fetchesMappedCfg_onPlatformMap()
platforms { "Shared", "Static" }
project ("MyProject")
configmap { ["Shared"] = "DLL" }
prepare("Debug", "DLL")
test.isequal("DLL", cfg.platform)
end
--
-- If the specified configuration has been removed from the project,
-- then nil should be returned.
--
function suite.returnsNil_onRemovedBuildCfg()
project ("MyProject")
removeconfigurations { "Debug" }
prepare()
test.isnil(cfg)
end
function suite.returnsNil_onRemovedPlatform()
platforms { "Shared", "Static" }
project ("MyProject")
removeplatforms { "Shared" }
prepare("Debug", "Shared")
test.isnil(cfg)
end
--
-- Check mapping from a buildcfg-platform tuple to a simple single
-- value platform configuration.
--
function suite.canMap_tupleToSingle()
platforms { "Win32", "Linux" }
project ("MyProject")
removeconfigurations "*"
removeplatforms "*"
configurations { "Debug Win32", "Release Win32", "Debug Linux", "Release Linux" }
configmap {
[{"Debug", "Win32"}] = "Debug Win32",
[{"Debug", "Linux"}] = "Debug Linux",
[{"Release", "Win32"}] = "Release Win32",
[{"Release", "Linux"}] = "Release Linux"
}
prepare("Debug", "Linux")
test.isequal("Debug Linux", cfg.buildcfg)
end
--
-- Check mapping from a buildcfg-platform tuple to new project
-- configuration tuple.
--
function suite.canMap_tupleToTuple()
platforms { "Win32", "Linux" }
project ("MyProject")
removeconfigurations "*"
removeplatforms "*"
configurations { "Development", "Production" }
platforms { "x32", "x64" }
configmap {
[{"Debug", "Win32"}] = { "Development", "x32" },
[{"Debug", "Linux"}] = { "Development", "x64" },
[{"Release", "Win32"}] = { "Production", "x32" },
[{"Release", "Linux"}] = { "Production", "x64" },
}
prepare("Debug", "Linux")
test.isequal({ "Development", "x64" }, { cfg.buildcfg, cfg.platform })
end
--
-- To allow some measure of global configuration, config maps that are contained
-- in configuration blocks are allowed to bubble up to the project level.
--
function suite.canBubbleUp_onConfiguration()
platforms { "XCUA", "XCUB" }
filter { "platforms:CCU" }
configmap { XCUA = "CCU", XCUB = "CCU" }
project "MyProject"
platforms { "CCU" }
prepare("Debug", "XCUA")
test.isequal({"Debug", "CCU"}, {cfg.buildcfg, cfg.platform})
end