premake/tests/tools/test_snc.lua

142 lines
2.7 KiB
Lua

--
-- tests/test_snc.lua
-- Automated test suite for the SNC toolset interface.
-- Copyright (c) 2012 Jason Perkins and the Premake project
--
T.tools_snc = {}
local suite = T.tools_snc
local snc = premake.tools.snc
--
-- Setup/teardown
--
local sln, prj, cfg
function suite.setup()
sln, prj = test.createsolution()
system "PS3"
end
local function prepare()
cfg = premake5.project.getconfig(prj, "Debug")
end
--
-- Check the selection of tools based on the target system.
--
function suite.tools_onDefaults()
prepare()
test.isnil(snc.gettoolname(cfg, "cc"))
test.isnil(snc.gettoolname(cfg, "cxx"))
test.isnil(snc.gettoolname(cfg, "ar"))
end
function suite.tools_onPS3()
system "PS3"
prepare()
test.isnil(snc.gettoolname(cfg, "cc"))
test.isnil(snc.gettoolname(cfg, "cxx"))
test.isnil(snc.gettoolname(cfg, "ar"))
end
--
-- By default, the -MMD -MP are used to generate dependencies.
--
function suite.cppflags_defaultWithMMD()
prepare()
test.isequal({ "-MMD", "-MP" }, snc.getcppflags(cfg))
end
--
-- Check the translation of CFLAGS.
--
function suite.cflags_onFatalWarnings()
flags { "FatalWarnings" }
prepare()
test.isequal({ "-Xquit=2" }, snc.getcflags(cfg))
end
--
-- Turn on exceptions and RTTI by default, to match the other Premake supported toolsets.
--
function suite.cxxflags_onDefault()
prepare()
test.isequal({ "-Xc+=exceptions", "-Xc+=rtti" }, snc.getcxxflags(cfg))
end
--
-- Check the translation of LDFLAGS.
--
function suite.cflags_onDefaults()
prepare()
test.isequal({ "-s" }, snc.getldflags(cfg))
end
--
-- Check the formatting of linked libraries.
--
function suite.links_onSystemLibs()
links { "fs_stub", "net_stub" }
prepare()
test.isequal({ "-lfs_stub", "-lnet_stub" }, snc.getlinks(cfg))
end
--
-- When linking to a static sibling library, the relative path to the library
-- should be used instead of the "-l" flag. This prevents linking against a
-- shared library of the same name, should one be present.
--
function suite.links_onStaticSiblingLibrary()
links { "MyProject2" }
test.createproject(sln)
system "Linux"
kind "StaticLib"
location "MyProject2"
targetdir "lib"
prepare()
test.isequal({ "lib/libMyProject2.a" }, snc.getlinks(cfg))
end
--
-- When linking object files, leave off the "-l".
--
function suite.links_onObjectFile()
links { "generated.o" }
prepare()
test.isequal({ "generated.o" }, snc.getlinks(cfg))
end
--
-- Check handling of forced includes.
--
function suite.forcedIncludeFiles()
forceincludes { "stdafx.h", "include/sys.h" }
prepare()
test.isequal({"-MMD", "-MP", '-include "stdafx.h"', '-include "include/sys.h"'}, snc.getcppflags(cfg))
end