Initial community commit
This commit is contained in:
parent
537bcbc862
commit
fc06254474
16440 changed files with 4239995 additions and 2 deletions
80
Src/external_dependencies/openmpt-trunk/include/premake/tests/api/test_boolean_kind.lua
vendored
Normal file
80
Src/external_dependencies/openmpt-trunk/include/premake/tests/api/test_boolean_kind.lua
vendored
Normal file
|
@ -0,0 +1,80 @@
|
|||
--
|
||||
-- tests/api/test_boolean_kind.lua
|
||||
-- Tests the boolean API value type.
|
||||
-- Copyright (c) 2014 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local p = premake
|
||||
local suite = test.declare("api_boolean_kind")
|
||||
local api = p.api
|
||||
|
||||
|
||||
--
|
||||
-- Setup and teardown
|
||||
--
|
||||
|
||||
function suite.setup()
|
||||
api.register {
|
||||
name = "testapi",
|
||||
kind = "boolean",
|
||||
scope = "project",
|
||||
}
|
||||
test.createWorkspace()
|
||||
end
|
||||
|
||||
function suite.teardown()
|
||||
testapi = nil
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Check setting of true values.
|
||||
--
|
||||
|
||||
function suite.setsTrue_onYes()
|
||||
testapi "yes"
|
||||
test.istrue(api.scope.project.testapi)
|
||||
end
|
||||
|
||||
function suite.setsTrue_onBooleanTrue()
|
||||
testapi (true)
|
||||
test.istrue(api.scope.project.testapi)
|
||||
end
|
||||
|
||||
function suite.setsTrue_onNonZero()
|
||||
testapi (1)
|
||||
test.istrue(api.scope.project.testapi)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Check setting of false values.
|
||||
--
|
||||
|
||||
function suite.setsFalse_onNo()
|
||||
testapi "no"
|
||||
test.isfalse(api.scope.project.testapi)
|
||||
end
|
||||
|
||||
function suite.setsFalse_onBooleanFalse()
|
||||
testapi (false)
|
||||
test.isfalse(api.scope.project.testapi)
|
||||
end
|
||||
|
||||
function suite.setsFalse_onZero()
|
||||
testapi (0)
|
||||
test.isfalse(api.scope.project.testapi)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Raise an error on an invalid string value.
|
||||
--
|
||||
|
||||
function suite.raisesError_onDisallowedValue()
|
||||
ok, err = pcall(function ()
|
||||
testapi "maybe"
|
||||
end)
|
||||
test.isfalse(ok)
|
||||
end
|
94
Src/external_dependencies/openmpt-trunk/include/premake/tests/api/test_containers.lua
vendored
Normal file
94
Src/external_dependencies/openmpt-trunk/include/premake/tests/api/test_containers.lua
vendored
Normal file
|
@ -0,0 +1,94 @@
|
|||
--
|
||||
-- tests/api/test_containers.lua
|
||||
-- Tests the API's workspace() and project() container definitions.
|
||||
-- Copyright (c) 2013-2014 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local p = premake
|
||||
local suite = test.declare("api_containers")
|
||||
local api = p.api
|
||||
|
||||
|
||||
--
|
||||
-- Setup and teardown
|
||||
--
|
||||
|
||||
local wks
|
||||
|
||||
function suite.setup()
|
||||
wks = workspace("MyWorkspace")
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- The first time a name is encountered, a new container should be created.
|
||||
--
|
||||
|
||||
function suite.workspace_createsOnFirstUse()
|
||||
test.isnotnil(p.global.getWorkspace("MyWorkspace"))
|
||||
end
|
||||
|
||||
function suite.project_createsOnFirstUse()
|
||||
project("MyProject")
|
||||
test.isnotnil(test.getproject(wks, "MyProject"))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- When a container is created, it should become the active scope.
|
||||
--
|
||||
|
||||
function suite.workspace_setsActiveScope()
|
||||
test.issame(api.scope.workspace, wks)
|
||||
end
|
||||
|
||||
function suite.project_setsActiveScope()
|
||||
local prj = project("MyProject")
|
||||
test.issame(api.scope.project, prj)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- When container function is called with no arguments, that should
|
||||
-- become the current scope.
|
||||
--
|
||||
|
||||
function suite.workspace_setsActiveScope_onNoArgs()
|
||||
project("MyProject")
|
||||
group("MyGroup")
|
||||
workspace()
|
||||
test.issame(wks, api.scope.workspace)
|
||||
test.isnil(api.scope.project)
|
||||
test.isnil(api.scope.group)
|
||||
end
|
||||
|
||||
function suite.project_setsActiveScope_onNoArgs()
|
||||
local prj = project("MyProject")
|
||||
group("MyGroup")
|
||||
project()
|
||||
test.issame(prj, api.scope.project)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- The "*" name should activate the parent scope.
|
||||
--
|
||||
|
||||
function suite.workspace_onStar()
|
||||
project("MyProject")
|
||||
group("MyGroup")
|
||||
filter("Debug")
|
||||
workspace("*")
|
||||
test.isnil(api.scope.workspace)
|
||||
test.isnil(api.scope.project)
|
||||
test.isnil(api.scope.group)
|
||||
end
|
||||
|
||||
function suite.project_onStar()
|
||||
project("MyProject")
|
||||
group("MyGroup")
|
||||
filter("Debug")
|
||||
project "*"
|
||||
test.issame(wks, api.scope.workspace)
|
||||
test.isnil(api.scope.project)
|
||||
end
|
66
Src/external_dependencies/openmpt-trunk/include/premake/tests/api/test_deprecations.lua
vendored
Normal file
66
Src/external_dependencies/openmpt-trunk/include/premake/tests/api/test_deprecations.lua
vendored
Normal file
|
@ -0,0 +1,66 @@
|
|||
--
|
||||
-- tests/api/test_table_kind.lua
|
||||
-- Tests the table API value type.
|
||||
-- Copyright (c) 2012-2014 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local p = premake
|
||||
local suite = test.declare("api_deprecations")
|
||||
local api = p.api
|
||||
|
||||
|
||||
function suite.setup()
|
||||
workspace("MyWorkspace")
|
||||
configurations { "Debug", "Release" }
|
||||
end
|
||||
|
||||
function suite.setsNewValue_whenOldValueIsRemovedViaWildcard_inSubConfig()
|
||||
local prj = project "MyProject"
|
||||
filter { "configurations:Debug" }
|
||||
flags { "Symbols" }
|
||||
|
||||
filter { "*" }
|
||||
removeflags { "*" }
|
||||
|
||||
-- test output.
|
||||
local cfg = test.getconfig(prj, "Debug", platform)
|
||||
test.isequal("Default", cfg.Symbols)
|
||||
end
|
||||
|
||||
|
||||
function suite.setsNewValue_whenOldValueIsRemovedInOtherConfig_inSubConfig()
|
||||
local prj = project "MyProject"
|
||||
flags { "Symbols" }
|
||||
|
||||
filter { "configurations:Release" }
|
||||
removeflags { "*" }
|
||||
|
||||
-- test output.
|
||||
test.isequal("On", test.getconfig(prj, "Debug", platform).Symbols)
|
||||
test.isequal("Default", test.getconfig(prj, "Release", platform).Symbols)
|
||||
end
|
||||
|
||||
|
||||
function suite.dontRemoveFlagIfSetThroughNewApi()
|
||||
local prj = project "MyProject"
|
||||
floatingpoint "Fast"
|
||||
removeflags "*"
|
||||
|
||||
-- test output.
|
||||
local cfg = test.getconfig(prj, "Debug", platform)
|
||||
test.isequal("Fast", cfg.floatingpoint)
|
||||
end
|
||||
|
||||
|
||||
function suite.setsNewValue_whenOldValueFromParentIsRemovedInOtherConfig_inSubConfig()
|
||||
flags { "Symbols" }
|
||||
|
||||
local prj = project "MyProject"
|
||||
filter { "configurations:Release" }
|
||||
removeflags { "*" }
|
||||
|
||||
-- test output.
|
||||
test.isequal("On", test.getconfig(prj, "Debug", platform).Symbols)
|
||||
test.isequal("Default", test.getconfig(prj, "Release", platform).Symbols)
|
||||
end
|
||||
|
49
Src/external_dependencies/openmpt-trunk/include/premake/tests/api/test_directory_kind.lua
vendored
Normal file
49
Src/external_dependencies/openmpt-trunk/include/premake/tests/api/test_directory_kind.lua
vendored
Normal file
|
@ -0,0 +1,49 @@
|
|||
--
|
||||
-- tests/api/test_directory_kind.lua
|
||||
-- Tests the directory API value type.
|
||||
-- Copyright (c) 2013 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local p = premake
|
||||
local suite = test.declare("api_directory_kind")
|
||||
local api = p.api
|
||||
|
||||
|
||||
--
|
||||
-- Setup and teardown
|
||||
--
|
||||
|
||||
function suite.setup()
|
||||
api.register {
|
||||
name = "testapi",
|
||||
kind = "directory",
|
||||
list = true,
|
||||
scope = "project"
|
||||
}
|
||||
test.createWorkspace()
|
||||
end
|
||||
|
||||
function suite.teardown()
|
||||
testapi = nil
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Values should be converted to absolute paths, relative to
|
||||
-- the currently running script.
|
||||
--
|
||||
|
||||
function suite.convertsToAbsolute()
|
||||
testapi "self/local"
|
||||
test.isequal({os.getcwd() .. "/self/local"}, api.scope.project.testapi)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Check expansion of wildcards.
|
||||
--
|
||||
|
||||
function suite.expandsWildcards()
|
||||
testapi (_TESTS_DIR .. "/*")
|
||||
test.istrue(table.contains(api.scope.project.testapi, _TESTS_DIR .. "/api"))
|
||||
end
|
86
Src/external_dependencies/openmpt-trunk/include/premake/tests/api/test_list_kind.lua
vendored
Normal file
86
Src/external_dependencies/openmpt-trunk/include/premake/tests/api/test_list_kind.lua
vendored
Normal file
|
@ -0,0 +1,86 @@
|
|||
--
|
||||
-- tests/api/test_list_kind.lua
|
||||
-- Tests the list API value type.
|
||||
-- Copyright (c) 2012 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local p = premake
|
||||
local suite = test.declare("api_list_kind")
|
||||
local api = p.api
|
||||
|
||||
|
||||
--
|
||||
-- Setup and teardown
|
||||
--
|
||||
|
||||
function suite.setup()
|
||||
api.register {
|
||||
name = "testapi",
|
||||
kind = "string",
|
||||
list = true,
|
||||
scope = "project",
|
||||
allowed = { "first", "second", "third" }
|
||||
}
|
||||
test.createWorkspace()
|
||||
end
|
||||
|
||||
function suite.teardown()
|
||||
testapi = nil
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Table values should be stored as-is.
|
||||
--
|
||||
|
||||
function suite.storesTable_onArrayValue()
|
||||
testapi { "first", "second" }
|
||||
test.isequal({ "first", "second" }, api.scope.project.testapi)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- String values should be converted into a table.
|
||||
--
|
||||
|
||||
function suite.storesTable_onStringValue()
|
||||
testapi "first"
|
||||
test.isequal({ "first" }, api.scope.project.testapi)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- New values should be appended to any previous values.
|
||||
--
|
||||
|
||||
function suite.overwrites_onNewValue()
|
||||
testapi "first"
|
||||
testapi "second"
|
||||
test.isequal({ "first", "second" }, api.scope.project.testapi)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Nested lists should be flattened.
|
||||
--
|
||||
|
||||
function suite.flattensValues_onNestedLists()
|
||||
testapi { { "first" }, { "second" } }
|
||||
test.isequal({ "first", "second" }, api.scope.project.testapi)
|
||||
end
|
||||
|
||||
--
|
||||
-- If an allowed values list is present, make sure it gets applied.
|
||||
--
|
||||
|
||||
function suite.raisesError_onDisallowedValue()
|
||||
ok, err = pcall(function ()
|
||||
testapi "NotAllowed"
|
||||
end)
|
||||
test.isfalse(ok)
|
||||
end
|
||||
|
||||
function suite.convertsCase_onAllowedValue()
|
||||
testapi "seCOnd"
|
||||
test.isequal({ "second" }, api.scope.project.testapi)
|
||||
end
|
38
Src/external_dependencies/openmpt-trunk/include/premake/tests/api/test_path_kind.lua
vendored
Normal file
38
Src/external_dependencies/openmpt-trunk/include/premake/tests/api/test_path_kind.lua
vendored
Normal file
|
@ -0,0 +1,38 @@
|
|||
--
|
||||
-- tests/api/test_path_kind.lua
|
||||
-- Tests the path API value type.
|
||||
-- Copyright (c) 2012 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local p = premake
|
||||
local suite = test.declare("api_path_kind")
|
||||
local api = p.api
|
||||
|
||||
|
||||
--
|
||||
-- Setup and teardown
|
||||
--
|
||||
|
||||
function suite.setup()
|
||||
api.register {
|
||||
name = "testapi",
|
||||
kind = "path",
|
||||
scope = "project"
|
||||
}
|
||||
test.createWorkspace()
|
||||
end
|
||||
|
||||
function suite.teardown()
|
||||
testapi = nil
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Values should be converted to absolute paths, relative to
|
||||
-- the currently running script.
|
||||
--
|
||||
|
||||
function suite.convertsToAbsolute()
|
||||
testapi "self/local.h"
|
||||
test.isequal(os.getcwd() .. "/self/local.h", api.scope.project.testapi)
|
||||
end
|
88
Src/external_dependencies/openmpt-trunk/include/premake/tests/api/test_register.lua
vendored
Normal file
88
Src/external_dependencies/openmpt-trunk/include/premake/tests/api/test_register.lua
vendored
Normal file
|
@ -0,0 +1,88 @@
|
|||
--
|
||||
-- tests/api/test_register.lua
|
||||
-- Tests the new API registration function.
|
||||
-- Copyright (c) 2012 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local p = premake
|
||||
local suite = test.declare("api_register")
|
||||
local api = p.api
|
||||
|
||||
|
||||
--
|
||||
-- Setup and teardown
|
||||
--
|
||||
|
||||
function suite.teardown()
|
||||
testapi = nil
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Verify that the function exists.
|
||||
--
|
||||
|
||||
function suite.registerFunctionExists()
|
||||
test.isequal("function", type(p.api.register))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- When called, a new function with with provided name should
|
||||
-- added to the global namespace.
|
||||
--
|
||||
|
||||
function suite.createsNewGlobalFunction()
|
||||
api.register { name = "testapi", kind = "string", scope = "project" }
|
||||
test.isequal("function", type(testapi));
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Verify that an error is raised if no name is provided.
|
||||
--
|
||||
|
||||
function suite.raisesError_onMissingName()
|
||||
ok, err = pcall(function ()
|
||||
api.register { kind = "string", scope = "project" }
|
||||
end)
|
||||
test.isfalse(ok)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Verify that an error is raised if the name is already in use.
|
||||
--
|
||||
|
||||
function suite.raisesError_onExistingGlobalName()
|
||||
testapi = "testapi"
|
||||
ok, err = pcall(function ()
|
||||
api.register { name = "testapi", kind = "string", scope = "project" }
|
||||
end)
|
||||
test.isfalse(ok)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Verify that an error is raised if an invalid kind is used.
|
||||
--
|
||||
|
||||
function suite.raisesError_onInvalidKind()
|
||||
ok, err = pcall(function ()
|
||||
api.register { name = "testapi", kind = "bogus", scope = "project" }
|
||||
end)
|
||||
test.isfalse(ok)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Verify that key-value forms are accepted.
|
||||
--
|
||||
|
||||
function suite.succeeds_onKeyValueForm()
|
||||
ok, err = pcall(function ()
|
||||
api.register { name = "testapi", kind = "string", keyed = true, scope = "project" }
|
||||
end)
|
||||
test.istrue(ok)
|
||||
end
|
85
Src/external_dependencies/openmpt-trunk/include/premake/tests/api/test_string_kind.lua
vendored
Normal file
85
Src/external_dependencies/openmpt-trunk/include/premake/tests/api/test_string_kind.lua
vendored
Normal file
|
@ -0,0 +1,85 @@
|
|||
--
|
||||
-- tests/api/test_string_kind.lua
|
||||
-- Tests the string API value type.
|
||||
-- Copyright (c) 2012 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local p = premake
|
||||
local suite = test.declare("api_string_kind")
|
||||
local api = p.api
|
||||
|
||||
|
||||
--
|
||||
-- Setup and teardown
|
||||
--
|
||||
|
||||
function suite.setup()
|
||||
api.register {
|
||||
name = "testapi",
|
||||
kind = "string",
|
||||
scope = "project",
|
||||
allowed = { "One", "Two", "Three" },
|
||||
}
|
||||
test.createWorkspace()
|
||||
end
|
||||
|
||||
function suite.teardown()
|
||||
testapi = nil
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- String values should be stored as-is.
|
||||
--
|
||||
|
||||
function suite.storesString_onStringValue()
|
||||
testapi "One"
|
||||
test.isequal("One", api.scope.project.testapi)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- New values should overwrite old ones.
|
||||
--
|
||||
|
||||
function suite.overwritesPreviousValues()
|
||||
testapi "One"
|
||||
testapi "Two"
|
||||
test.isequal("Two", api.scope.project.testapi)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- An error occurs if a table value is assigned to a string field.
|
||||
--
|
||||
|
||||
function suite.raisesError_onTableValue()
|
||||
ok, err = pcall(function ()
|
||||
testapi { "One", "Two" }
|
||||
end)
|
||||
test.isfalse(ok)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Raises an error on a disallowed value.
|
||||
--
|
||||
|
||||
function suite.raisesError_onDisallowedValue()
|
||||
ok, err = pcall(function ()
|
||||
testapi "NotAllowed"
|
||||
end)
|
||||
test.isfalse(ok)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- If allowed values present, converts to provided case.
|
||||
--
|
||||
|
||||
function suite.convertsCase_onAllowedValue()
|
||||
testapi "oNe"
|
||||
test.isequal("One", api.scope.project.testapi)
|
||||
end
|
||||
|
||||
|
54
Src/external_dependencies/openmpt-trunk/include/premake/tests/api/test_table_kind.lua
vendored
Normal file
54
Src/external_dependencies/openmpt-trunk/include/premake/tests/api/test_table_kind.lua
vendored
Normal file
|
@ -0,0 +1,54 @@
|
|||
--
|
||||
-- tests/api/test_table_kind.lua
|
||||
-- Tests the table API value type.
|
||||
-- Copyright (c) 2012-2014 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local p = premake
|
||||
local suite = test.declare("api_table_kind")
|
||||
local api = p.api
|
||||
|
||||
|
||||
--
|
||||
-- Setup and teardown
|
||||
--
|
||||
|
||||
function suite.setup()
|
||||
api.register { name = "testapi", kind = "table", scope = "project" }
|
||||
test.createWorkspace()
|
||||
end
|
||||
|
||||
function suite.teardown()
|
||||
testapi = nil
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Array values should be stored as-is.
|
||||
--
|
||||
|
||||
function suite.storesTable_onArrayValue()
|
||||
testapi { "one", "two" }
|
||||
test.isequal({ "one", "two" }, api.scope.project.testapi)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- String values should be converted into a table.
|
||||
--
|
||||
|
||||
function suite.storesTable_onStringValue()
|
||||
testapi "myvalue"
|
||||
test.isequal({ "myvalue" }, api.scope.project.testapi)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- New values should overwrite old.
|
||||
--
|
||||
|
||||
function suite.overwrites_onNewValue()
|
||||
testapi "first"
|
||||
testapi "second"
|
||||
test.isequal({ "second" }, api.scope.project.testapi)
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue