--
-- tests/test_vs200x_vcproj.lua
-- Automated test suite for Visual Studio 2002-2008 C/C++ project generation.
-- Copyright (c) 2009 Jason Perkins and the Premake project
--
T.vs200x_vcproj = { }
local suite = T.vs200x_vcproj
local vcproj = premake.vstudio.vcproj
--
-- Configure a solution for testing
--
local sln, prj
function suite.setup()
_ACTION = "vs2005"
sln = solution "MySolution"
configurations { "Debug", "Release" }
platforms {}
project "DotNetProject" -- to test handling of .NET platform in solution
language "C#"
kind "ConsoleApp"
prj = project "MyProject"
language "C++"
kind "ConsoleApp"
uuid "AE61726D-187C-E440-BD07-2556188A6565"
end
local function prepare()
io.capture()
premake.buildconfigs()
sln.vstudio_configs = premake.vstudio_buildconfigs(sln)
local cfg = premake.getconfig(sln.projects[2])
cfg.name = prj.name
cfg.blocks = prj.blocks
prj = cfg
end
--
-- Make sure I've got the basic layout correct
--
function suite.BasicLayout()
prepare()
premake.vs200x_vcproj(prj)
test.capture [[
]]
end
--
-- Test the element
--
function suite.Configuration_OnMFCFlag()
flags { "MFC" }
prepare()
vcproj.Configuration("Debug|Win32", premake.getconfig(prj, "Debug"))
test.capture [[
]]
end
--
-- Test multiple platforms
--
function suite.Platforms_OnMultiplePlatforms()
platforms { "x32", "x64" }
prepare()
premake.vs200x_vcproj(prj)
local result = io.endcapture()
test.istrue(result:find '
]]
end
--
-- Test Xbox360 handling
--
function suite.PlatformsList_OnXbox360()
platforms { "Native", "Xbox360" }
prepare()
premake.vs200x_vcproj_platforms(prj)
test.capture [[
]]
end
function suite.CompilerBlock_OnXbox360()
platforms { "Xbox360" }
prepare()
premake.vs200x_vcproj_VCCLCompilerTool(premake.getconfig(prj, "Debug", "Xbox360"))
test.capture [[
]]
end
--
-- Test PS3 handling
--
function suite.PlatformsList_OnPS3()
platforms { "Native", "PS3" }
prepare()
premake.vs200x_vcproj_platforms(prj)
test.capture [[
]]
end
function suite.CompilerBlock_OnPS3()
platforms { "PS3" }
flags { "Symbols" }
includedirs { "include/pkg1", "include/pkg2" }
defines { "DEFINE1", "DEFINE2" }
prepare()
premake.vs200x_vcproj_VCCLCompilerTool_PS3(premake.getconfig(prj, "Debug", "PS3"))
test.capture [[
]]
end
function suite.LinkerBlock_OnPS3ConsoleApp()
platforms { "PS3" }
prepare()
premake.vs200x_vcproj_VCLinkerTool_PS3(premake.getconfig(prj, "Debug", "PS3"))
test.capture [[
]]
end
function suite.LinkerBlock_OnPS3StaticLib()
platforms { "PS3" }
kind "StaticLib"
prepare()
premake.vs200x_vcproj_VCLinkerTool_PS3(premake.getconfig(prj, "Debug", "PS3"))
test.capture [[
]]
end
function suite.LinkerBlock_OnPS3SharedLink()
platforms { "PS3" }
links { "MyLibrary" }
project "MyLibrary"
language "C++"
kind "SharedLib"
prepare()
premake.vs200x_vcproj_VCLinkerTool_PS3(premake.getconfig(prj, "Debug", "PS3"))
test.capture [[
]]
end
--
-- Test manifest file handling.
--
function suite.VCManifestTool_OnNoManifests()
files { "hello.c", "goodbye.c" }
prepare()
premake.vs200x_vcproj_VCManifestTool(premake.getconfig(prj, "Debug"))
test.capture [[
]]
end
function suite.VCManifestTool_OnNoManifests()
files { "hello.c", "project1.manifest", "goodbye.c", "project2.manifest" }
prepare()
premake.vs200x_vcproj_VCManifestTool(premake.getconfig(prj, "Debug"))
test.capture [[
]]
end
--
-- Test precompiled header handling
--
function suite.CompilerBlock_OnPCH()
pchheader "source/common.h"
pchsource "source/common.cpp"
prepare()
premake.vs200x_vcproj_VCCLCompilerTool(premake.getconfig(prj, "Debug"))
test.capture [[
]]
end
function suite.Files_OnPCH_OnWindows()
files { "afxwin.cpp" }
pchsource "afxwin.cpp"
prepare()
_VS.files(prj, "afxwin.cpp", "Item", 1)
test.capture [[
]]
end
function suite.Files_OnPCH_OnXbox360()
files { "afxwin.cpp" }
pchsource "afxwin.cpp"
platforms { "Xbox360" }
prepare()
sln.vstudio_configs = premake.vstudio_buildconfigs(sln)
_VS.files(prj, "afxwin.cpp", "Item", 1)
test.capture [[
]]
end
--
-- Floating point flag tests
--
function suite.CompilerBlock_OnFpFast()
flags { "FloatFast" }
prepare()
premake.vs200x_vcproj_VCCLCompilerTool(premake.getconfig(prj, "Debug"))
test.capture [[
]]
end
function suite.CompilerBlock_OnFpStrict()
flags { "FloatStrict" }
prepare()
premake.vs200x_vcproj_VCCLCompilerTool(premake.getconfig(prj, "Debug"))
test.capture [[
]]
end
--
-- PDB file naming tests
--
function suite.CompilerBlock_OnTargetName()
targetname "foob"
prepare()
premake.vs200x_vcproj_VCCLCompilerTool(premake.getconfig(prj, "Debug"))
test.capture [[
]]
end
--
-- Compilation option tests
--
function suite.CompilerBlock_OnNoMinimalRebuild()
flags { "Symbols", "NoMinimalRebuild" }
prepare()
premake.vs200x_vcproj_VCCLCompilerTool(premake.getconfig(prj, "Debug"))
test.capture [[
]]
end
--
-- RuntimeLibrary tests
--
function suite.CompilerBlock_RuntimeLibrary_IsDebug_OnSymbolsNoOptimize()
flags { "Symbols" }
prepare()
premake.vs200x_vcproj_VCCLCompilerTool(premake.getconfig(prj, "Debug"))
test.capture [[
]]
end
function suite.CompilerBlock_RuntimeLibrary_IsRelease_OnOptimize()
flags { "Symbols", "Optimize" }
prepare()
premake.vs200x_vcproj_VCCLCompilerTool(premake.getconfig(prj, "Debug"))
test.capture [[
]]
end
--
-- C language support
--
function suite.CompilerBlock_RuntimeLibrary_IsDebug_OnSymbolsNoOptimize()
language "C"
flags { "Symbols" }
prepare()
premake.vs200x_vcproj_VCCLCompilerTool(premake.getconfig(prj, "Debug"))
test.capture [[
]]
end
function suite.noLinkIncrementalFlag_valueEqualsOne()
flags { "NoIncrementalLink" }
prepare()
premake.vs200x_vcproj_VCLinkerTool(premake.getconfig(prj, "Debug"))
local result = io.endcapture()
test.string_contains(result,'LinkIncremental="1"')
end