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/base/test_baking.lua

187 lines
3.3 KiB
Lua
Raw Normal View History

--
-- tests/test_baking.lua
-- Automated test suite for the configuration baking functions.
-- Copyright (c) 2009, 2010 Jason Perkins and the Premake project
--
T.baking = { }
local suite = T.baking
2009-05-29 15:36:39 +00:00
--
-- Setup code
--
2009-05-08 20:18:47 +00:00
local prj, cfg
function suite.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.bake.buildconfigs()
2009-05-08 20:18:47 +00:00
prj = premake.getconfig(prj)
cfg = premake.getconfig(prj, "Debug")
end
--
-- Tests
--
function suite.SolutionFields()
2009-05-29 15:36:39 +00:00
prepare()
test.isequal("Debug:Release", table.concat(cfg.configurations,":"))
end
function suite.ProjectFields()
2009-05-29 15:36:39 +00:00
prepare()
test.isequal("C", cfg.language)
end
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,":"))
end
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,":"))
end
function suite.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 suite.SetsConfigName()
2009-05-29 15:36:39 +00:00
prepare()
local cfg = premake.getconfig(prj, "Debug", "x32")
test.isequal("Debug", cfg.name)
end
function suite.SetsPlatformName()
2009-05-29 15:36:39 +00:00
prepare()
local cfg = premake.getconfig(prj, "Debug", "x32")
test.isequal("x32", cfg.platform)
end
function suite.SetsPlatformNativeName()
2009-04-29 18:51:15 +00:00
test.isequal("Native", cfg.platform)
end
2009-04-29 18:51:15 +00:00
function suite.SetsShortName()
2009-05-29 15:36:39 +00:00
prepare()
local cfg = premake.getconfig(prj, "Debug", "x32")
test.isequal("debug32", cfg.shortname)
end
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-04-29 18:51:15 +00:00
function suite.SetsLongName()
2009-05-29 15:36:39 +00:00
prepare()
local cfg = premake.getconfig(prj, "Debug", "x32")
test.isequal("Debug|x32", cfg.longname)
end
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-04-29 18:51:15 +00:00
function suite.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 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
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
--
function suite.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 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
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