premake/tests/test_targets.lua

235 lines
7.0 KiB
Lua
Raw Normal View History

--
-- tests/test_targets.lua
-- Automated test suite for premake.gettarget()
-- Copyright (c) 2008, 2009 Jason Perkins and the Premake project
--
T.targets = { }
local cfg
function T.targets.setup()
cfg = { }
cfg.basedir = "."
cfg.location = "."
2009-05-08 20:18:47 +00:00
cfg.targetdir = "../bin"
cfg.language = "C++"
cfg.project = { name = "MyProject" }
2009-01-12 19:42:49 +00:00
cfg.flags = { }
2009-05-08 20:18:47 +00:00
cfg.objectsdir = "obj"
cfg.platform = "Native"
end
--
-- Path Style Name Style Example Environment
-- ---------- ---------- -------------------
-- windows windows VStudio with MSC
-- posix posix GMake with GCC
-- windows posix VStudio for PS3
-- posix windows GMake for .NET
--
--
-- ConsoleApp tests
--
function T.targets.ConsoleApp_Build_WindowsNames()
cfg.kind = "ConsoleApp"
result = premake.gettarget(cfg, "build", "posix", "windows", "macosx")
test.isequal([[../bin/MyProject.exe]], result.fullpath)
end
function T.targets.ConsoleApp_Build_PosixNames_OnWindows()
cfg.kind = "ConsoleApp"
result = premake.gettarget(cfg, "build", "posix", "posix", "windows")
test.isequal([[../bin/MyProject.exe]], result.fullpath)
end
function T.targets.ConsoleApp_Build_PosixNames_OnLinux()
cfg.kind = "ConsoleApp"
result = premake.gettarget(cfg, "build", "posix", "posix", "linux")
test.isequal([[../bin/MyProject]], result.fullpath)
end
function T.targets.ConsoleApp_Build_PosixNames_OnMacOSX()
cfg.kind = "ConsoleApp"
result = premake.gettarget(cfg, "build", "posix", "posix", "macosx")
test.isequal([[../bin/MyProject]], result.fullpath)
end
function T.targets.ConsoleApp_Build_PS3Names()
cfg.kind = "ConsoleApp"
result = premake.gettarget(cfg, "build", "posix", "PS3", "macosx")
test.isequal([[../bin/MyProject.elf]], result.fullpath)
end
--
-- WindowedApp tests
--
function T.targets.WindowedApp_Build_WindowsNames()
cfg.kind = "WindowedApp"
result = premake.gettarget(cfg, "build", "posix", "windows", "macosx")
test.isequal([[../bin/MyProject.exe]], result.fullpath)
end
function T.targets.WindowedApp_Build_PosixNames_OnWindows()
cfg.kind = "WindowedApp"
result = premake.gettarget(cfg, "build", "posix", "posix", "windows")
test.isequal([[../bin/MyProject.exe]], result.fullpath)
end
function T.targets.WindowedApp_Build_PosixNames_OnLinux()
cfg.kind = "WindowedApp"
result = premake.gettarget(cfg, "build", "posix", "posix", "linux")
test.isequal([[../bin/MyProject]], result.fullpath)
end
2009-05-08 20:18:47 +00:00
function T.targets.WindowedApp_Build_PosixNames_OnMacOSX()
cfg.kind = "WindowedApp"
result = premake.gettarget(cfg, "build", "posix", "posix", "macosx")
test.isequal([[../bin/MyProject.app/Contents/MacOS/MyProject]], result.fullpath)
end
function T.targets.WindowedApp_Build_PS3Names()
cfg.kind = "WindowedApp"
result = premake.gettarget(cfg, "build", "posix", "PS3", "macosx")
test.isequal([[../bin/MyProject.elf]], result.fullpath)
end
--
-- SharedLib tests
--
function T.targets.SharedLib_Build_WindowsNames()
cfg.kind = "SharedLib"
result = premake.gettarget(cfg, "build", "posix", "windows", "macosx")
test.isequal([[../bin/MyProject.dll]], result.fullpath)
end
function T.targets.SharedLib_Link_WindowsNames()
cfg.kind = "SharedLib"
result = premake.gettarget(cfg, "link", "posix", "windows", "macosx")
test.isequal([[../bin/MyProject.lib]], result.fullpath)
end
function T.targets.SharedLib_Build_PosixNames_OnWindows()
cfg.kind = "SharedLib"
result = premake.gettarget(cfg, "build", "posix", "posix", "windows")
test.isequal([[../bin/MyProject.dll]], result.fullpath)
end
2009-05-08 20:18:47 +00:00
function T.targets.SharedLib_Link_PosixNames_OnWindows()
cfg.kind = "SharedLib"
result = premake.gettarget(cfg, "link", "posix", "posix", "windows")
test.isequal([[../bin/libMyProject.a]], result.fullpath)
end
function T.targets.SharedLib_Build_PosixNames_OnLinux()
cfg.kind = "SharedLib"
result = premake.gettarget(cfg, "build", "posix", "posix", "linux")
test.isequal([[../bin/libMyProject.so]], result.fullpath)
end
function T.targets.SharedLib_Link_PosixNames_OnLinux()
cfg.kind = "SharedLib"
result = premake.gettarget(cfg, "link", "posix", "posix", "linux")
test.isequal([[../bin/libMyProject.so]], result.fullpath)
end
function T.targets.SharedLib_Build_PosixNames_OnMacOSX()
cfg.kind = "SharedLib"
result = premake.gettarget(cfg, "build", "posix", "posix", "macosx")
test.isequal([[../bin/libMyProject.dylib]], result.fullpath)
end
2009-05-08 20:18:47 +00:00
function T.targets.SharedLib_Link_PosixNames_OnMacOSX()
cfg.kind = "SharedLib"
result = premake.gettarget(cfg, "link", "posix", "posix", "macosx")
test.isequal([[../bin/libMyProject.dylib]], result.fullpath)
end
2009-05-08 20:18:47 +00:00
--
-- StaticLib tests
--
function T.targets.StaticLib_Build_WindowsNames()
cfg.kind = "StaticLib"
result = premake.gettarget(cfg, "build", "posix", "windows", "macosx")
test.isequal([[../bin/MyProject.lib]], result.fullpath)
end
function T.targets.StaticLib_Link_WindowsNames()
cfg.kind = "StaticLib"
result = premake.gettarget(cfg, "link", "posix", "windows", "macosx")
test.isequal([[../bin/MyProject.lib]], result.fullpath)
end
function T.targets.StaticLib_Build_PosixNames_OnWindows()
cfg.kind = "StaticLib"
result = premake.gettarget(cfg, "build", "posix", "posix", "windows")
2009-05-08 20:18:47 +00:00
test.isequal([[../bin/libMyProject.a]], result.fullpath)
end
function T.targets.StaticLib_Link_PosixNames_OnWindows()
2009-05-08 20:18:47 +00:00
cfg.kind = "StaticLib"
result = premake.gettarget(cfg, "link", "posix", "posix", "windows")
2009-05-08 20:18:47 +00:00
test.isequal([[../bin/libMyProject.a]], result.fullpath)
end
function T.targets.StaticLib_Build_PosixNames_OnLinux()
2009-05-08 20:18:47 +00:00
cfg.kind = "StaticLib"
result = premake.gettarget(cfg, "build", "posix", "posix", "linux")
2009-05-08 20:18:47 +00:00
test.isequal([[../bin/libMyProject.a]], result.fullpath)
end
function T.targets.StaticLib_Link_PosixNames_OnLinux()
2009-05-08 20:18:47 +00:00
cfg.kind = "StaticLib"
result = premake.gettarget(cfg, "link", "posix", "posix", "linux")
2009-05-08 20:18:47 +00:00
test.isequal([[../bin/libMyProject.a]], result.fullpath)
end
function T.targets.StaticLib_Build_PosixNames_OnMacOSX()
2009-05-08 20:18:47 +00:00
cfg.kind = "StaticLib"
result = premake.gettarget(cfg, "build", "posix", "posix", "macosx")
2009-05-08 20:18:47 +00:00
test.isequal([[../bin/libMyProject.a]], result.fullpath)
end
function T.targets.StaticLib_Link_PosixNames_OnMacOSX()
2009-05-08 20:18:47 +00:00
cfg.kind = "StaticLib"
result = premake.gettarget(cfg, "link", "posix", "posix", "macosx")
2009-05-08 20:18:47 +00:00
test.isequal([[../bin/libMyProject.a]], result.fullpath)
end
function T.targets.StaticLib_Build_PosixNames_OnPS3()
2009-05-08 20:18:47 +00:00
cfg.kind = "StaticLib"
result = premake.gettarget(cfg, "build", "posix", "PS3", "macosx")
2009-05-08 20:18:47 +00:00
test.isequal([[../bin/libMyProject.a]], result.fullpath)
end
function T.targets.StaticLib_Link_PosixNames_OnPS3()
2009-05-08 20:18:47 +00:00
cfg.kind = "StaticLib"
result = premake.gettarget(cfg, "link", "posix", "PS3", "macosx")
2009-05-08 20:18:47 +00:00
test.isequal([[../bin/libMyProject.a]], result.fullpath)
end
--
-- Windows path tests
--
function T.targets.WindowsPaths()
cfg.kind = "ConsoleApp"
result = premake.gettarget(cfg, "build", "windows", "windows", "linux")
test.isequal([[..\bin]], result.directory)
test.isequal([[..\bin\MyProject.exe]], result.fullpath)
end