premake/tests/test_configs.lua

186 lines
3.4 KiB
Lua
Raw Normal View History

--
-- tests/test_configs.lua
-- Automated test suite for the configuration building functions.
-- Copyright (c) 2009 Jason Perkins and the Premake project
--
T.configs = { }
2009-05-29 15:36:39 +00:00
--
-- Setup code
--
2009-05-08 20:18:47 +00:00
local prj, cfg
function T.configs.setup()
2009-05-08 20:18:47 +00:00
_ACTION = "gmake"
solution "MySolution"
configurations { "Debug", "Release" }
2009-05-01 19:50:45 +00:00
platforms { "x32", "ps3" }
defines "SOLUTION"
configuration "Debug"
defines "SOLUTION_DEBUG"
prj = project "MyProject"
language "C"
2009-05-01 19:50:45 +00:00
kind "SharedLib"
2009-05-08 20:18:47 +00:00
targetdir "../bin"
defines "PROJECT"
configuration "Debug"
defines "DEBUG"
configuration "Release"
defines "RELEASE"
2009-04-29 18:51:15 +00:00
configuration "native"
defines "NATIVE"
configuration "x32"
defines "X86_32"
configuration "x64"
defines "X86_64"
2009-05-29 15:36:39 +00:00
end
local function prepare()
premake.buildconfigs()
2009-05-08 20:18:47 +00:00
prj = premake.getconfig(prj)
cfg = premake.getconfig(prj, "Debug")
end
--
-- Tests
--
function T.configs.SolutionFields()
2009-05-29 15:36:39 +00:00
prepare()
test.isequal("Debug:Release", table.concat(cfg.configurations,":"))
end
function T.configs.ProjectFields()
2009-05-29 15:36:39 +00:00
prepare()
test.isequal("C", cfg.language)
end
function T.configs.ProjectWideSettings()
2009-05-29 15:36:39 +00:00
prepare()
2009-05-08 20:18:47 +00:00
test.isequal("SOLUTION:PROJECT:NATIVE", table.concat(prj.defines,":"))
end
function T.configs.BuildCfgSettings()
2009-05-29 15:36:39 +00:00
prepare()
2009-04-29 18:51:15 +00:00
test.isequal("SOLUTION:SOLUTION_DEBUG:PROJECT:DEBUG:NATIVE", table.concat(cfg.defines,":"))
end
function T.configs.PlatformSettings()
2009-05-29 15:36:39 +00:00
prepare()
local cfg = premake.getconfig(prj, "Debug", "x32")
test.isequal("SOLUTION:SOLUTION_DEBUG:PROJECT:DEBUG:X86_32", table.concat(cfg.defines,":"))
end
function T.configs.SetsConfigName()
2009-05-29 15:36:39 +00:00
prepare()
local cfg = premake.getconfig(prj, "Debug", "x32")
test.isequal("Debug", cfg.name)
end
function T.configs.SetsPlatformName()
2009-05-29 15:36:39 +00:00
prepare()
local cfg = premake.getconfig(prj, "Debug", "x32")
test.isequal("x32", cfg.platform)
end
2009-04-29 18:51:15 +00:00
function T.configs.SetsPlatformNativeName()
test.isequal("Native", cfg.platform)
end
2009-04-29 18:51:15 +00:00
function T.configs.SetsShortName()
2009-05-29 15:36:39 +00:00
prepare()
local cfg = premake.getconfig(prj, "Debug", "x32")
test.isequal("debug32", cfg.shortname)
end
2009-04-29 18:51:15 +00:00
function T.configs.SetsNativeShortName()
2009-05-29 15:36:39 +00:00
prepare()
2009-04-29 18:51:15 +00:00
test.isequal("debug", cfg.shortname)
end
2009-04-29 18:51:15 +00:00
function T.configs.SetsLongName()
2009-05-29 15:36:39 +00:00
prepare()
local cfg = premake.getconfig(prj, "Debug", "x32")
test.isequal("Debug|x32", cfg.longname)
end
2009-04-29 18:51:15 +00:00
function T.configs.SetsNativeLongName()
2009-05-29 15:36:39 +00:00
prepare()
2009-04-29 18:51:15 +00:00
test.isequal("Debug", cfg.longname)
end
2009-04-29 18:51:15 +00:00
function T.configs.SetsProject()
2009-05-29 15:36:39 +00:00
prepare()
local cfg = premake.getconfig(prj, "Debug", "x32")
2009-05-08 20:18:47 +00:00
test.istrue(prj.project == cfg.project)
end
2009-05-01 19:50:45 +00:00
2009-05-08 20:18:47 +00:00
2009-05-01 19:50:45 +00:00
--
-- Target system testing
--
function T.configs.SetsTargetSystem_OnNative()
2009-05-29 15:36:39 +00:00
prepare()
2009-05-01 19:50:45 +00:00
test.isequal(os.get(), cfg.system)
end
function T.configs.SetTargetSystem_OnCrossCompiler()
2009-05-29 15:36:39 +00:00
prepare()
2009-05-01 19:50:45 +00:00
local cfg = premake.getconfig(prj, "Debug", "PS3")
test.isequal("PS3", cfg.system)
end
2009-05-08 20:18:47 +00:00
2009-05-01 19:50:45 +00:00
2009-05-29 15:36:39 +00:00
--
-- Configuration-specific kinds
--
function T.configs.SetsConfigSpecificKind()
configuration "Debug"
kind "ConsoleApp"
prepare()
test.isequal("ConsoleApp", cfg.kind)
end
2009-05-29 15:36:39 +00:00
2009-05-01 19:50:45 +00:00
--
-- Platform kind translation
--
function T.configs.SetsTargetKind_OnSupportedKind()
2009-05-29 15:36:39 +00:00
prepare()
2009-05-01 19:50:45 +00:00
test.isequal("SharedLib", cfg.kind)
end
function T.configs.SetsTargetKind_OnUnsupportedKind()
2009-05-29 15:36:39 +00:00
prepare()
2009-05-01 19:50:45 +00:00
local cfg = premake.getconfig(prj, "Debug", "PS3")
test.isequal("StaticLib", cfg.kind)
end