Initial community commit
This commit is contained in:
parent
537bcbc862
commit
fc06254474
16440 changed files with 4239995 additions and 2 deletions
73
Src/external_dependencies/openmpt-trunk/include/genie/tests/base/test_action.lua
vendored
Normal file
73
Src/external_dependencies/openmpt-trunk/include/genie/tests/base/test_action.lua
vendored
Normal file
|
@ -0,0 +1,73 @@
|
|||
--
|
||||
-- tests/base/test_action.lua
|
||||
-- Automated test suite for the action list.
|
||||
-- Copyright (c) 2009 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
T.action = { }
|
||||
|
||||
|
||||
--
|
||||
-- Setup/teardown
|
||||
--
|
||||
|
||||
local fake = {
|
||||
trigger = "fake",
|
||||
description = "Fake action used for testing",
|
||||
}
|
||||
|
||||
function T.action.setup()
|
||||
premake.action.list["fake"] = fake
|
||||
solution "MySolution"
|
||||
configurations "Debug"
|
||||
project "MyProject"
|
||||
premake.bake.buildconfigs()
|
||||
end
|
||||
|
||||
function T.action.teardown()
|
||||
premake.action.list["fake"] = nil
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Tests for call()
|
||||
--
|
||||
|
||||
function T.action.CallCallsExecuteIfPresent()
|
||||
local called = false
|
||||
fake.execute = function () called = true end
|
||||
premake.action.call("fake")
|
||||
test.istrue(called)
|
||||
end
|
||||
|
||||
function T.action.CallCallsOnSolutionIfPresent()
|
||||
local called = false
|
||||
fake.onsolution = function () called = true end
|
||||
premake.action.call("fake")
|
||||
test.istrue(called)
|
||||
end
|
||||
|
||||
function T.action.CallCallsOnProjectIfPresent()
|
||||
local called = false
|
||||
fake.onproject = function () called = true end
|
||||
premake.action.call("fake")
|
||||
test.istrue(called)
|
||||
end
|
||||
|
||||
function T.action.CallSkipsCallbacksIfNotPresent()
|
||||
test.success(premake.action.call, "fake")
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Tests for set()
|
||||
--
|
||||
|
||||
function T.action.set_SetsActionOS()
|
||||
local oldos = _OS
|
||||
_OS = "linux"
|
||||
premake.action.set("vs2008")
|
||||
test.isequal(_OS, "windows")
|
||||
_OS = oldos
|
||||
end
|
404
Src/external_dependencies/openmpt-trunk/include/genie/tests/base/test_api.lua
vendored
Normal file
404
Src/external_dependencies/openmpt-trunk/include/genie/tests/base/test_api.lua
vendored
Normal file
|
@ -0,0 +1,404 @@
|
|||
--
|
||||
-- tests/base/test_api.lua
|
||||
-- Automated test suite for the project API support functions.
|
||||
-- Copyright (c) 2008-2011 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
T.api = { }
|
||||
local suite = T.api
|
||||
|
||||
local sln
|
||||
function suite.setup()
|
||||
sln = solution "MySolution"
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- premake.getobject() tests
|
||||
--
|
||||
|
||||
function suite.getobject_RaisesError_OnNoContainer()
|
||||
premake.CurrentContainer = nil
|
||||
c, err = premake.getobject("container")
|
||||
test.istrue(c == nil)
|
||||
test.isequal("no active solution or project", err)
|
||||
end
|
||||
|
||||
function suite.getobject_RaisesError_OnNoActiveSolution()
|
||||
premake.CurrentContainer = { }
|
||||
c, err = premake.getobject("solution")
|
||||
test.istrue(c == nil)
|
||||
test.isequal("no active solution", err)
|
||||
end
|
||||
|
||||
function suite.getobject_RaisesError_OnNoActiveConfig()
|
||||
premake.CurrentConfiguration = nil
|
||||
c, err = premake.getobject("config")
|
||||
test.istrue(c == nil)
|
||||
test.isequal("no active solution, project, or configuration", err)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- premake.setarray() tests
|
||||
--
|
||||
|
||||
function suite.setarray_Inserts_OnStringValue()
|
||||
premake.CurrentConfiguration = { }
|
||||
premake.CurrentConfiguration.myfield = { }
|
||||
premake.setarray("config", "myfield", "hello")
|
||||
test.isequal("hello", premake.CurrentConfiguration.myfield[1])
|
||||
end
|
||||
|
||||
function suite.setarray_Inserts_OnTableValue()
|
||||
premake.CurrentConfiguration = { }
|
||||
premake.CurrentConfiguration.myfield = { }
|
||||
premake.setarray("config", "myfield", { "hello", "goodbye" })
|
||||
test.isequal("hello", premake.CurrentConfiguration.myfield[1])
|
||||
test.isequal("goodbye", premake.CurrentConfiguration.myfield[2])
|
||||
end
|
||||
|
||||
function suite.setarray_Appends_OnNewValues()
|
||||
premake.CurrentConfiguration = { }
|
||||
premake.CurrentConfiguration.myfield = { "hello" }
|
||||
premake.setarray("config", "myfield", "goodbye")
|
||||
test.isequal("hello", premake.CurrentConfiguration.myfield[1])
|
||||
test.isequal("goodbye", premake.CurrentConfiguration.myfield[2])
|
||||
end
|
||||
|
||||
function suite.setarray_FlattensTables()
|
||||
premake.CurrentConfiguration = { }
|
||||
premake.CurrentConfiguration.myfield = { }
|
||||
premake.setarray("config", "myfield", { {"hello"}, {"goodbye"} })
|
||||
test.isequal("hello", premake.CurrentConfiguration.myfield[1])
|
||||
test.isequal("goodbye", premake.CurrentConfiguration.myfield[2])
|
||||
end
|
||||
|
||||
function suite.setarray_RaisesError_OnInvalidValue()
|
||||
premake.CurrentConfiguration = { }
|
||||
premake.CurrentConfiguration.myfield = { }
|
||||
ok, err = pcall(function () premake.setarray("config", "myfield", "bad", { "Good", "Better", "Best" }) end)
|
||||
test.isfalse(ok)
|
||||
end
|
||||
|
||||
function suite.setarray_CorrectsCase_OnConstrainedValue()
|
||||
premake.CurrentConfiguration = { }
|
||||
premake.CurrentConfiguration.myfield = { }
|
||||
premake.setarray("config", "myfield", "better", { "Good", "Better", "Best" })
|
||||
test.isequal("Better", premake.CurrentConfiguration.myfield[1])
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- premake.setstring() tests
|
||||
--
|
||||
|
||||
function suite.setstring_Sets_OnNewProperty()
|
||||
premake.CurrentConfiguration = { }
|
||||
premake.setstring("config", "myfield", "hello")
|
||||
test.isequal("hello", premake.CurrentConfiguration.myfield)
|
||||
end
|
||||
|
||||
function suite.setstring_Overwrites_OnExistingProperty()
|
||||
premake.CurrentConfiguration = { }
|
||||
premake.CurrentConfiguration.myfield = "hello"
|
||||
premake.setstring("config", "myfield", "goodbye")
|
||||
test.isequal("goodbye", premake.CurrentConfiguration.myfield)
|
||||
end
|
||||
|
||||
function suite.setstring_RaisesError_OnInvalidValue()
|
||||
premake.CurrentConfiguration = { }
|
||||
ok, err = pcall(function () premake.setstring("config", "myfield", "bad", { "Good", "Better", "Best" }) end)
|
||||
test.isfalse(ok)
|
||||
end
|
||||
|
||||
function suite.setstring_CorrectsCase_OnConstrainedValue()
|
||||
premake.CurrentConfiguration = { }
|
||||
premake.setstring("config", "myfield", "better", { "Good", "Better", "Best" })
|
||||
test.isequal("Better", premake.CurrentConfiguration.myfield)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- premake.setkeyvalue() tests
|
||||
--
|
||||
|
||||
function suite.setkeyvalue_Inserts_OnStringValue()
|
||||
premake.CurrentConfiguration = { }
|
||||
premake.setkeyvalue("config", "vpaths", { ["Headers"] = "*.h" })
|
||||
test.isequal({"*.h"}, premake.CurrentConfiguration.vpaths["Headers"])
|
||||
end
|
||||
|
||||
function suite.setkeyvalue_Inserts_OnTableValue()
|
||||
premake.CurrentConfiguration = { }
|
||||
premake.setkeyvalue("config", "vpaths", { ["Headers"] = {"*.h","*.hpp"} })
|
||||
test.isequal({"*.h","*.hpp"}, premake.CurrentConfiguration.vpaths["Headers"])
|
||||
end
|
||||
|
||||
function suite.setkeyvalue_Inserts_OnEmptyStringKey()
|
||||
premake.CurrentConfiguration = { }
|
||||
premake.setkeyvalue("config", "vpaths", { [""] = "src" })
|
||||
test.isequal({"src"}, premake.CurrentConfiguration.vpaths[""])
|
||||
end
|
||||
|
||||
function suite.setkeyvalue_RaisesError_OnString()
|
||||
premake.CurrentConfiguration = { }
|
||||
ok, err = pcall(function () premake.setkeyvalue("config", "vpaths", "Headers") end)
|
||||
test.isfalse(ok)
|
||||
end
|
||||
|
||||
function suite.setkeyvalue_InsertsString_IntoExistingKey()
|
||||
premake.CurrentConfiguration = { }
|
||||
premake.setkeyvalue("config", "vpaths", { ["Headers"] = "*.h" })
|
||||
premake.setkeyvalue("config", "vpaths", { ["Headers"] = "*.hpp" })
|
||||
test.isequal({"*.h","*.hpp"}, premake.CurrentConfiguration.vpaths["Headers"])
|
||||
end
|
||||
|
||||
function suite.setkeyvalue_InsertsTable_IntoExistingKey()
|
||||
premake.CurrentConfiguration = { }
|
||||
premake.setkeyvalue("config", "vpaths", { ["Headers"] = {"*.h"} })
|
||||
premake.setkeyvalue("config", "vpaths", { ["Headers"] = {"*.hpp"} })
|
||||
test.isequal({"*.h","*.hpp"}, premake.CurrentConfiguration.vpaths["Headers"])
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- accessor tests
|
||||
--
|
||||
|
||||
function suite.accessor_CanRetrieveString()
|
||||
sln.blocks[1].kind = "ConsoleApp"
|
||||
test.isequal("ConsoleApp", kind())
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- solution() tests
|
||||
--
|
||||
|
||||
function suite.solution_SetsCurrentContainer_OnName()
|
||||
test.istrue(sln == premake.CurrentContainer)
|
||||
end
|
||||
|
||||
function suite.solution_CreatesNewObject_OnNewName()
|
||||
solution "MySolution2"
|
||||
test.isfalse(sln == premake.CurrentContainer)
|
||||
end
|
||||
|
||||
function suite.solution_ReturnsPrevious_OnExistingName()
|
||||
solution "MySolution2"
|
||||
local sln2 = solution "MySolution"
|
||||
test.istrue(sln == sln2)
|
||||
end
|
||||
|
||||
function suite.solution_SetsCurrentContainer_OnExistingName()
|
||||
solution "MySolution2"
|
||||
solution "MySolution"
|
||||
test.istrue(sln == premake.CurrentContainer)
|
||||
end
|
||||
|
||||
function suite.solution_ReturnsNil_OnNoActiveSolutionAndNoName()
|
||||
premake.CurrentContainer = nil
|
||||
test.isnil(solution())
|
||||
end
|
||||
|
||||
function suite.solution_ReturnsCurrentSolution_OnActiveSolutionAndNoName()
|
||||
test.istrue(sln == solution())
|
||||
end
|
||||
|
||||
function suite.solution_ReturnsCurrentSolution_OnActiveProjectAndNoName()
|
||||
project "MyProject"
|
||||
test.istrue(sln == solution())
|
||||
end
|
||||
|
||||
function suite.solution_LeavesProjectActive_OnActiveProjectAndNoName()
|
||||
local prj = project "MyProject"
|
||||
solution()
|
||||
test.istrue(prj == premake.CurrentContainer)
|
||||
end
|
||||
|
||||
function suite.solution_LeavesConfigActive_OnActiveSolutionAndNoName()
|
||||
local cfg = configuration "windows"
|
||||
solution()
|
||||
test.istrue(cfg == premake.CurrentConfiguration)
|
||||
end
|
||||
|
||||
function suite.solution_LeavesConfigActive_OnActiveProjectAndNoName()
|
||||
project "MyProject"
|
||||
local cfg = configuration "windows"
|
||||
solution()
|
||||
test.istrue(cfg == premake.CurrentConfiguration)
|
||||
end
|
||||
|
||||
function suite.solution_SetsName_OnNewName()
|
||||
test.isequal("MySolution", sln.name)
|
||||
end
|
||||
|
||||
function suite.solution_AddsNewConfig_OnNewName()
|
||||
test.istrue(#sln.blocks == 1)
|
||||
end
|
||||
|
||||
function suite.solution_AddsNewConfig_OnName()
|
||||
local num = #sln.blocks
|
||||
solution "MySolution"
|
||||
test.istrue(#sln.blocks == num + 1)
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- configuration() tests
|
||||
--
|
||||
|
||||
function suite.configuration_RaisesError_OnNoContainer()
|
||||
premake.CurrentContainer = nil
|
||||
local fn = function() configuration{"Debug"} end
|
||||
ok, err = pcall(fn)
|
||||
test.isfalse(ok)
|
||||
end
|
||||
|
||||
function suite.configuration_SetsCurrentConfiguration_OnKeywords()
|
||||
local cfg = configuration {"Debug"}
|
||||
test.istrue(premake.CurrentConfiguration == cfg)
|
||||
end
|
||||
|
||||
function suite.configuration_AddsToContainer_OnKeywords()
|
||||
local cfg = configuration {"Debug"}
|
||||
test.istrue(cfg == sln.blocks[#sln.blocks])
|
||||
end
|
||||
|
||||
function suite.configuration_ReturnsCurrent_OnNoKeywords()
|
||||
local cfg = configuration()
|
||||
test.istrue(cfg == sln.blocks[1])
|
||||
end
|
||||
|
||||
function suite.configuration_SetsTerms()
|
||||
local cfg = configuration {"aa", "bb"}
|
||||
test.isequal({"aa", "bb"}, cfg.terms)
|
||||
end
|
||||
|
||||
function suite.configuration_SetsTermsWithNestedTables()
|
||||
local cfg = configuration { {"aa", "bb"}, "cc" }
|
||||
test.isequal({"aa", "bb", "cc"}, cfg.terms)
|
||||
end
|
||||
|
||||
function suite.configuration_CanReuseTerms()
|
||||
local cfg = configuration { "aa", "bb" }
|
||||
local cfg2 = configuration { cfg.terms, "cc" }
|
||||
test.isequal({"aa", "bb", "cc"}, cfg2.terms)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- project() tests
|
||||
--
|
||||
|
||||
function suite.project_RaisesError_OnNoSolution()
|
||||
premake.CurrentContainer = nil
|
||||
local fn = function() project("MyProject") end
|
||||
ok, err = pcall(fn)
|
||||
test.isfalse(ok)
|
||||
end
|
||||
|
||||
function suite.project_SetsCurrentContainer_OnName()
|
||||
local prj = project "MyProject"
|
||||
test.istrue(prj == premake.CurrentContainer)
|
||||
end
|
||||
|
||||
function suite.project_CreatesNewObject_OnNewName()
|
||||
local prj = project "MyProject"
|
||||
local pr2 = project "MyProject2"
|
||||
test.isfalse(prj == premake.CurrentContainer)
|
||||
end
|
||||
|
||||
function suite.project_AddsToSolution_OnNewName()
|
||||
local prj = project "MyProject"
|
||||
test.istrue(prj == sln.projects[1])
|
||||
end
|
||||
|
||||
function suite.project_ReturnsPrevious_OnExistingName()
|
||||
local prj = project "MyProject"
|
||||
local pr2 = project "MyProject2"
|
||||
local pr3 = project "MyProject"
|
||||
test.istrue(prj == pr3)
|
||||
end
|
||||
|
||||
function suite.project_SetsCurrentContainer_OnExistingName()
|
||||
local prj = project "MyProject"
|
||||
local pr2 = project "MyProject2"
|
||||
local pr3 = project "MyProject"
|
||||
test.istrue(prj == premake.CurrentContainer)
|
||||
end
|
||||
|
||||
function suite.project_ReturnsNil_OnNoActiveProjectAndNoName()
|
||||
test.isnil(project())
|
||||
end
|
||||
|
||||
function suite.project_ReturnsCurrentProject_OnActiveProjectAndNoName()
|
||||
local prj = project "MyProject"
|
||||
test.istrue(prj == project())
|
||||
end
|
||||
|
||||
function suite.project_LeavesProjectActive_OnActiveProjectAndNoName()
|
||||
local prj = project "MyProject"
|
||||
project()
|
||||
test.istrue(prj == premake.CurrentContainer)
|
||||
end
|
||||
|
||||
function suite.project_LeavesConfigActive_OnActiveProjectAndNoName()
|
||||
local prj = project "MyProject"
|
||||
local cfg = configuration "Windows"
|
||||
project()
|
||||
test.istrue(cfg == premake.CurrentConfiguration)
|
||||
end
|
||||
|
||||
function suite.project_SetsName_OnNewName()
|
||||
prj = project("MyProject")
|
||||
test.isequal("MyProject", prj.name)
|
||||
end
|
||||
|
||||
function suite.project_SetsSolution_OnNewName()
|
||||
prj = project("MyProject")
|
||||
test.istrue(sln == prj.solution)
|
||||
end
|
||||
|
||||
function suite.project_SetsConfiguration()
|
||||
prj = project("MyProject")
|
||||
test.istrue(premake.CurrentConfiguration == prj.blocks[1])
|
||||
end
|
||||
|
||||
function suite.project_SetsUUID()
|
||||
local prj = project "MyProject"
|
||||
test.istrue(prj.uuid)
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- uuid() tests
|
||||
--
|
||||
|
||||
function suite.uuid_makes_uppercase()
|
||||
premake.CurrentContainer = {}
|
||||
uuid "7CBB5FC2-7449-497f-947F-129C5129B1FB"
|
||||
test.isequal(premake.CurrentContainer.uuid, "7CBB5FC2-7449-497F-947F-129C5129B1FB")
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Fields with allowed value lists should be case-insensitive.
|
||||
--
|
||||
|
||||
function suite.flags_onCaseMismatch()
|
||||
premake.CurrentConfiguration = {}
|
||||
flags "symbols"
|
||||
test.isequal(premake.CurrentConfiguration.flags[1], "Symbols")
|
||||
end
|
||||
|
||||
function suite.flags_onCaseMismatchAndAlias()
|
||||
premake.CurrentConfiguration = {}
|
||||
flags "optimisespeed"
|
||||
test.isequal(premake.CurrentConfiguration.flags[1], "OptimizeSpeed")
|
||||
end
|
||||
|
174
Src/external_dependencies/openmpt-trunk/include/genie/tests/base/test_baking.lua
vendored
Normal file
174
Src/external_dependencies/openmpt-trunk/include/genie/tests/base/test_baking.lua
vendored
Normal file
|
@ -0,0 +1,174 @@
|
|||
--
|
||||
-- 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
|
||||
|
||||
--
|
||||
-- Setup code
|
||||
--
|
||||
|
||||
local prj, cfg
|
||||
function suite.setup()
|
||||
_ACTION = "gmake"
|
||||
|
||||
solution "MySolution"
|
||||
configurations { "Debug", "Release" }
|
||||
platforms { "x32", "ps3" }
|
||||
|
||||
defines "SOLUTION"
|
||||
|
||||
configuration "Debug"
|
||||
defines "SOLUTION_DEBUG"
|
||||
|
||||
prj = project "MyProject"
|
||||
language "C"
|
||||
kind "SharedLib"
|
||||
targetdir "../bin"
|
||||
defines "PROJECT"
|
||||
|
||||
configuration "Debug"
|
||||
defines "DEBUG"
|
||||
|
||||
configuration "Release"
|
||||
defines "RELEASE"
|
||||
|
||||
configuration "native"
|
||||
defines "NATIVE"
|
||||
|
||||
configuration "x32"
|
||||
defines "X86_32"
|
||||
|
||||
configuration "x64"
|
||||
defines "X86_64"
|
||||
end
|
||||
|
||||
local function prepare()
|
||||
premake.bake.buildconfigs()
|
||||
prj = premake.getconfig(prj)
|
||||
cfg = premake.getconfig(prj, "Debug")
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Tests
|
||||
--
|
||||
|
||||
function suite.ProjectWideSettings()
|
||||
prepare()
|
||||
test.isequal("SOLUTION:PROJECT:NATIVE", table.concat(prj.defines,":"))
|
||||
end
|
||||
|
||||
|
||||
function suite.BuildCfgSettings()
|
||||
prepare()
|
||||
test.isequal("SOLUTION:SOLUTION_DEBUG:PROJECT:DEBUG:NATIVE", table.concat(cfg.defines,":"))
|
||||
end
|
||||
|
||||
|
||||
function suite.PlatformSettings()
|
||||
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()
|
||||
prepare()
|
||||
local cfg = premake.getconfig(prj, "Debug", "x32")
|
||||
test.isequal("Debug", cfg.name)
|
||||
end
|
||||
|
||||
|
||||
function suite.SetsPlatformName()
|
||||
prepare()
|
||||
local cfg = premake.getconfig(prj, "Debug", "x32")
|
||||
test.isequal("x32", cfg.platform)
|
||||
end
|
||||
|
||||
|
||||
function suite.SetsPlatformNativeName()
|
||||
test.isequal("Native", cfg.platform)
|
||||
end
|
||||
|
||||
|
||||
function suite.SetsShortName()
|
||||
prepare()
|
||||
local cfg = premake.getconfig(prj, "Debug", "x32")
|
||||
test.isequal("debug32", cfg.shortname)
|
||||
end
|
||||
|
||||
|
||||
function suite.SetsNativeShortName()
|
||||
prepare()
|
||||
test.isequal("debug", cfg.shortname)
|
||||
end
|
||||
|
||||
|
||||
function suite.SetsLongName()
|
||||
prepare()
|
||||
local cfg = premake.getconfig(prj, "Debug", "x32")
|
||||
test.isequal("Debug|x32", cfg.longname)
|
||||
end
|
||||
|
||||
|
||||
function suite.SetsNativeLongName()
|
||||
prepare()
|
||||
test.isequal("Debug", cfg.longname)
|
||||
end
|
||||
|
||||
|
||||
function suite.SetsProject()
|
||||
prepare()
|
||||
local cfg = premake.getconfig(prj, "Debug", "x32")
|
||||
test.istrue(prj.project == cfg.project)
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Target system testing
|
||||
--
|
||||
|
||||
function suite.SetsTargetSystem_OnNative()
|
||||
prepare()
|
||||
test.isequal(os.get(), cfg.system)
|
||||
end
|
||||
|
||||
function suite.SetTargetSystem_OnCrossCompiler()
|
||||
prepare()
|
||||
local cfg = premake.getconfig(prj, "Debug", "PS3")
|
||||
test.isequal("PS3", cfg.system)
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Configuration-specific kinds
|
||||
--
|
||||
|
||||
function suite.SetsConfigSpecificKind()
|
||||
configuration "Debug"
|
||||
kind "ConsoleApp"
|
||||
prepare()
|
||||
test.isequal("ConsoleApp", cfg.kind)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Platform kind translation
|
||||
--
|
||||
|
||||
function suite.SetsTargetKind_OnSupportedKind()
|
||||
prepare()
|
||||
test.isequal("SharedLib", cfg.kind)
|
||||
end
|
||||
|
||||
function suite.SetsTargetKind_OnUnsupportedKind()
|
||||
prepare()
|
||||
local cfg = premake.getconfig(prj, "Debug", "PS3")
|
||||
test.isequal("StaticLib", cfg.kind)
|
||||
end
|
98
Src/external_dependencies/openmpt-trunk/include/genie/tests/base/test_config.lua
vendored
Normal file
98
Src/external_dependencies/openmpt-trunk/include/genie/tests/base/test_config.lua
vendored
Normal file
|
@ -0,0 +1,98 @@
|
|||
--
|
||||
-- tests/test_config.lua
|
||||
-- Automated test suite for the configuration handling functions.
|
||||
-- Copyright (c) 2010 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
T.config = { }
|
||||
local suite = T.config
|
||||
|
||||
|
||||
--
|
||||
-- Setup/Teardown
|
||||
--
|
||||
|
||||
function suite.setup()
|
||||
sln = test.createsolution()
|
||||
end
|
||||
|
||||
local cfg
|
||||
local function prepare()
|
||||
premake.bake.buildconfigs()
|
||||
cfg = premake.solution.getproject(sln, 1)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Debug/Release build testing
|
||||
--
|
||||
function suite.IsDebug_ReturnsFalse_EnglishSpellingOfOptimiseFlag()
|
||||
flags { "Optimise" }
|
||||
prepare()
|
||||
return test.isfalse(premake.config.isdebugbuild(cfg))
|
||||
end
|
||||
|
||||
function suite.IsDebug_ReturnsFalse_EnglishSpellingOfOptimiseSizeFlag()
|
||||
flags { "OptimiseSize" }
|
||||
prepare()
|
||||
return test.isfalse(premake.config.isdebugbuild(cfg))
|
||||
end
|
||||
|
||||
function suite.IsDebug_ReturnsFalse_EnglishSpellingOfOptimiseSpeedFlag()
|
||||
flags { "OptimiseSpeed" }
|
||||
prepare()
|
||||
return test.isfalse(premake.config.isdebugbuild(cfg))
|
||||
end
|
||||
|
||||
function suite.IsDebug_ReturnsFalse_OnOptimizeFlag()
|
||||
flags { "Optimize" }
|
||||
prepare()
|
||||
return test.isfalse(premake.config.isdebugbuild(cfg))
|
||||
end
|
||||
|
||||
function suite.IsDebug_ReturnsFalse_OnOptimizeSizeFlag()
|
||||
flags { "OptimizeSize" }
|
||||
prepare()
|
||||
return test.isfalse(premake.config.isdebugbuild(cfg))
|
||||
end
|
||||
|
||||
function suite.IsDebug_ReturnsFalse_OnOptimizeSpeedFlag()
|
||||
flags { "OptimizeSpeed" }
|
||||
prepare()
|
||||
return test.isfalse(premake.config.isdebugbuild(cfg))
|
||||
end
|
||||
|
||||
function suite.IsDebug_ReturnsFalse_OnNoSymbolsFlag()
|
||||
prepare()
|
||||
return test.isfalse(premake.config.isdebugbuild(cfg))
|
||||
end
|
||||
|
||||
function suite.IsDebug_ReturnsTrue_OnSymbolsFlag()
|
||||
flags { "Symbols" }
|
||||
prepare()
|
||||
return test.istrue(premake.config.isdebugbuild(cfg))
|
||||
end
|
||||
|
||||
function suite.shouldIncrementallyLink_staticLib_returnsFalse()
|
||||
kind "StaticLib"
|
||||
prepare()
|
||||
return test.isfalse(premake.config.isincrementallink(cfg))
|
||||
end
|
||||
|
||||
function suite.shouldIncrementallyLink_optimizeFlagSet_returnsFalse()
|
||||
flags { "Optimize" }
|
||||
prepare()
|
||||
return test.isfalse(premake.config.isincrementallink(cfg))
|
||||
end
|
||||
|
||||
function suite.shouldIncrementallyLink_NoIncrementalLinkFlag_returnsFalse()
|
||||
flags { "NoIncrementalLink" }
|
||||
prepare()
|
||||
return test.isfalse(premake.config.isincrementallink(cfg))
|
||||
end
|
||||
|
||||
function suite.shouldIncrementallyLink_notStaticLib_NoIncrementalLinkFlag_noOptimiseFlag_returnsTrue()
|
||||
prepare()
|
||||
return test.istrue(premake.config.isincrementallink(cfg))
|
||||
end
|
||||
|
192
Src/external_dependencies/openmpt-trunk/include/genie/tests/base/test_config_bug.lua
vendored
Normal file
192
Src/external_dependencies/openmpt-trunk/include/genie/tests/base/test_config_bug.lua
vendored
Normal file
|
@ -0,0 +1,192 @@
|
|||
T.config_bug_report = { }
|
||||
local config_bug = T.config_bug_report
|
||||
local vs10_helpers = premake.vstudio.vs10_helpers
|
||||
|
||||
local sln, prjA,prjB,prjC,prjD,prjE
|
||||
function config_bug.teardown()
|
||||
sln = nil
|
||||
prjA = nil
|
||||
prjB = nil
|
||||
prjC = nil
|
||||
prjD = nil
|
||||
prjE = nil
|
||||
end
|
||||
|
||||
function config_bug.setup()
|
||||
end
|
||||
|
||||
|
||||
|
||||
local config_bug_updated = function ()
|
||||
|
||||
local setCommonLibraryConfig = function()
|
||||
configuration "Debug or Release"
|
||||
kind "StaticLib"
|
||||
|
||||
configuration "DebugDLL or ReleaseDLL"
|
||||
kind "SharedLib"
|
||||
end
|
||||
|
||||
sln = solution "Test"
|
||||
configurations { "Debug", "Release", "DebugDLL", "ReleaseDLL" }
|
||||
language "C++"
|
||||
|
||||
prjA = project "A"
|
||||
files { "a.cpp" }
|
||||
setCommonLibraryConfig()
|
||||
prjB = project "B"
|
||||
files { "b.cpp" }
|
||||
setCommonLibraryConfig()
|
||||
configuration "SharedLib"
|
||||
links { "A" }
|
||||
prjC = project "C"
|
||||
files { "c.cpp" }
|
||||
setCommonLibraryConfig()
|
||||
configuration "SharedLib"
|
||||
links { "A", "B" }
|
||||
prjD = project "D"
|
||||
files { "d.cpp" }
|
||||
setCommonLibraryConfig()
|
||||
configuration "SharedLib"
|
||||
links { "A", "B", "C" }
|
||||
prjE = project "Executable"
|
||||
kind "WindowedApp"
|
||||
links { "A", "B", "C", "D" }
|
||||
|
||||
end
|
||||
|
||||
local kindSetOnConfiguration_and_linkSetOnSharedLibProjB = function (config_kind)
|
||||
sln = solution "DontCare"
|
||||
configurations { "DebugDLL"}
|
||||
|
||||
configuration "DebugDLL"
|
||||
kind(config_kind)
|
||||
prjA = project "A"
|
||||
prjB = project "B"
|
||||
configuration { config_kind }
|
||||
links { "A" }
|
||||
end
|
||||
|
||||
local sharedLibKindSetOnProject_and_linkSetOnSharedLibProjB = function ()
|
||||
sln = solution "DontCare"
|
||||
configurations { "DebugDLL" }
|
||||
project "A"
|
||||
prjB = project "B"
|
||||
configuration "DebugDLL"
|
||||
kind "SharedLib"
|
||||
configuration "SharedLib"
|
||||
links { "A" }
|
||||
defines {"defineSet"}
|
||||
|
||||
end
|
||||
|
||||
|
||||
local kindSetOnConfiguration_and_linkSetOnBundleProjB = function (config_kind)
|
||||
sln = solution "DontCare"
|
||||
configurations { "DebugDLL"}
|
||||
|
||||
configuration "DebugDLL"
|
||||
kind(config_kind)
|
||||
prjA = project "A"
|
||||
prjB = project "B"
|
||||
configuration { config_kind }
|
||||
links { "A" }
|
||||
end
|
||||
|
||||
local sharedLibKindSetOnProject_and_linkSetOnBundleProjB = function ()
|
||||
sln = solution "DontCare"
|
||||
configurations { "DebugDLL" }
|
||||
project "A"
|
||||
prjB = project "B"
|
||||
configuration "DebugDLL"
|
||||
kind "Bundle"
|
||||
configuration "Bundle"
|
||||
links { "A" }
|
||||
defines {"defineSet"}
|
||||
|
||||
end
|
||||
|
||||
|
||||
function kind_set_on_project_config_block()
|
||||
sln = solution "DontCare"
|
||||
configurations { "DebugDLL" }
|
||||
local A = project "A"
|
||||
configuration "DebugDLL"
|
||||
kind "SharedLib"
|
||||
defines {"defineSet"}
|
||||
return A
|
||||
end
|
||||
|
||||
|
||||
function config_bug.bugUpdated_prjBLinksContainsA()
|
||||
config_bug_updated()
|
||||
premake.bake.buildconfigs()
|
||||
local conf = premake.getconfig(prjB,"DebugDLL","Native")
|
||||
test.isnotnil(conf.links.A)
|
||||
end
|
||||
|
||||
|
||||
function config_bug.kindSetOnProjectConfigBlock_projKindEqualsSharedLib()
|
||||
local proj = kind_set_on_project_config_block()
|
||||
premake.bake.buildconfigs()
|
||||
local conf = premake.getconfig(proj,"DebugDLL","Native")
|
||||
test.isequal("SharedLib",conf.kind)
|
||||
end
|
||||
|
||||
function config_bug.kindSetOnProjectConfigBlock_projKindEqualsBundle()
|
||||
local proj = kind_set_on_project_config_block()
|
||||
premake.bake.buildconfigs()
|
||||
local conf = premake.getconfig(proj,"DebugDLL","Native")
|
||||
test.isequal("Bundle",conf.kind)
|
||||
end
|
||||
|
||||
function config_bug.defineSetOnProjectConfigBlock_projDefineSetIsNotNil()
|
||||
local proj = kind_set_on_project_config_block()
|
||||
premake.bake.buildconfigs()
|
||||
local conf = premake.getconfig(proj,"DebugDLL","Native")
|
||||
test.isnotnil(conf.defines.defineSet)
|
||||
end
|
||||
|
||||
function config_bug.defineSetInBlockInsideProject ()
|
||||
sharedLibKindSetOnProject_and_linkSetOnSharedLibProjB()
|
||||
premake.bake.buildconfigs()
|
||||
local conf = premake.getconfig(prjB,"DebugDLL","Native")
|
||||
test.isnotnil(conf.defines.defineSet)
|
||||
end
|
||||
|
||||
|
||||
function config_bug.whenKindSetOnProject_PrjBLinksContainsA()
|
||||
sharedLibKindSetOnProject_and_linkSetOnSharedLibProjB()
|
||||
premake.bake.buildconfigs()
|
||||
local conf = premake.getconfig(prjB,"DebugDLL","Native")
|
||||
test.isnotnil(conf.links.A)
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function config_bug.whenKindSetOnConfiguration_prjBLinksContainsA_StaticLib()
|
||||
-- sharedLibKindSetOnConfiguration_and_linkSetOnSharedLibProjB()
|
||||
kindSetOnConfiguration_and_linkSetOnSharedLibProjB("StaticLib")
|
||||
premake.bake.buildconfigs()
|
||||
local config = premake.getconfig(prjB,"DebugDLL","Native")
|
||||
test.isnotnil(config.links.A)
|
||||
end
|
||||
|
||||
function config_bug.whenKindSetOnConfiguration_prjBLinksContainsA()
|
||||
-- sharedLibKindSetOnConfiguration_and_linkSetOnSharedLibProjB()
|
||||
kindSetOnConfiguration_and_linkSetOnSharedLibProjB("SharedLib")
|
||||
premake.bake.buildconfigs()
|
||||
local config = premake.getconfig(prjB,"DebugDLL","Native")
|
||||
test.isnotnil(config.links.A)
|
||||
end
|
||||
|
||||
function config_bug.whenKindSetOnConfiguration_prjBLinksContainsA_bundle()
|
||||
-- sharedLibKindSetOnConfiguration_and_linkSetOnBundleProjB()
|
||||
kindSetOnConfiguration_and_linkSetOnBundleProjB("Bundle")
|
||||
premake.bake.buildconfigs()
|
||||
local config = premake.getconfig(prjB,"DebugDLL","Native")
|
||||
test.isnotnil(config.links.A)
|
||||
end
|
||||
|
100
Src/external_dependencies/openmpt-trunk/include/genie/tests/base/test_location.lua
vendored
Normal file
100
Src/external_dependencies/openmpt-trunk/include/genie/tests/base/test_location.lua
vendored
Normal file
|
@ -0,0 +1,100 @@
|
|||
--
|
||||
-- tests/base/test_location.lua
|
||||
-- Automated tests for the location() function.
|
||||
-- Copyright (c) 2011 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
T.base_location = { }
|
||||
local suite = T.base_location
|
||||
|
||||
|
||||
--
|
||||
-- Setup/Teardown
|
||||
--
|
||||
|
||||
function suite.setup()
|
||||
sln = solution "MySolution"
|
||||
configurations { "Debug", "Release" }
|
||||
language "C"
|
||||
end
|
||||
|
||||
local function prepare()
|
||||
premake.bake.buildconfigs()
|
||||
prj = premake.solution.getproject(sln, 1)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Test no location set
|
||||
--
|
||||
|
||||
function suite.solutionUsesCwd_OnNoLocationSet()
|
||||
project "MyProject"
|
||||
prepare()
|
||||
test.isequal(os.getcwd(), sln.location)
|
||||
end
|
||||
|
||||
function suite.projectUsesCwd_OnNoLocationSet()
|
||||
project "MyProject"
|
||||
prepare()
|
||||
test.isequal(os.getcwd(), prj.location)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Test with location set on solution only
|
||||
--
|
||||
|
||||
function suite.solutionUsesLocation_OnSolutionOnly()
|
||||
location "build"
|
||||
project "MyProject"
|
||||
prepare()
|
||||
test.isequal(path.join(os.getcwd(), "build"), sln.location)
|
||||
end
|
||||
|
||||
function suite.projectUsesLocation_OnSolutionOnly()
|
||||
location "build"
|
||||
project "MyProject"
|
||||
prepare()
|
||||
test.isequal(path.join(os.getcwd(), "build"), prj.location)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Test with location set on project only
|
||||
--
|
||||
|
||||
function suite.solutionUsesCwd_OnProjectOnly()
|
||||
project "MyProject"
|
||||
location "build"
|
||||
prepare()
|
||||
test.isequal(os.getcwd(), sln.location)
|
||||
end
|
||||
|
||||
function suite.projectUsesLocation_OnProjectOnly()
|
||||
project "MyProject"
|
||||
location "build"
|
||||
prepare()
|
||||
test.isequal(path.join(os.getcwd(), "build"), prj.location)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Test with location set on both solution and project only
|
||||
--
|
||||
|
||||
function suite.solutionUsesCwd_OnProjectOnly()
|
||||
location "build/solution"
|
||||
project "MyProject"
|
||||
location "build/project"
|
||||
prepare()
|
||||
test.isequal(path.join(os.getcwd(), "build/solution"), sln.location)
|
||||
end
|
||||
|
||||
function suite.projectUsesLocation_OnProjectOnly()
|
||||
location "build/solution"
|
||||
project "MyProject"
|
||||
location "build/project"
|
||||
prepare()
|
||||
test.isequal(path.join(os.getcwd(), "build/project"), prj.location)
|
||||
end
|
124
Src/external_dependencies/openmpt-trunk/include/genie/tests/base/test_os.lua
vendored
Normal file
124
Src/external_dependencies/openmpt-trunk/include/genie/tests/base/test_os.lua
vendored
Normal file
|
@ -0,0 +1,124 @@
|
|||
--
|
||||
-- tests/base/test_os.lua
|
||||
-- Automated test suite for the new OS functions.
|
||||
-- Copyright (c) 2008-2011 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
|
||||
T.os = { }
|
||||
local suite = T.os
|
||||
|
||||
|
||||
--
|
||||
-- os.findlib() tests
|
||||
--
|
||||
|
||||
function suite.findlib_FindSystemLib()
|
||||
if os.is("windows") then
|
||||
test.istrue(os.findlib("user32"))
|
||||
else
|
||||
test.istrue(os.findlib("m"))
|
||||
end
|
||||
end
|
||||
|
||||
function suite.findlib_FailsOnBadLibName()
|
||||
test.isfalse(os.findlib("NoSuchLibraryAsThisOneHere"))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- os.isfile() tests
|
||||
--
|
||||
|
||||
function suite.isfile_ReturnsTrue_OnExistingFile()
|
||||
test.istrue(os.isfile("premake4.lua"))
|
||||
end
|
||||
|
||||
function suite.isfile_ReturnsFalse_OnNonexistantFile()
|
||||
test.isfalse(os.isfile("no_such_file.lua"))
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- os.matchfiles() tests
|
||||
--
|
||||
|
||||
function suite.matchfiles_OnNonRecursive()
|
||||
local result = os.matchfiles("*.lua")
|
||||
test.istrue(table.contains(result, "testfx.lua"))
|
||||
test.isfalse(table.contains(result, "folder/ok.lua"))
|
||||
end
|
||||
|
||||
function suite.matchfiles_Recursive()
|
||||
local result = os.matchfiles("**.lua")
|
||||
test.istrue(table.contains(result, "folder/ok.lua"))
|
||||
end
|
||||
|
||||
function suite.matchfiles_SkipsDotDirs_OnRecursive()
|
||||
local result = os.matchfiles("**.lua")
|
||||
test.isfalse(table.contains(result, ".svn/text-base/testfx.lua.svn-base"))
|
||||
end
|
||||
|
||||
function suite.matchfiles_OnSubfolderMatch()
|
||||
local result = os.matchfiles("**/xcode/*")
|
||||
test.istrue(table.contains(result, "actions/xcode/test_xcode_project.lua"))
|
||||
test.isfalse(table.contains(result, "premake4.lua"))
|
||||
end
|
||||
|
||||
function suite.matchfiles_OnDotSlashPrefix()
|
||||
local result = os.matchfiles("./**.lua")
|
||||
test.istrue(table.contains(result, "folder/ok.lua"))
|
||||
end
|
||||
|
||||
function suite.matchfiles_OnImplicitEndOfString()
|
||||
local result = os.matchfiles("folder/*.lua")
|
||||
test.istrue(table.contains(result, "folder/ok.lua"))
|
||||
test.isfalse(table.contains(result, "folder/ok.lua.2"))
|
||||
end
|
||||
|
||||
function suite.matchfiles_OnLeadingDotSlashWithPath()
|
||||
local result = os.matchfiles("./folder/*.lua")
|
||||
test.istrue(table.contains(result, "folder/ok.lua"))
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- os.pathsearch() tests
|
||||
--
|
||||
|
||||
function suite.pathsearch_ReturnsNil_OnNotFound()
|
||||
test.istrue( os.pathsearch("nosuchfile", "aaa;bbb;ccc") == nil )
|
||||
end
|
||||
|
||||
function suite.pathsearch_ReturnsPath_OnFound()
|
||||
test.isequal(os.getcwd(), os.pathsearch("premake4.lua", os.getcwd()))
|
||||
end
|
||||
|
||||
function suite.pathsearch_FindsFile_OnComplexPath()
|
||||
test.isequal(os.getcwd(), os.pathsearch("premake4.lua", "aaa;"..os.getcwd()..";bbb"))
|
||||
end
|
||||
|
||||
function suite.pathsearch_NilPathsAllowed()
|
||||
test.isequal(os.getcwd(), os.pathsearch("premake4.lua", nil, os.getcwd(), nil))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- os.uuid() tests
|
||||
--
|
||||
|
||||
function suite.guid_ReturnsValidUUID()
|
||||
local g = os.uuid()
|
||||
test.istrue(#g == 36)
|
||||
for i=1,36 do
|
||||
local ch = g:sub(i,i)
|
||||
test.istrue(ch:find("[ABCDEF0123456789-]"))
|
||||
end
|
||||
test.isequal("-", g:sub(9,9))
|
||||
test.isequal("-", g:sub(14,14))
|
||||
test.isequal("-", g:sub(19,19))
|
||||
test.isequal("-", g:sub(24,24))
|
||||
end
|
||||
|
266
Src/external_dependencies/openmpt-trunk/include/genie/tests/base/test_path.lua
vendored
Normal file
266
Src/external_dependencies/openmpt-trunk/include/genie/tests/base/test_path.lua
vendored
Normal file
|
@ -0,0 +1,266 @@
|
|||
--
|
||||
-- tests/base/test_path.lua
|
||||
-- Automated test suite for the action list.
|
||||
-- Copyright (c) 2008-2010 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
T.path = { }
|
||||
local suite = T.path
|
||||
|
||||
|
||||
--
|
||||
-- path.getabsolute() tests
|
||||
--
|
||||
|
||||
function suite.getabsolute_ReturnsCorrectPath_OnMissingSubdir()
|
||||
local expected = path.translate(os.getcwd(), "/") .. "/a/b/c"
|
||||
test.isequal(expected, path.getabsolute("a/b/c"))
|
||||
end
|
||||
|
||||
function suite.getabsolute_RemovesDotDots_OnWindowsAbsolute()
|
||||
test.isequal("c:/ProjectB/bin", path.getabsolute("c:/ProjectA/../ProjectB/bin"))
|
||||
end
|
||||
|
||||
function suite.getabsolute_RemovesDotDots_OnPosixAbsolute()
|
||||
test.isequal("/ProjectB/bin", path.getabsolute("/ProjectA/../ProjectB/bin"))
|
||||
end
|
||||
|
||||
function suite.getabsolute_OnTrailingSlash()
|
||||
local expected = path.translate(os.getcwd(), "/") .. "/a/b/c"
|
||||
test.isequal(expected, path.getabsolute("a/b/c/"))
|
||||
end
|
||||
|
||||
function suite.getabsolute_OnLeadingEnvVar()
|
||||
test.isequal("$(HOME)/user", path.getabsolute("$(HOME)/user"))
|
||||
end
|
||||
|
||||
function suite.getabsolute_OnMultipleEnvVar()
|
||||
test.isequal("$(HOME)/$(USER)", path.getabsolute("$(HOME)/$(USER)"))
|
||||
end
|
||||
|
||||
function suite.getabsolute_OnTrailingEnvVar()
|
||||
local expected = path.translate(os.getcwd(), "/") .. "/home/$(USER)"
|
||||
test.isequal(expected, path.getabsolute("home/$(USER)"))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- path.getbasename() tests
|
||||
--
|
||||
|
||||
function suite.getbasename_ReturnsCorrectName_OnDirAndExtension()
|
||||
test.isequal("filename", path.getbasename("folder/filename.ext"))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- path.getdirectory() tests
|
||||
--
|
||||
|
||||
function suite.getdirectory_ReturnsEmptyString_OnNoDirectory()
|
||||
test.isequal(".", path.getdirectory("filename.ext"))
|
||||
end
|
||||
|
||||
function suite.getdirectory_ReturnsDirectory_OnSingleLevelPath()
|
||||
test.isequal("dir0", path.getdirectory("dir0/filename.ext"))
|
||||
end
|
||||
|
||||
function suite.getdirectory_ReturnsDirectory_OnMultiLeveLPath()
|
||||
test.isequal("dir0/dir1/dir2", path.getdirectory("dir0/dir1/dir2/filename.ext"))
|
||||
end
|
||||
|
||||
function suite.getdirectory_ReturnsRootPath_OnRootPathOnly()
|
||||
test.isequal("/", path.getdirectory("/filename.ext"))
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- path.getdrive() tests
|
||||
--
|
||||
|
||||
function suite.getdrive_ReturnsNil_OnNotWindows()
|
||||
test.isnil(path.getdrive("/hello"))
|
||||
end
|
||||
|
||||
function suite.getdrive_ReturnsLetter_OnWindowsAbsolute()
|
||||
test.isequal("x", path.getdrive("x:/hello"))
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- path.getextension() tests
|
||||
--
|
||||
|
||||
function suite.getextension_ReturnsEmptyString_OnNoExtension()
|
||||
test.isequal("", path.getextension("filename"))
|
||||
end
|
||||
|
||||
function suite.getextension_ReturnsExtension()
|
||||
test.isequal(".txt", path.getextension("filename.txt"))
|
||||
end
|
||||
|
||||
function suite.getextension_OnMultipleDots()
|
||||
test.isequal(".txt", path.getextension("filename.mod.txt"))
|
||||
end
|
||||
|
||||
function suite.getextension_OnLeadingNumeric()
|
||||
test.isequal(".7z", path.getextension("filename.7z"))
|
||||
end
|
||||
|
||||
function suite.getextension_OnUnderscore()
|
||||
test.isequal(".a_c", path.getextension("filename.a_c"))
|
||||
end
|
||||
|
||||
function suite.getextension_OnHyphen()
|
||||
test.isequal(".a-c", path.getextension("filename.a-c"))
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- path.getrelative() tests
|
||||
--
|
||||
|
||||
function suite.getrelative_ReturnsDot_OnMatchingPaths()
|
||||
test.isequal(".", path.getrelative("/a/b/c", "/a/b/c"))
|
||||
end
|
||||
|
||||
function suite.getrelative_ReturnsDoubleDot_OnChildToParent()
|
||||
test.isequal("..", path.getrelative("/a/b/c", "/a/b"))
|
||||
end
|
||||
|
||||
function suite.getrelative_ReturnsDoubleDot_OnSiblingToSibling()
|
||||
test.isequal("../d", path.getrelative("/a/b/c", "/a/b/d"))
|
||||
end
|
||||
|
||||
function suite.getrelative_ReturnsChildPath_OnParentToChild()
|
||||
test.isequal("d", path.getrelative("/a/b/c", "/a/b/c/d"))
|
||||
end
|
||||
|
||||
function suite.getrelative_ReturnsChildPath_OnWindowsAbsolute()
|
||||
test.isequal("obj/debug", path.getrelative("C:/Code/Premake4", "C:/Code/Premake4/obj/debug"))
|
||||
end
|
||||
|
||||
function suite.getrelative_ReturnsAbsPath_OnDifferentDriveLetters()
|
||||
test.isequal("D:/Files", path.getrelative("C:/Code/Premake4", "D:/Files"))
|
||||
end
|
||||
|
||||
function suite.getrelative_ReturnsAbsPath_OnDollarMacro()
|
||||
test.isequal("$(SDK_HOME)/include", path.getrelative("C:/Code/Premake4", "$(SDK_HOME)/include"))
|
||||
end
|
||||
|
||||
function suite.getrelative_ReturnsAbsPath_OnRootedPath()
|
||||
test.isequal("/opt/include", path.getrelative("/home/me/src/project", "/opt/include"))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- path.isabsolute() tests
|
||||
--
|
||||
|
||||
function suite.isabsolute_ReturnsTrue_OnAbsolutePosixPath()
|
||||
test.istrue(path.isabsolute("/a/b/c"))
|
||||
end
|
||||
|
||||
function suite.isabsolute_ReturnsTrue_OnAbsoluteWindowsPathWithDrive()
|
||||
test.istrue(path.isabsolute("C:/a/b/c"))
|
||||
end
|
||||
|
||||
function suite.isabsolute_ReturnsFalse_OnRelativePath()
|
||||
test.isfalse(path.isabsolute("a/b/c"))
|
||||
end
|
||||
|
||||
function suite.isabsolute_ReturnsTrue_OnDollarSign()
|
||||
test.istrue(path.isabsolute("$(SDK_HOME)/include"))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- path.join() tests
|
||||
--
|
||||
|
||||
function suite.join_OnValidParts()
|
||||
test.isequal("p1/p2", path.join("p1", "p2"))
|
||||
end
|
||||
|
||||
function suite.join_OnAbsoluteUnixPath()
|
||||
test.isequal("/p2", path.join("p1", "/p2"))
|
||||
end
|
||||
|
||||
function suite.join_OnAbsoluteWindowsPath()
|
||||
test.isequal("C:/p2", path.join("p1", "C:/p2"))
|
||||
end
|
||||
|
||||
function suite.join_OnCurrentDirectory()
|
||||
test.isequal("p2", path.join(".", "p2"))
|
||||
end
|
||||
|
||||
function suite.join_OnNilSecondPart()
|
||||
test.isequal("p1", path.join("p1", nil))
|
||||
end
|
||||
|
||||
function suite.join_onMoreThanTwoParts()
|
||||
test.isequal("p1/p2/p3", path.join("p1", "p2", "p3"))
|
||||
end
|
||||
|
||||
function suite.join_removesExtraInternalSlashes()
|
||||
test.isequal("p1/p2", path.join("p1/", "p2"))
|
||||
end
|
||||
|
||||
function suite.join_removesTrailingSlash()
|
||||
test.isequal("p1/p2", path.join("p1", "p2/"))
|
||||
end
|
||||
|
||||
function suite.join_ignoresNilParts()
|
||||
test.isequal("p2", path.join(nil, "p2", nil))
|
||||
end
|
||||
|
||||
function suite.join_ignoresEmptyParts()
|
||||
test.isequal("p2", path.join("", "p2", ""))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- path.rebase() tests
|
||||
--
|
||||
|
||||
function suite.rebase_WithEndingSlashOnPath()
|
||||
local cwd = os.getcwd()
|
||||
test.isequal("src", path.rebase("../src/", cwd, path.getdirectory(cwd)))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- path.translate() tests
|
||||
--
|
||||
|
||||
function suite.translate_ReturnsTranslatedPath_OnValidPath()
|
||||
test.isequal("dir/dir/file", path.translate("dir\\dir\\file", "/"))
|
||||
end
|
||||
|
||||
function suite.translate_ReturnsCorrectSeparator_OnMixedPath()
|
||||
local actual = path.translate("dir\\dir/file")
|
||||
if (os.is("windows")) then
|
||||
test.isequal("dir\\dir\\file", actual)
|
||||
else
|
||||
test.isequal("dir/dir/file", actual)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- path.wildcards tests
|
||||
--
|
||||
|
||||
function suite.wildcards_MatchesTrailingStar()
|
||||
local p = path.wildcards("**/xcode/*")
|
||||
test.isequal(".*/xcode/[^/]*", p)
|
||||
end
|
||||
|
||||
function suite.wildcards_MatchPlusSign()
|
||||
local patt = path.wildcards("file+name.*")
|
||||
local name = "file+name.c"
|
||||
test.isequal(name, name:match(patt))
|
||||
end
|
14
Src/external_dependencies/openmpt-trunk/include/genie/tests/base/test_premake_command.lua
vendored
Normal file
14
Src/external_dependencies/openmpt-trunk/include/genie/tests/base/test_premake_command.lua
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
--
|
||||
-- tests/base/test_premake_command.lua
|
||||
-- Test the initialization of the _PREMAKE_COMMAND global.
|
||||
-- Copyright (c) 2012 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
T.premake_command = { }
|
||||
local suite = T.premake_command
|
||||
|
||||
|
||||
function suite.valueIsSet()
|
||||
local filename = iif(os.is("windows"), "premake4.exe", "premake4")
|
||||
test.isequal(path.getabsolute("../bin/debug/" .. filename), _PREMAKE_COMMAND)
|
||||
end
|
65
Src/external_dependencies/openmpt-trunk/include/genie/tests/base/test_table.lua
vendored
Normal file
65
Src/external_dependencies/openmpt-trunk/include/genie/tests/base/test_table.lua
vendored
Normal file
|
@ -0,0 +1,65 @@
|
|||
--
|
||||
-- tests/base/test_table.lua
|
||||
-- Automated test suite for the new table functions.
|
||||
-- Copyright (c) 2008-2010 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
|
||||
T.table = { }
|
||||
local suite = T.table
|
||||
|
||||
|
||||
--
|
||||
-- table.contains() tests
|
||||
--
|
||||
|
||||
function suite.contains_OnContained()
|
||||
t = { "one", "two", "three" }
|
||||
test.istrue( table.contains(t, "two") )
|
||||
end
|
||||
|
||||
function suite.contains_OnNotContained()
|
||||
t = { "one", "two", "three" }
|
||||
test.isfalse( table.contains(t, "four") )
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- table.flatten() tests
|
||||
--
|
||||
|
||||
function suite.flatten_OnMixedValues()
|
||||
t = { "a", { "b", "c" }, "d" }
|
||||
test.isequal({ "a", "b", "c", "d" }, table.flatten(t))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- table.implode() tests
|
||||
--
|
||||
|
||||
function suite.implode()
|
||||
t = { "one", "two", "three", "four" }
|
||||
test.isequal("[one], [two], [three], [four]", table.implode(t, "[", "]", ", "))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- table.isempty() tests
|
||||
--
|
||||
|
||||
function suite.isempty_ReturnsTrueOnEmpty()
|
||||
test.istrue(table.isempty({}))
|
||||
end
|
||||
|
||||
function suite.isempty_ReturnsFalseOnNotEmpty()
|
||||
test.isfalse(table.isempty({ 1 }))
|
||||
end
|
||||
|
||||
function suite.isempty_ReturnsFalseOnNotEmptyMap()
|
||||
test.isfalse(table.isempty({ name = 'premake' }))
|
||||
end
|
||||
|
||||
function suite.isempty_ReturnsFalseOnNotEmptyMapWithFalseKey()
|
||||
test.isfalse(table.isempty({ [false] = 0 }))
|
||||
end
|
143
Src/external_dependencies/openmpt-trunk/include/genie/tests/base/test_tree.lua
vendored
Normal file
143
Src/external_dependencies/openmpt-trunk/include/genie/tests/base/test_tree.lua
vendored
Normal file
|
@ -0,0 +1,143 @@
|
|||
--
|
||||
-- tests/base/test_tree.lua
|
||||
-- Automated test suite source code tree handling.
|
||||
-- Copyright (c) 2009 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
T.tree = { }
|
||||
local suite = T.tree
|
||||
local tree = premake.tree
|
||||
|
||||
|
||||
--
|
||||
-- Setup/teardown
|
||||
--
|
||||
|
||||
local tr, nodes
|
||||
|
||||
function suite.setup()
|
||||
tr = tree.new()
|
||||
nodes = { }
|
||||
end
|
||||
|
||||
local function getresult()
|
||||
tree.traverse(tr, {
|
||||
onnode = function(node, depth)
|
||||
table.insert(nodes, string.rep(">", depth) .. node.name)
|
||||
end
|
||||
})
|
||||
return table.concat(nodes)
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Tests for tree.new()
|
||||
--
|
||||
|
||||
function suite.NewReturnsObject()
|
||||
test.isnotnil(tr)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Tests for tree.add()
|
||||
--
|
||||
|
||||
function suite.CanAddAtRoot()
|
||||
tree.add(tr, "Root")
|
||||
test.isequal("Root", getresult())
|
||||
end
|
||||
|
||||
function suite.CanAddAtChild()
|
||||
tree.add(tr, "Root/Child")
|
||||
test.isequal("Root>Child", getresult())
|
||||
end
|
||||
|
||||
function suite.CanAddAtGrandchild()
|
||||
tree.add(tr, "Root/Child/Grandchild")
|
||||
test.isequal("Root>Child>>Grandchild", getresult())
|
||||
end
|
||||
|
||||
function suite.SkipsLeadingDotDots()
|
||||
tree.add(tr, "../MyProject/hello")
|
||||
test.isequal("MyProject>hello", getresult())
|
||||
end
|
||||
|
||||
function suite.SkipsInlineDotDots()
|
||||
tree.add(tr, "MyProject/../hello")
|
||||
test.isequal("MyProject>hello", getresult())
|
||||
end
|
||||
|
||||
function suite.AddsNodes_OnDifferentParentLevel()
|
||||
tree.add(tr, "../Common")
|
||||
tree.add(tr, "../../Common")
|
||||
test.isequal(2, #tr.children)
|
||||
test.isequal("Common", tr.children[1].name)
|
||||
test.isequal("Common", tr.children[2].name)
|
||||
test.isequal("../Common", tr.children[1].path)
|
||||
test.isequal("../../Common", tr.children[2].path)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Tests for tree.getlocalpath()
|
||||
--
|
||||
|
||||
function suite.GetLocalPath_ReturnsPath_OnNoParentPath()
|
||||
local c = tree.add(tr, "Root/Child")
|
||||
c.parent.path = nil
|
||||
test.isequal("Root/Child", tree.getlocalpath(c))
|
||||
end
|
||||
|
||||
function suite.GetLocalPath_ReturnsName_OnParentPathSet()
|
||||
local c = tree.add(tr, "Root/Child")
|
||||
test.isequal("Child", tree.getlocalpath(c))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Tests for tree.remove()
|
||||
--
|
||||
|
||||
function suite.Remove_RemovesNodes()
|
||||
local n1 = tree.add(tr, "1")
|
||||
local n2 = tree.add(tr, "2")
|
||||
local n3 = tree.add(tr, "3")
|
||||
tree.remove(n2)
|
||||
local r = ""
|
||||
for _, n in ipairs(tr.children) do r = r .. n.name end
|
||||
test.isequal("13", r)
|
||||
end
|
||||
|
||||
|
||||
function suite.Remove_WorksInTraversal()
|
||||
tree.add(tr, "Root/1")
|
||||
tree.add(tr, "Root/2")
|
||||
tree.add(tr, "Root/3")
|
||||
local r = ""
|
||||
tree.traverse(tr, {
|
||||
onleaf = function(node)
|
||||
r = r .. node.name
|
||||
tree.remove(node)
|
||||
end
|
||||
})
|
||||
test.isequal("123", r)
|
||||
test.isequal(0, #tr.children[1])
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Tests for tree.sort()
|
||||
--
|
||||
|
||||
function suite.Sort_SortsAllLevels()
|
||||
tree.add(tr, "B/3")
|
||||
tree.add(tr, "B/1")
|
||||
tree.add(tr, "A/2")
|
||||
tree.add(tr, "A/1")
|
||||
tree.add(tr, "B/2")
|
||||
tree.sort(tr)
|
||||
test.isequal("A>1>2B>1>2>3", getresult(tr))
|
||||
end
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue