2009-04-09 20:02:49 +00:00
|
|
|
--
|
2010-09-05 20:10:28 +00:00
|
|
|
-- tests/test_baking.lua
|
|
|
|
-- Automated test suite for the configuration baking functions.
|
|
|
|
-- Copyright (c) 2009, 2010 Jason Perkins and the Premake project
|
2009-04-09 20:02:49 +00:00
|
|
|
--
|
|
|
|
|
2010-09-05 20:10:28 +00:00
|
|
|
T.baking = { }
|
|
|
|
local suite = T.baking
|
2009-04-09 20:02:49 +00:00
|
|
|
|
2009-05-29 15:36:39 +00:00
|
|
|
--
|
|
|
|
-- Setup code
|
|
|
|
--
|
|
|
|
|
2009-05-08 20:18:47 +00:00
|
|
|
local prj, cfg
|
2010-09-05 20:10:28 +00:00
|
|
|
function suite.setup()
|
2009-05-08 20:18:47 +00:00
|
|
|
_ACTION = "gmake"
|
|
|
|
|
2009-04-09 20:02:49 +00:00
|
|
|
solution "MySolution"
|
|
|
|
configurations { "Debug", "Release" }
|
2012-01-03 22:08:22 +00:00
|
|
|
platforms { "x32", "PS3" }
|
2009-04-09 20:02:49 +00:00
|
|
|
|
2009-04-28 00:19:44 +00:00
|
|
|
defines "SOLUTION"
|
|
|
|
|
|
|
|
configuration "Debug"
|
|
|
|
defines "SOLUTION_DEBUG"
|
|
|
|
|
2009-04-09 20:02:49 +00:00
|
|
|
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"
|
2009-04-28 00:19:44 +00:00
|
|
|
defines "PROJECT"
|
2009-04-09 20:02:49 +00:00
|
|
|
|
|
|
|
configuration "Debug"
|
|
|
|
defines "DEBUG"
|
|
|
|
|
|
|
|
configuration "Release"
|
|
|
|
defines "RELEASE"
|
|
|
|
|
2009-04-29 18:51:15 +00:00
|
|
|
configuration "native"
|
|
|
|
defines "NATIVE"
|
|
|
|
|
2009-04-09 20:02:49 +00:00
|
|
|
configuration "x32"
|
|
|
|
defines "X86_32"
|
|
|
|
|
|
|
|
configuration "x64"
|
|
|
|
defines "X86_64"
|
2009-05-29 15:36:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
local function prepare()
|
2011-05-18 21:32:04 +00:00
|
|
|
premake.bake.buildconfigs()
|
2009-05-08 20:18:47 +00:00
|
|
|
prj = premake.getconfig(prj)
|
|
|
|
cfg = premake.getconfig(prj, "Debug")
|
2009-04-09 20:02:49 +00:00
|
|
|
end
|
|
|
|
|
2009-04-28 00:19:44 +00:00
|
|
|
|
2009-07-15 14:38:28 +00:00
|
|
|
--
|
|
|
|
-- Tests
|
|
|
|
--
|
|
|
|
|
2010-09-05 20:10:28 +00:00
|
|
|
function suite.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,":"))
|
2009-04-28 00:19:44 +00:00
|
|
|
end
|
2009-07-15 14:38:28 +00:00
|
|
|
|
2009-04-28 00:19:44 +00:00
|
|
|
|
2010-09-05 20:10:28 +00:00
|
|
|
function suite.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,":"))
|
2009-04-09 20:02:49 +00:00
|
|
|
end
|
|
|
|
|
2009-07-15 14:38:28 +00:00
|
|
|
|
2010-09-05 20:10:28 +00:00
|
|
|
function suite.PlatformSettings()
|
2009-05-29 15:36:39 +00:00
|
|
|
prepare()
|
2009-04-28 00:19:44 +00:00
|
|
|
local cfg = premake.getconfig(prj, "Debug", "x32")
|
|
|
|
test.isequal("SOLUTION:SOLUTION_DEBUG:PROJECT:DEBUG:X86_32", table.concat(cfg.defines,":"))
|
2009-04-09 20:02:49 +00:00
|
|
|
end
|
2009-07-15 14:38:28 +00:00
|
|
|
|
2009-04-28 00:19:44 +00:00
|
|
|
|
2010-09-05 20:10:28 +00:00
|
|
|
function suite.SetsConfigName()
|
2009-05-29 15:36:39 +00:00
|
|
|
prepare()
|
2009-04-28 00:19:44 +00:00
|
|
|
local cfg = premake.getconfig(prj, "Debug", "x32")
|
|
|
|
test.isequal("Debug", cfg.name)
|
|
|
|
end
|
2009-07-15 14:38:28 +00:00
|
|
|
|
2009-04-28 00:19:44 +00:00
|
|
|
|
2010-09-05 20:10:28 +00:00
|
|
|
function suite.SetsPlatformName()
|
2009-05-29 15:36:39 +00:00
|
|
|
prepare()
|
2009-04-28 00:19:44 +00:00
|
|
|
local cfg = premake.getconfig(prj, "Debug", "x32")
|
|
|
|
test.isequal("x32", cfg.platform)
|
|
|
|
end
|
2009-07-15 14:38:28 +00:00
|
|
|
|
2009-04-28 00:19:44 +00:00
|
|
|
|
2010-09-05 20:10:28 +00:00
|
|
|
function suite.SetsPlatformNativeName()
|
2009-04-29 18:51:15 +00:00
|
|
|
test.isequal("Native", cfg.platform)
|
|
|
|
end
|
2009-07-15 14:38:28 +00:00
|
|
|
|
2009-04-29 18:51:15 +00:00
|
|
|
|
2010-09-05 20:10:28 +00:00
|
|
|
function suite.SetsShortName()
|
2009-05-29 15:36:39 +00:00
|
|
|
prepare()
|
2009-04-28 00:19:44 +00:00
|
|
|
local cfg = premake.getconfig(prj, "Debug", "x32")
|
|
|
|
test.isequal("debug32", cfg.shortname)
|
|
|
|
end
|
2009-07-15 14:38:28 +00:00
|
|
|
|
2009-04-28 00:19:44 +00:00
|
|
|
|
2010-09-05 20:10:28 +00:00
|
|
|
function suite.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-07-15 14:38:28 +00:00
|
|
|
|
2009-04-29 18:51:15 +00:00
|
|
|
|
2010-09-05 20:10:28 +00:00
|
|
|
function suite.SetsLongName()
|
2009-05-29 15:36:39 +00:00
|
|
|
prepare()
|
2009-04-28 00:19:44 +00:00
|
|
|
local cfg = premake.getconfig(prj, "Debug", "x32")
|
|
|
|
test.isequal("Debug|x32", cfg.longname)
|
|
|
|
end
|
2009-07-15 14:38:28 +00:00
|
|
|
|
2009-04-28 00:19:44 +00:00
|
|
|
|
2010-09-05 20:10:28 +00:00
|
|
|
function suite.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-07-15 14:38:28 +00:00
|
|
|
|
2009-04-29 18:51:15 +00:00
|
|
|
|
2010-09-05 20:10:28 +00:00
|
|
|
function suite.SetsProject()
|
2009-05-29 15:36:39 +00:00
|
|
|
prepare()
|
2009-04-28 00:19:44 +00:00
|
|
|
local cfg = premake.getconfig(prj, "Debug", "x32")
|
2009-05-08 20:18:47 +00:00
|
|
|
test.istrue(prj.project == cfg.project)
|
2009-04-28 00:19:44 +00:00
|
|
|
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
|
|
|
|
--
|
|
|
|
|
2010-09-05 20:10:28 +00:00
|
|
|
function suite.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
|
|
|
|
|
2010-09-05 20:10:28 +00:00
|
|
|
function suite.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
|
|
|
|
--
|
|
|
|
|
2010-09-05 20:10:28 +00:00
|
|
|
function suite.SetsConfigSpecificKind()
|
2009-05-29 15:41:32 +00:00
|
|
|
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
|
|
|
|
--
|
|
|
|
|
2010-09-05 20:10:28 +00:00
|
|
|
function suite.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
|
|
|
|
|
2010-09-05 20:10:28 +00:00
|
|
|
function suite.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
|