Initial community commit
This commit is contained in:
parent
537bcbc862
commit
fc06254474
16440 changed files with 4239995 additions and 2 deletions
1
Src/external_dependencies/openmpt-trunk/include/premake/tests/base/.testDotFile
vendored
Normal file
1
Src/external_dependencies/openmpt-trunk/include/premake/tests/base/.testDotFile
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
This is a test file for os.matchfiles tests.
|
65
Src/external_dependencies/openmpt-trunk/include/premake/tests/base/test_aliasing.lua
vendored
Normal file
65
Src/external_dependencies/openmpt-trunk/include/premake/tests/base/test_aliasing.lua
vendored
Normal file
|
@ -0,0 +1,65 @@
|
|||
--
|
||||
-- tests/base/test_aliasing.lua
|
||||
-- Verify handling of function aliases.
|
||||
-- Copyright (c) 2015 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local suite = test.declare("premake_alias")
|
||||
local m = {}
|
||||
|
||||
local p = premake
|
||||
|
||||
|
||||
function suite.setup()
|
||||
m.testfunc = function()
|
||||
return 48
|
||||
end
|
||||
m.aliased = nil
|
||||
m.aliased2 = nil
|
||||
end
|
||||
|
||||
|
||||
function suite.returnsOriginalFunction_onNoAlias()
|
||||
local scope, f = p.resolveAlias(m, "testfunc")
|
||||
test.isequal("testfunc", f)
|
||||
end
|
||||
|
||||
|
||||
function suite.pointsAliasToOriginalFunction()
|
||||
p.alias(m, "testfunc", "aliased")
|
||||
test.isequal(48, m.aliased())
|
||||
end
|
||||
|
||||
|
||||
function suite.returnsOriginalFunction_onAlias()
|
||||
p.alias(m, "testfunc", "aliased")
|
||||
local scope, f = p.resolveAlias(m, "aliased")
|
||||
test.isequal("testfunc", f)
|
||||
end
|
||||
|
||||
|
||||
function suite.returnsOriginalFunction_onChainedAliases()
|
||||
p.alias(m, "testfunc", "aliased")
|
||||
p.alias(m, "aliased", "aliased2")
|
||||
local scope, f = p.resolveAlias(m, "aliased2")
|
||||
test.isequal("testfunc", f)
|
||||
end
|
||||
|
||||
|
||||
function suite.overrideResolvesAliases()
|
||||
p.alias(m, "testfunc", "aliased")
|
||||
p.override(m, "aliased", function(base)
|
||||
return base() + 1
|
||||
end)
|
||||
test.isequal(49, m.testfunc())
|
||||
end
|
||||
|
||||
|
||||
function suite.aliasTracksOverrides()
|
||||
p.alias(m, "testfunc", "aliased")
|
||||
p.override(m, "testfunc", function(base)
|
||||
return base() + 1
|
||||
end)
|
||||
test.isequal(49, m.aliased())
|
||||
end
|
||||
|
19
Src/external_dependencies/openmpt-trunk/include/premake/tests/base/test_binmodules.lua
vendored
Normal file
19
Src/external_dependencies/openmpt-trunk/include/premake/tests/base/test_binmodules.lua
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
--
|
||||
-- tests/base/test_binmodules.lua
|
||||
-- Verify handling of binary modules.
|
||||
-- Copyright (c) 2017 Tom van Dijck and the Premake project
|
||||
--
|
||||
|
||||
local suite = test.declare("premake_binmodules")
|
||||
local p = premake
|
||||
|
||||
|
||||
function suite.setup()
|
||||
require("example")
|
||||
end
|
||||
|
||||
|
||||
function suite.testExample()
|
||||
local result = example.test("world")
|
||||
test.isequal("hello world", result)
|
||||
end
|
261
Src/external_dependencies/openmpt-trunk/include/premake/tests/base/test_configset.lua
vendored
Normal file
261
Src/external_dependencies/openmpt-trunk/include/premake/tests/base/test_configset.lua
vendored
Normal file
|
@ -0,0 +1,261 @@
|
|||
--
|
||||
-- tests/base/test_configset.lua
|
||||
-- Test suite for the configset API.
|
||||
-- Copyright (c) 2012-2014 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local p = premake
|
||||
local suite = test.declare("configset")
|
||||
local configset = p.configset
|
||||
local field = p.field
|
||||
|
||||
|
||||
--
|
||||
-- Setup and teardown
|
||||
--
|
||||
|
||||
local cset, parentset
|
||||
|
||||
function suite.setup()
|
||||
local wks = test.createWorkspace()
|
||||
parentset = configset.new()
|
||||
cset = configset.new(parentset)
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Make sure that new() returns a valid object.
|
||||
--
|
||||
|
||||
function suite.new_returnsValidObject()
|
||||
test.isequal("table", type(cset))
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Check the default values for different field types.
|
||||
--
|
||||
|
||||
function suite.defaultValue_onString()
|
||||
test.isnil(configset.fetch(cset, field.get("targetextension")))
|
||||
end
|
||||
|
||||
function suite.defaultValue_onList()
|
||||
test.isequal({}, configset.fetch(cset, field.get("defines")))
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Make sure that I can roundtrip a value stored into the
|
||||
-- initial, default configuration.
|
||||
--
|
||||
|
||||
function suite.canRoundtrip_onDefaultBlock()
|
||||
local f = field.get("targetextension")
|
||||
configset.store(cset, f, ".so")
|
||||
test.isequal(".so", configset.fetch(cset, f, {}))
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Make sure that I can roundtrip a value stored into a block
|
||||
-- with a simple matching term.
|
||||
--
|
||||
|
||||
function suite.canRoundtrip_onSimpleTermMatch()
|
||||
local f = field.get("targetextension")
|
||||
configset.addblock(cset, { "Windows" })
|
||||
configset.store(cset, f, ".dll")
|
||||
test.isequal(".dll", configset.fetch(cset, f, { "windows" }))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Make sure that blocks that do not match the context terms
|
||||
-- do not contribute to the result.
|
||||
--
|
||||
|
||||
function suite.skipsBlock_onTermMismatch()
|
||||
local f = field.get("targetextension")
|
||||
configset.store(cset, f, ".so")
|
||||
configset.addblock(cset, { "Windows" })
|
||||
configset.store(cset, f, ".dll")
|
||||
test.isequal(".so", configset.fetch(cset, f, { "linux" }))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Values stored in a parent configuration set should propagate into child.
|
||||
--
|
||||
|
||||
function suite.canRoundtrip_fromParentToChild()
|
||||
local f = field.get("targetextension")
|
||||
configset.store(parentset, f, ".so")
|
||||
test.isequal(".so", configset.fetch(cset, f, {}))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Child should be able to override parent values.
|
||||
--
|
||||
|
||||
function suite.child_canOverrideStringValueFromParent()
|
||||
local f = field.get("targetextension")
|
||||
configset.store(parentset, f, ".so")
|
||||
configset.store(cset, f, ".dll")
|
||||
test.isequal(".dll", configset.fetch(cset, f, {}))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- If a base directory is set, filename tests should be performed
|
||||
-- relative to this path.
|
||||
--
|
||||
|
||||
function suite.filenameMadeRelative_onBaseDirSet()
|
||||
local f = field.get("buildaction")
|
||||
configset.addblock(cset, { "hello.c" }, os.getcwd())
|
||||
configset.store(cset, f, "Copy")
|
||||
test.isequal("Copy", configset.fetch(cset, f, { files=path.join(os.getcwd(), "hello.c"):lower() }))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- List fields should return an empty list of not set.
|
||||
--
|
||||
|
||||
function suite.lists_returnsEmptyTable_onNotSet()
|
||||
test.isequal({}, configset.fetch(cset, field.get("buildoptions"), {}))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- List fields should merge values fetched from different blocks.
|
||||
--
|
||||
|
||||
function suite.lists_mergeValues_onFetch()
|
||||
local f = field.get("buildoptions")
|
||||
configset.store(cset, f, "v1")
|
||||
configset.addblock(cset, { "windows" })
|
||||
configset.store(cset, f, "v2")
|
||||
test.isequal({"v1", "v2"}, configset.fetch(cset, f, {"windows"}))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Multiple adds to a list field in the same block should be merged together.
|
||||
--
|
||||
|
||||
function suite.lists_mergeValues_onAdd()
|
||||
local f = field.get("buildoptions")
|
||||
configset.store(cset, f, "v1")
|
||||
configset.store(cset, f, "v2")
|
||||
test.isequal({"v1", "v2"}, configset.fetch(cset, f, {"windows"}))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Fetched lists should be both keyed and indexed.
|
||||
--
|
||||
|
||||
function suite.lists_includeValueKeys()
|
||||
local f = field.get("buildoptions")
|
||||
configset.store(cset, f, { "v1", "v2" })
|
||||
local x = configset.fetch(cset, f, {})
|
||||
test.isequal("v2", x.v2)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Check removing a value with an exact match.
|
||||
--
|
||||
|
||||
function suite.remove_onExactValueMatch()
|
||||
local f = field.get("flags")
|
||||
|
||||
local r, err = configset.store(cset, f, { "Symbols", "WinMain", "MFC" })
|
||||
test.isnil(err)
|
||||
|
||||
configset.remove(cset, f, { "WinMain" })
|
||||
|
||||
local result = configset.fetch(cset, f)
|
||||
test.isequal({ "Symbols", "MFC" }, result)
|
||||
end
|
||||
|
||||
|
||||
function suite.remove_onMultipleValues()
|
||||
local f = field.get("flags")
|
||||
|
||||
local r, err = configset.store(cset, f, { "Symbols", "Maps", "WinMain", "MFC" })
|
||||
test.isnil(err)
|
||||
|
||||
configset.remove(cset, f, { "Maps", "MFC" })
|
||||
|
||||
local result = configset.fetch(cset, f)
|
||||
test.isequal({ "Symbols", "WinMain" }, result)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Remove should also accept wildcards.
|
||||
--
|
||||
|
||||
function suite.remove_onWildcard()
|
||||
local f = field.get("defines")
|
||||
configset.store(cset, f, { "WIN32", "WIN64", "LINUX", "MACOSX" })
|
||||
configset.remove(cset, f, { "WIN*" })
|
||||
test.isequal({ "LINUX", "MACOSX" }, configset.fetch(cset, f, {}))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Keyed values should merge keys fetched from different blocks.
|
||||
--
|
||||
|
||||
function suite.keyed_mergesKeys_onFetch()
|
||||
local f = field.get("configmap")
|
||||
configset.store(cset, f, { Debug="Debug", Release="Release" })
|
||||
configset.addblock(cset, { "windows" })
|
||||
configset.store(cset, f, { Profile="Profile" })
|
||||
local x = configset.fetch(cset, f, {"windows"})
|
||||
test.istrue(x[1].Debug and x[1].Release and x[2].Profile)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Multiple adds to a keyed value field in the same block should be merged.
|
||||
--
|
||||
|
||||
function suite.keyed_mergesKeys_onAdd()
|
||||
local f = field.get("configmap")
|
||||
configset.store(cset, f, { Debug="Debug", Release="Release" })
|
||||
configset.store(cset, f, { Profile="Profile" })
|
||||
local x = configset.fetch(cset, f, {"windows"})
|
||||
test.istrue(x[1].Debug and x[1].Release and x[2].Profile)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Keyed values should overwrite when non-merged fields are fetched.
|
||||
--
|
||||
|
||||
function suite.keyed_overwritesValues_onNonMergeFetch()
|
||||
local f = field.get("configmap")
|
||||
configset.store(cset, f, { Debug="Debug" })
|
||||
configset.addblock(cset, { "windows" })
|
||||
configset.store(cset, f, { Debug="Development" })
|
||||
local x = configset.fetch(cset, f, {"windows"})
|
||||
test.isequal({"Development"}, x[2].Debug)
|
||||
end
|
||||
|
||||
function suite.keyed_overwritesValues_onNonMergeAdd()
|
||||
local f = field.get("configmap")
|
||||
configset.store(cset, f, { Debug="Debug" })
|
||||
configset.store(cset, f, { Debug="Development" })
|
||||
local x = configset.fetch(cset, f, {"windows"})
|
||||
test.isequal({"Development"}, x[2].Debug)
|
||||
end
|
113
Src/external_dependencies/openmpt-trunk/include/premake/tests/base/test_context.lua
vendored
Normal file
113
Src/external_dependencies/openmpt-trunk/include/premake/tests/base/test_context.lua
vendored
Normal file
|
@ -0,0 +1,113 @@
|
|||
--
|
||||
-- tests/base/test_context.lua
|
||||
-- Test suite for the configuration context API.
|
||||
-- Copyright (c) 2012-2014 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local p = premake
|
||||
local suite = test.declare("context")
|
||||
local context = p.context
|
||||
local configset = p.configset
|
||||
local field = p.field
|
||||
|
||||
|
||||
--
|
||||
-- Setup and teardown
|
||||
--
|
||||
|
||||
local ctx, cset
|
||||
|
||||
function suite.setup()
|
||||
cset = configset.new()
|
||||
ctx = context.new(cset)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Make sure that new() returns a valid object.
|
||||
--
|
||||
|
||||
function suite.new_returnsValidObject()
|
||||
test.isequal("table", type(ctx))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Context should be able to retrieve a default value from
|
||||
-- the configuration set, using the field name.
|
||||
--
|
||||
|
||||
function suite.returnsConfigValue_onExistingValue()
|
||||
configset.store(cset, field.get("targetextension"), ".so")
|
||||
test.isequal(".so", ctx.targetextension)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Tokens encountered in enabled fields should be expanded.
|
||||
--
|
||||
|
||||
function suite.doesExpandTokens()
|
||||
configset.store(cset, field.get("targetname"), "MyProject%{1 + 1}")
|
||||
test.isequal("MyProject2", ctx.targetname)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Token environment in extended context overrides context.
|
||||
--
|
||||
|
||||
function suite.extent()
|
||||
-- set in toplevel context.
|
||||
configset.store(cset, field.get("targetname"), "%{value}")
|
||||
|
||||
-- detoken in toplevel context should result in empty string.
|
||||
test.isequal("", ctx.targetname)
|
||||
|
||||
-- create an extended context with a local environ.
|
||||
local environ = {
|
||||
value = "text"
|
||||
}
|
||||
local ext = context.extent(ctx, environ)
|
||||
|
||||
-- detoken in extended context should result in value set in that environ.
|
||||
test.isequal("text", ext.targetname)
|
||||
end
|
||||
|
||||
--
|
||||
-- mergeFilters should behave as expected for tags
|
||||
--
|
||||
|
||||
function suite.mergeFilters()
|
||||
|
||||
ctx = { terms = { tags = { "ctxtags" } } }
|
||||
src = { terms = { tags = { "srctags" } } }
|
||||
|
||||
context.mergeFilters(ctx, src)
|
||||
|
||||
result = { terms = { tags = { "ctxtags", "srctags" } } }
|
||||
|
||||
test.isequal(result, ctx)
|
||||
end
|
||||
|
||||
function suite.mergeFilters_keeptype()
|
||||
|
||||
ctx = { terms = { kind = "ConsoleApp" } }
|
||||
src = { terms = { kind = "ConsoleApp" } }
|
||||
|
||||
context.mergeFilters(ctx, src)
|
||||
|
||||
test.isequal("string", type(ctx.terms.kind))
|
||||
end
|
||||
|
||||
function suite.mergeFilters_createtable()
|
||||
|
||||
ctx = { terms = { tags = "ctxtags" } }
|
||||
src = { terms = { tags = "srctags" } }
|
||||
|
||||
context.mergeFilters(ctx, src)
|
||||
|
||||
result = { terms = { tags = { "ctxtags", "srctags" } } }
|
||||
|
||||
test.isequal(result, ctx)
|
||||
end
|
362
Src/external_dependencies/openmpt-trunk/include/premake/tests/base/test_criteria.lua
vendored
Normal file
362
Src/external_dependencies/openmpt-trunk/include/premake/tests/base/test_criteria.lua
vendored
Normal file
|
@ -0,0 +1,362 @@
|
|||
--
|
||||
-- tests/base/test_criteria.lua
|
||||
-- Test suite for the criteria matching API.
|
||||
-- Copyright (c) 2012-2015 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local p = premake
|
||||
local suite = test.declare("criteria")
|
||||
local criteria = p.criteria
|
||||
|
||||
|
||||
--
|
||||
-- Setup and teardown
|
||||
--
|
||||
|
||||
local crit
|
||||
|
||||
|
||||
--
|
||||
-- A criteria with no terms should satisfy any context.
|
||||
--
|
||||
|
||||
function suite.matches_alwaysTrue_onNoFilterTerms()
|
||||
crit = criteria.new {}
|
||||
test.istrue(criteria.matches(crit, { configurations="Debug", system="Windows" }))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Should not match if any term is missing in the context.
|
||||
--
|
||||
|
||||
function suite.matches_fails_onMissingContext()
|
||||
crit = criteria.new { "system:Windows", "architecture:x86" }
|
||||
test.isfalse(criteria.matches(crit, { configurations="Debug", system="Windows" }))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Context terms must match the entire criteria term.
|
||||
--
|
||||
|
||||
function suite.matches_fails_onIncompleteTermMatch()
|
||||
crit = criteria.new { "platforms:win64" }
|
||||
test.isfalse(criteria.matches(crit, { platforms="win64 dll dcrt" }))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Wildcard matches should work.
|
||||
--
|
||||
|
||||
function suite.matches_passes_onPatternMatch()
|
||||
crit = criteria.new { "action:vs*" }
|
||||
test.istrue(criteria.matches(crit, { action="vs2005" }))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- The "not" modifier should fail the test if the term is matched.
|
||||
--
|
||||
|
||||
function suite.matches_fails_onMatchWithNotModifier_afterPrefix()
|
||||
crit = criteria.new { "system:not windows" }
|
||||
test.isfalse(criteria.matches(crit, { system="windows" }))
|
||||
end
|
||||
|
||||
function suite.matches_fails_onMatchWithNotModifier_beforePrefix()
|
||||
crit = criteria.new { "not system:windows" }
|
||||
test.isfalse(criteria.matches(crit, { system="windows" }))
|
||||
end
|
||||
|
||||
function suite.matches_passes_onMissWithNotModifier_afterPrefix()
|
||||
crit = criteria.new { "system:not windows" }
|
||||
test.istrue(criteria.matches(crit, { system="linux" }))
|
||||
end
|
||||
|
||||
function suite.matches_passes_onMissWithNotModifier_beforePrefix()
|
||||
crit = criteria.new { "not system:windows" }
|
||||
test.istrue(criteria.matches(crit, { system="linux" }))
|
||||
end
|
||||
|
||||
function suite.matches_passes_onMissWithNotModifier_noPrefix()
|
||||
crit = criteria.new { "not debug" }
|
||||
test.istrue(criteria.matches(crit, { configurations="release" }))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- The "or" modifier should pass if either term is present.
|
||||
--
|
||||
|
||||
function suite.matches_passes_onFirstOrTermMatched()
|
||||
crit = criteria.new { "system:windows or linux" }
|
||||
test.istrue(criteria.matches(crit, { system="windows" }))
|
||||
end
|
||||
|
||||
function suite.matches_passes_onSecondOrTermMatched()
|
||||
crit = criteria.new { "system:windows or linux" }
|
||||
test.istrue(criteria.matches(crit, { system="linux" }))
|
||||
end
|
||||
|
||||
function suite.matches_passes_onThirdOrTermMatched()
|
||||
crit = criteria.new { "system:windows or linux or vs2005" }
|
||||
test.istrue(criteria.matches(crit, { system="vs2005" }))
|
||||
end
|
||||
|
||||
function suite.matches_fails_onNoOrTermMatched()
|
||||
crit = criteria.new { "system:windows or linux" }
|
||||
test.isfalse(criteria.matches(crit, { system="vs2005" }))
|
||||
end
|
||||
|
||||
function suite.matches_passes_onMixedPrefixes_firstTermMatched_projectContext()
|
||||
crit = criteria.new { "system:windows or files:core*" }
|
||||
test.istrue(criteria.matches(crit, { system="windows" }))
|
||||
end
|
||||
|
||||
function suite.matches_fails_onMixedPrefixes_firstTermMatched_fileContext()
|
||||
crit = criteria.new { "system:windows or files:core*" }
|
||||
test.isfalse(criteria.matches(crit, { system="windows", files="hello.cpp" }))
|
||||
end
|
||||
|
||||
function suite.matches_passes_onMixedPrefixes_secondTermMatched()
|
||||
crit = criteria.new { "system:windows or files:core*" }
|
||||
test.istrue(criteria.matches(crit, { system="linux", files="coregraphics.cpp" }))
|
||||
end
|
||||
|
||||
function suite.matches_fails_onMixedPrefixes_noTermMatched()
|
||||
crit = criteria.new { "system:windows or files:core*" }
|
||||
test.isfalse(criteria.matches(crit, { system="linux", files="hello.cpp" }))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- The "not" modifier should fail on any match with an "or" modifier.
|
||||
--
|
||||
|
||||
function suite.matches_passes_onNotOrMatchesFirst()
|
||||
crit = criteria.new { "system:not windows or linux" }
|
||||
test.isfalse(criteria.matches(crit, { system="windows" }))
|
||||
end
|
||||
|
||||
function suite.matches_passes_onNotOrMatchesSecond()
|
||||
crit = criteria.new { "system:windows or not linux" }
|
||||
test.isfalse(criteria.matches(crit, { system="linux" }))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- The "not" modifier should succeed with "or" if there are no matches.
|
||||
--
|
||||
|
||||
function suite.matches_passes_onNoNotMatch()
|
||||
crit = criteria.new { "system:not windows or linux" }
|
||||
test.istrue(criteria.matches(crit, { system="macosx" }))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- If the context specifies a filename, the filter must match it explicitly.
|
||||
--
|
||||
|
||||
function suite.matches_passes_onFilenameAndMatchingPattern()
|
||||
crit = criteria.new { "files:**.c", "system:windows" }
|
||||
test.istrue(criteria.matches(crit, { system="windows", files="hello.c" }))
|
||||
end
|
||||
|
||||
function suite.matches_fails_onFilenameAndNoMatchingPattern()
|
||||
crit = criteria.new { "system:windows" }
|
||||
test.isfalse(criteria.matches(crit, { system="windows", files="hello.c" }))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Test criteria creation through a table.
|
||||
--
|
||||
|
||||
function suite.createCriteriaWithTable()
|
||||
crit = criteria.new {
|
||||
files = { "**.c" },
|
||||
system = "windows"
|
||||
}
|
||||
test.istrue(criteria.matches(crit, { system="windows", files="hello.c" }))
|
||||
end
|
||||
|
||||
function suite.createCriteriaWithTable2()
|
||||
crit = criteria.new {
|
||||
system = "not windows"
|
||||
}
|
||||
test.isfalse(criteria.matches(crit, { system="windows" }))
|
||||
end
|
||||
|
||||
function suite.createCriteriaWithTable3()
|
||||
crit = criteria.new {
|
||||
system = "not windows or linux"
|
||||
}
|
||||
test.istrue(criteria.matches(crit, { system="macosx" }))
|
||||
end
|
||||
|
||||
function suite.createCriteriaWithTable4()
|
||||
crit = criteria.new {
|
||||
system = "windows or linux"
|
||||
}
|
||||
test.istrue(criteria.matches(crit, { system="windows" }))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- "Not" modifiers can also be used on filenames.
|
||||
--
|
||||
|
||||
function suite.matches_passes_onFilenameMissAndNotModifier()
|
||||
crit = criteria.new { "files:not **.c", "system:windows" }
|
||||
test.istrue(criteria.matches(crit, { system="windows", files="hello.h" }))
|
||||
end
|
||||
|
||||
function suite.matches_fails_onFilenameHitAndNotModifier()
|
||||
crit = criteria.new { "files:not **.c", "system:windows" }
|
||||
test.isfalse(criteria.matches(crit, { system="windows", files="hello.c" }))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- If context provides a list of values, match against them.
|
||||
--
|
||||
|
||||
function suite.matches_passes_termMatchesList()
|
||||
crit = criteria.new { "options:debug" }
|
||||
test.istrue(criteria.matches(crit, { options={ "debug", "logging" }}))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- If no prefix is specified, default to "configurations".
|
||||
--
|
||||
|
||||
function suite.matches_usesDefaultPrefix_onSingleTerm()
|
||||
crit = criteria.new { "debug" }
|
||||
test.istrue(criteria.matches(crit, { configurations="debug" }))
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- These tests use the older, unprefixed style of filter terms. This
|
||||
-- approach will get phased out eventually, but are still included here
|
||||
-- for backward compatibility testing.
|
||||
--
|
||||
|
||||
function suite.matches_onEmptyCriteria_Unprefixed()
|
||||
crit = criteria.new({}, true)
|
||||
test.istrue(criteria.matches(crit, { "apple", "orange" }))
|
||||
end
|
||||
|
||||
function suite.fails_onMissingContext_Unprefixed()
|
||||
crit = criteria.new({ "orange", "pear" }, true)
|
||||
test.isfalse(criteria.matches(crit, { "apple", "orange" }))
|
||||
end
|
||||
|
||||
function suite.fails_onIncompleteMatch_Unprefixed()
|
||||
crit = criteria.new({ "win64" }, true)
|
||||
test.isfalse(criteria.matches(crit, { "win64 dll dcrt" }))
|
||||
end
|
||||
|
||||
function suite.passes_onPatternMatch_Unprefixed()
|
||||
crit = criteria.new({ "vs*" }, true)
|
||||
test.istrue(criteria.matches(crit, { "vs2005" }))
|
||||
end
|
||||
|
||||
function suite.fails_onNotMatch_Unprefixed()
|
||||
crit = criteria.new({ "not windows" }, true)
|
||||
test.isfalse(criteria.matches(crit, { "windows" }))
|
||||
end
|
||||
|
||||
function suite.passes_onNotUnmatched_Unprefixed()
|
||||
crit = criteria.new({ "not windows" }, true)
|
||||
test.istrue(criteria.matches(crit, { "linux" }))
|
||||
end
|
||||
|
||||
function suite.passes_onFirstOrTermMatched_Unprefixed()
|
||||
crit = criteria.new({ "windows or linux" }, true)
|
||||
test.istrue(criteria.matches(crit, { "windows" }))
|
||||
end
|
||||
|
||||
function suite.passes_onSecondOrTermMatched_Unprefixed()
|
||||
crit = criteria.new({ "windows or linux" }, true)
|
||||
test.istrue(criteria.matches(crit, { "linux" }))
|
||||
end
|
||||
|
||||
function suite.passes_onThirdOrTermMatched_Unprefixed()
|
||||
crit = criteria.new({ "windows or linux or vs2005" }, true)
|
||||
test.istrue(criteria.matches(crit, { "vs2005" }))
|
||||
end
|
||||
|
||||
function suite.fails_onNoOrTermMatched_Unprefixed()
|
||||
crit = criteria.new({ "windows or linux" }, true)
|
||||
test.isfalse(criteria.matches(crit, { "vs2005" }))
|
||||
end
|
||||
|
||||
function suite.passes_onNotOrMatchesFirst_Unprefixed()
|
||||
crit = criteria.new({ "not windows or linux" }, true)
|
||||
test.isfalse(criteria.matches(crit, { "windows" }))
|
||||
end
|
||||
|
||||
function suite.passes_onNotOrMatchesSecond_Unprefixed()
|
||||
crit = criteria.new({ "windows or not linux" }, true)
|
||||
test.isfalse(criteria.matches(crit, { "linux" }))
|
||||
end
|
||||
|
||||
function suite.passes_onNoNotMatch_Unprefixed()
|
||||
crit = criteria.new({ "not windows or linux" }, true)
|
||||
test.istrue(criteria.matches(crit, { "macosx" }))
|
||||
end
|
||||
|
||||
function suite.passes_onFilenameAndMatchingPattern_Unprefixed()
|
||||
crit = criteria.new({ "**.c", "windows" }, true)
|
||||
test.istrue(criteria.matches(crit, { system="windows", files="hello.c" }))
|
||||
end
|
||||
|
||||
function suite.fails_onFilenameAndNoMatchingPattern_Unprefixed()
|
||||
crit = criteria.new({ "windows" }, true)
|
||||
test.isfalse(criteria.matches(crit, { system="windows", files="hello.c" }))
|
||||
end
|
||||
|
||||
function suite.fails_onFilenameAndNotModifier_Unprefixed()
|
||||
crit = criteria.new({ "not linux" }, true)
|
||||
test.isfalse(criteria.matches(crit, { system="windows", files="hello.c" }))
|
||||
end
|
||||
|
||||
function suite.matches_passes_termMatchesList_Unprefixed()
|
||||
crit = criteria.new({ "debug" }, true)
|
||||
test.istrue(criteria.matches(crit, { options={ "debug", "logging" }}))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Should return nil and an error message on an invalid prefix.
|
||||
--
|
||||
|
||||
function suite.returnsNilAndError_onInvalidPrefix()
|
||||
crit, err = criteria.new { "gibble:Debug" }
|
||||
test.isnil(crit)
|
||||
test.isnotnil(err)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Should respect field value aliases, if present.
|
||||
--
|
||||
|
||||
function suite.passes_onAliasedValue()
|
||||
p.api.addAliases("system", { ["gnu-linux"] = "linux" })
|
||||
crit = criteria.new { "system:gnu-linux" }
|
||||
test.istrue(criteria.matches(crit, { system="linux" }))
|
||||
end
|
||||
|
||||
function suite.passes_onAliasedValue_withMixedCase()
|
||||
p.api.addAliases("system", { ["gnu-linux"] = "linux" })
|
||||
crit = criteria.new { "System:GNU-Linux" }
|
||||
test.istrue(criteria.matches(crit, { system="linux" }))
|
||||
end
|
||||
|
170
Src/external_dependencies/openmpt-trunk/include/premake/tests/base/test_detoken.lua
vendored
Normal file
170
Src/external_dependencies/openmpt-trunk/include/premake/tests/base/test_detoken.lua
vendored
Normal file
|
@ -0,0 +1,170 @@
|
|||
--
|
||||
-- tests/base/test_detoken.lua
|
||||
-- Test suite for the token expansion API.
|
||||
-- Copyright (c) 2011-2014 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local p = premake
|
||||
local suite = test.declare("detoken")
|
||||
local detoken = p.detoken
|
||||
|
||||
|
||||
--
|
||||
-- Setup
|
||||
--
|
||||
|
||||
local x, action
|
||||
local environ = {}
|
||||
|
||||
function suite.setup()
|
||||
action = p.action.get("test")
|
||||
end
|
||||
|
||||
function suite.teardown()
|
||||
action.pathVars = nil
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- The contents of the token should be executed and the results returned.
|
||||
--
|
||||
|
||||
function suite.executesTokenContents()
|
||||
x = detoken.expand("MyProject%{1+1}", environ)
|
||||
test.isequal("MyProject2", x)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- If the value contains more than one token, then should all be expanded.
|
||||
--
|
||||
|
||||
function suite.expandsMultipleTokens()
|
||||
x = detoken.expand("MyProject%{'X'}and%{'Y'}and%{'Z'}", environ)
|
||||
test.isequal("MyProjectXandYandZ", x)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- If the token replacement values contain tokens themselves, those
|
||||
-- should also get expanded.
|
||||
--
|
||||
|
||||
function suite.expandsNestedTokens()
|
||||
environ.wks = { name="MyWorkspace%{'X'}" }
|
||||
x = detoken.expand("%{wks.name}", environ)
|
||||
test.isequal("MyWorkspaceX", x)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Verify that the global namespace is still accessible.
|
||||
--
|
||||
|
||||
function suite.canUseGlobalFunctions()
|
||||
x = detoken.expand("%{iif(true, 'a', 'b')}", environ)
|
||||
test.isequal("a", x)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- If a path field contains a token, and if that token expands to an
|
||||
-- absolute path itself, that should be returned as the new value.
|
||||
--
|
||||
|
||||
function suite.canExpandToAbsPath()
|
||||
environ.cfg = { basedir = os.getcwd() }
|
||||
x = detoken.expand("bin/debug/%{cfg.basedir}", environ, {paths=true})
|
||||
test.isequal(os.getcwd(), x)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- If a non-path field contains a token that expands to a path, that
|
||||
-- path should be converted to a relative value.
|
||||
--
|
||||
|
||||
function suite.canExpandToRelPath()
|
||||
local cwd = os.getcwd()
|
||||
environ.cfg = { basedir = path.getdirectory(cwd) }
|
||||
x = detoken.expand("cd %{cfg.basedir}", environ, {}, cwd)
|
||||
test.isequal("cd ..", x)
|
||||
end
|
||||
|
||||
--
|
||||
-- but not if it is prefixed with a !
|
||||
--
|
||||
|
||||
function suite.canExpandWithExclamationMark()
|
||||
local cwd = os.getcwd()
|
||||
environ.cfg = { basedir = path.getdirectory(cwd) }
|
||||
x = detoken.expand("%{!cfg.basedir}", environ, {}, cwd)
|
||||
test.isequal(path.getdirectory(os.getcwd()), x)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- If a path field contains a token that expands to a deferred join,
|
||||
-- it should be resolved before performing detoken.
|
||||
--
|
||||
|
||||
function suite.canExpandWithDeferredJoin()
|
||||
local cwd = os.getcwd()
|
||||
x = detoken.expand(path.deferredjoin(os.getcwd(), "%{_ACTION}"), environ, {}, cwd)
|
||||
test.isequal(os.getcwd() .. "/test", x)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- If the value being expanded is a table, iterate over all of its values.
|
||||
--
|
||||
|
||||
function suite.expandsAllItemsInList()
|
||||
x = detoken.expand({ "A%{1}", "B%{2}", "C%{3}" }, environ)
|
||||
test.isequal({ "A1", "B2", "C3" }, x)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- If the field being expanded supports path variable mapping, and the
|
||||
-- action provides a map, replace tokens with the mapped values.
|
||||
--
|
||||
|
||||
function suite.replacesToken_onSupportedAndMapped()
|
||||
action.pathVars = { ["cfg.objdir"] = { absolute = true, token = "$(IntDir)" }, }
|
||||
x = detoken.expand("cmd %{cfg.objdir}/file", environ, {pathVars=true})
|
||||
test.isequal("cmd $(IntDir)/file", x)
|
||||
end
|
||||
|
||||
function suite.replacesToken_onSupportedAndMapped_inAbsPath()
|
||||
action.pathVars = { ["cfg.objdir"] = { absolute = true, token = "$(IntDir)" }, }
|
||||
x = detoken.expand(os.getcwd() .. "/%{cfg.objdir}/file", environ, {paths=true,pathVars=true})
|
||||
test.isequal("$(IntDir)/file", x)
|
||||
end
|
||||
|
||||
function suite.replacesToken_onSupportedAndMapped_inRelPath()
|
||||
action.pathVars = { ["cfg.objdir"] = { absolute = false, token = "$(IntDir)" }, }
|
||||
x = detoken.expand(os.getcwd() .. "/%{cfg.objdir}/file", environ, {paths=true,pathVars=true})
|
||||
test.isequal(os.getcwd() .. "/$(IntDir)/file", x)
|
||||
end
|
||||
|
||||
--
|
||||
-- Escapes backslashes correctly.
|
||||
--
|
||||
|
||||
function suite.escapesBackslashes()
|
||||
environ.foo = "some/path"
|
||||
x = detoken.expand("%{foo:gsub('/', '\\')}", environ)
|
||||
test.isequal("some\\path", x)
|
||||
end
|
||||
|
||||
--
|
||||
-- Escapes backslashes correctly, but not outside tokens.
|
||||
--
|
||||
|
||||
function suite.escapesBackslashes2()
|
||||
environ.foo = "some/path"
|
||||
x = detoken.expand("%{foo:gsub('/', '\\')}\\already\\escaped", environ)
|
||||
test.isequal("some\\path\\already\\escaped", x)
|
||||
end
|
99
Src/external_dependencies/openmpt-trunk/include/premake/tests/base/test_filename.lua
vendored
Normal file
99
Src/external_dependencies/openmpt-trunk/include/premake/tests/base/test_filename.lua
vendored
Normal file
|
@ -0,0 +1,99 @@
|
|||
--
|
||||
-- tests/base/test_filename.lua
|
||||
-- Verify generation of project/workspace/rule filenames.
|
||||
-- Copyright (c) 2008-2014 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local suite = test.declare("project_filename")
|
||||
|
||||
local p = premake
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Setup
|
||||
--
|
||||
|
||||
local wks
|
||||
|
||||
function suite.setup()
|
||||
wks = test.createWorkspace()
|
||||
end
|
||||
|
||||
local function prepare()
|
||||
prj = test.getproject(wks, 1)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Should return name as an absolute path.
|
||||
--
|
||||
|
||||
function suite.isAbsolutePath()
|
||||
prepare()
|
||||
test.isequal(os.getcwd(), path.getdirectory(p.filename(prj)))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Should use the project name, if no filename was specified.
|
||||
--
|
||||
|
||||
function suite.isProjectName_onNoFilename()
|
||||
prepare()
|
||||
test.isequal("MyProject", path.getname(p.filename(prj)))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Should use filename, if set via API.
|
||||
--
|
||||
|
||||
function suite.doesUseFilename()
|
||||
filename "Howdy"
|
||||
prepare()
|
||||
test.isequal("Howdy", path.getname(p.filename(prj)))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Appends file extension, if supplied.
|
||||
--
|
||||
|
||||
function suite.doesUseExtension()
|
||||
prepare()
|
||||
test.isequal(".xc", path.getextension(p.filename(prj, ".xc")))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Should also work with workspaces.
|
||||
--
|
||||
|
||||
function suite.worksWithWorkspace()
|
||||
prepare()
|
||||
test.isequal("MyWorkspace", path.getname(p.filename(wks)))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Value should not propagate down to projects.
|
||||
--
|
||||
|
||||
function suite.doesNotPropagate()
|
||||
workspace ("MyWorkspace")
|
||||
filename ("Howdy")
|
||||
prepare()
|
||||
test.isequal("MyProject", path.getname(p.filename(prj)))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- If extension is provided without a leading dot, it should override any
|
||||
-- project filename.
|
||||
--
|
||||
|
||||
function suite.canOverrideFilename()
|
||||
prepare()
|
||||
test.isequal("Makefile", path.getname(p.filename(prj, "Makefile")))
|
||||
end
|
85
Src/external_dependencies/openmpt-trunk/include/premake/tests/base/test_http.lua
vendored
Normal file
85
Src/external_dependencies/openmpt-trunk/include/premake/tests/base/test_http.lua
vendored
Normal file
|
@ -0,0 +1,85 @@
|
|||
--
|
||||
-- tests/base/test_http.lua
|
||||
-- Tests the http API
|
||||
-- Copyright (c) 2016, 2020 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
if http.get ~= nil and _OPTIONS["test-all"] then
|
||||
local p = premake
|
||||
|
||||
local suite = test.declare("premake_http")
|
||||
|
||||
|
||||
function suite.http_get()
|
||||
local result, err = http.get("http://httpbin.org/user-agent")
|
||||
if result then
|
||||
p.out(result)
|
||||
test.capture(
|
||||
'{"user-agent": "Premake/' .. _PREMAKE_VERSION .. '"}'
|
||||
)
|
||||
else
|
||||
test.fail(err);
|
||||
end
|
||||
end
|
||||
|
||||
function suite.https_get()
|
||||
-- sslverifypeer = 0, so we can test from within companies like here at Blizzard where all HTTPS traffic goes through
|
||||
-- some strange black box that re-signs all traffic with a custom ssl certificate.
|
||||
local result, err = http.get("https://httpbin.org/user-agent", { sslverifypeer = 0 })
|
||||
if result then
|
||||
p.out(result)
|
||||
test.capture(
|
||||
'{"user-agent": "Premake/' .. _PREMAKE_VERSION .. '"}'
|
||||
)
|
||||
else
|
||||
test.fail(err);
|
||||
end
|
||||
end
|
||||
|
||||
function suite.https_get_verify_peer()
|
||||
local result, err = http.get("https://httpbin.org/user-agent")
|
||||
if result then
|
||||
p.out(result)
|
||||
test.capture(
|
||||
'{"user-agent": "Premake/' .. _PREMAKE_VERSION .. '"}'
|
||||
)
|
||||
else
|
||||
test.fail(err);
|
||||
end
|
||||
end
|
||||
|
||||
function suite.http_responsecode()
|
||||
local result, err, responseCode = http.get("http://httpbin.org/status/418")
|
||||
test.isequal(responseCode, 418)
|
||||
end
|
||||
|
||||
-- Disable as httpbin.org returns 404 on this endpoint
|
||||
-- See: https://github.com/postmanlabs/httpbin/issues/617
|
||||
|
||||
--[[
|
||||
function suite.http_redirect()
|
||||
local result, err, responseCode = http.get("http://httpbin.org/redirect/3")
|
||||
if result then
|
||||
test.isequal(responseCode, 200)
|
||||
else
|
||||
test.fail(err);
|
||||
end
|
||||
end
|
||||
]]
|
||||
|
||||
function suite.http_headers()
|
||||
local result, err, responseCode = http.get("http://httpbin.org/headers", {
|
||||
headers = { 'X-Premake: premake' }
|
||||
})
|
||||
|
||||
if result then
|
||||
if (not result:find('X-Premake')) then
|
||||
test.fail("response doens't contain header")
|
||||
test.print(result)
|
||||
end
|
||||
else
|
||||
test.fail(err);
|
||||
end
|
||||
end
|
||||
|
||||
end
|
67
Src/external_dependencies/openmpt-trunk/include/premake/tests/base/test_include.lua
vendored
Normal file
67
Src/external_dependencies/openmpt-trunk/include/premake/tests/base/test_include.lua
vendored
Normal file
|
@ -0,0 +1,67 @@
|
|||
--
|
||||
-- tests/base/test_include.lua
|
||||
-- Test the include() function, for including external scripts
|
||||
-- Copyright (c) 2011-2014 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
|
||||
local p = premake
|
||||
local suite = test.declare("include")
|
||||
|
||||
|
||||
--
|
||||
-- Setup and teardown
|
||||
--
|
||||
|
||||
function suite.teardown()
|
||||
-- clear the list of included files after each run
|
||||
io._includedFiles = { }
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Tests
|
||||
--
|
||||
|
||||
function suite.include_findsPremakeFile_onFolderNameOnly()
|
||||
include (_TESTS_DIR .. "/folder")
|
||||
test.isequal("ok", p.captured())
|
||||
end
|
||||
|
||||
|
||||
function suite.include_onExactFilename()
|
||||
include (_TESTS_DIR .. "/folder/premake5.lua")
|
||||
test.isequal("ok", p.captured())
|
||||
end
|
||||
|
||||
|
||||
function suite.include_runsOnlyOnce_onMultipleIncludes()
|
||||
include (_TESTS_DIR .. "/folder/premake5.lua")
|
||||
include (_TESTS_DIR .. "/folder/premake5.lua")
|
||||
test.isequal("ok", p.captured())
|
||||
end
|
||||
|
||||
|
||||
function suite.include_runsOnlyOnce_onMultipleIncludesWithDifferentPaths()
|
||||
include (_TESTS_DIR .. "/folder/premake5.lua")
|
||||
include (_TESTS_DIR .. "/../tests/folder/premake5.lua")
|
||||
test.isequal("ok", p.captured())
|
||||
end
|
||||
|
||||
function suite.includeexternal_runs()
|
||||
includeexternal (_TESTS_DIR .. "/folder/premake5.lua")
|
||||
test.isequal("ok", p.captured())
|
||||
end
|
||||
|
||||
function suite.includeexternal_runsAfterInclude()
|
||||
include (_TESTS_DIR .. "/folder/premake5.lua")
|
||||
includeexternal (_TESTS_DIR .. "/folder/premake5.lua")
|
||||
test.isequal("okok", p.captured())
|
||||
end
|
||||
|
||||
function suite.includeexternal_runsTwiceAfterInclude()
|
||||
include (_TESTS_DIR .. "/folder/premake5.lua")
|
||||
includeexternal (_TESTS_DIR .. "/folder/premake5.lua")
|
||||
includeexternal (_TESTS_DIR .. "/folder/premake5.lua")
|
||||
test.isequal("okokok", p.captured())
|
||||
end
|
32
Src/external_dependencies/openmpt-trunk/include/premake/tests/base/test_json.lua
vendored
Normal file
32
Src/external_dependencies/openmpt-trunk/include/premake/tests/base/test_json.lua
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
--
|
||||
-- tests/base/test_json.lua
|
||||
-- Tests the json API
|
||||
-- Copyright (c) 2017 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local p = premake
|
||||
|
||||
local suite = test.declare("premake_json")
|
||||
|
||||
function suite.json_encode()
|
||||
local result = json.encode({foo = "bar"})
|
||||
result = result:gsub('%s*', ''),
|
||||
test.isequal(result, '{"foo":"bar"}')
|
||||
end
|
||||
|
||||
function suite.json_decode()
|
||||
local result = json.decode('{ "foo": "bar" }')
|
||||
test.isequal(result, { foo = "bar" })
|
||||
end
|
||||
|
||||
function suite.json_encode_error()
|
||||
local result, err = json.encode({ fubar = function() end })
|
||||
test.isnil(result)
|
||||
test.isequal(type(err), "string")
|
||||
end
|
||||
|
||||
function suite.json_decode_error()
|
||||
local result, err = json.decode("fubar string")
|
||||
test.isnil(result)
|
||||
test.isequal(type(err), "string")
|
||||
end
|
38
Src/external_dependencies/openmpt-trunk/include/premake/tests/base/test_module_loader.lua
vendored
Normal file
38
Src/external_dependencies/openmpt-trunk/include/premake/tests/base/test_module_loader.lua
vendored
Normal file
|
@ -0,0 +1,38 @@
|
|||
--
|
||||
-- tests/base/test_module_loader.lua
|
||||
-- Test the custom module loader.
|
||||
-- Copyright (c) 2012-2015 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local p = premake
|
||||
local suite = test.declare("module_loader")
|
||||
|
||||
--
|
||||
-- Setup
|
||||
--
|
||||
|
||||
local loaderIndex
|
||||
|
||||
function suite.setup()
|
||||
table.insert(package.searchers, function (name)
|
||||
p.out(name)
|
||||
return load("")
|
||||
end)
|
||||
loaderIndex = #package.searchers
|
||||
end
|
||||
|
||||
function suite.teardown()
|
||||
table.remove(package.searchers, loaderIndex)
|
||||
end
|
||||
|
||||
--
|
||||
-- Check that premake's module loader let other loaders try
|
||||
-- when it cannot find a module.
|
||||
--
|
||||
|
||||
function suite.letOtherLoadersTry()
|
||||
require("foo")
|
||||
test.capture [[
|
||||
foo
|
||||
]]
|
||||
end
|
45
Src/external_dependencies/openmpt-trunk/include/premake/tests/base/test_option.lua
vendored
Normal file
45
Src/external_dependencies/openmpt-trunk/include/premake/tests/base/test_option.lua
vendored
Normal file
|
@ -0,0 +1,45 @@
|
|||
--
|
||||
-- tests/base/test_option.lua
|
||||
-- Verify the handling of command line options and the _OPTIONS table.
|
||||
-- Copyright (c) 2014 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local p = premake
|
||||
local suite = test.declare("base_option")
|
||||
|
||||
|
||||
--
|
||||
-- Setup and teardown.
|
||||
--
|
||||
|
||||
function suite.setup()
|
||||
_OPTIONS["testopt"] = "testopt"
|
||||
end
|
||||
|
||||
function suite.teardown()
|
||||
_OPTIONS["testopt"] = nil
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Because we can't control how the user will type in options on the
|
||||
-- command line, all key lookups should be case insensitive.
|
||||
--
|
||||
|
||||
function suite.returnsCorrectOption_onMixedCase()
|
||||
test.isnotnil(_OPTIONS["TestOpt"])
|
||||
end
|
||||
|
||||
--
|
||||
-- Because we can't control how the user will type in options in the
|
||||
-- premake script, keys should be stored in lowercase.
|
||||
--
|
||||
|
||||
function suite.storesOptionCorrectly_onMixedCase()
|
||||
newoption {
|
||||
trigger = "TestOpt2",
|
||||
description = "Testing",
|
||||
}
|
||||
|
||||
test.isnotnil(p.option.get("testopt2"))
|
||||
end
|
487
Src/external_dependencies/openmpt-trunk/include/premake/tests/base/test_os.lua
vendored
Normal file
487
Src/external_dependencies/openmpt-trunk/include/premake/tests/base/test_os.lua
vendored
Normal file
|
@ -0,0 +1,487 @@
|
|||
---
|
||||
-- tests/base/test_os.lua
|
||||
-- Automated test suite for the new OS functions.
|
||||
-- Copyright (c) 2008-2017 Jason Perkins and the Premake project
|
||||
---
|
||||
|
||||
local suite = test.declare("base_os")
|
||||
|
||||
local cwd
|
||||
|
||||
function suite.setup()
|
||||
cwd = os.getcwd()
|
||||
os.chdir(_TESTS_DIR)
|
||||
end
|
||||
|
||||
function suite.teardown()
|
||||
os.chdir(cwd)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- os.findlib() tests
|
||||
--
|
||||
|
||||
function suite.findlib_FindSystemLib()
|
||||
if os.istarget("macosx") then
|
||||
-- macOS no longer stores system libraries on filesystem; see
|
||||
-- https://developer.apple.com/documentation/macos-release-notes/macos-big-sur-11_0_1-release-notes
|
||||
elseif os.istarget("windows") then
|
||||
test.istrue(os.findlib("user32"))
|
||||
elseif os.istarget("haiku") then
|
||||
test.istrue(os.findlib("root"))
|
||||
else
|
||||
test.istrue(os.findlib("m"))
|
||||
end
|
||||
end
|
||||
|
||||
function suite.findlib_FailsOnBadLibName()
|
||||
test.isfalse(os.findlib("NoSuchLibraryAsThisOneHere"))
|
||||
end
|
||||
|
||||
function suite.findheader_stdheaders()
|
||||
if not os.istarget("windows") and not os.istarget("macosx") then
|
||||
test.istrue(os.findheader("stdlib.h"))
|
||||
end
|
||||
end
|
||||
|
||||
function suite.findheader_failure()
|
||||
test.isfalse(os.findheader("Knights/who/say/Ni.hpp"))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- os.isfile() tests
|
||||
--
|
||||
|
||||
function suite.isfile_ReturnsTrue_OnExistingFile()
|
||||
test.istrue(os.isfile("_tests.lua"))
|
||||
end
|
||||
|
||||
function suite.isfile_ReturnsFalse_OnNonexistantFile()
|
||||
test.isfalse(os.isfile("no_such_file.lua"))
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- os.matchdirs() tests
|
||||
--
|
||||
|
||||
function suite.matchdirs_skipsDottedDirs()
|
||||
local result = os.matchdirs("*")
|
||||
test.isfalse(table.contains(result, ".."))
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- os.matchfiles() tests
|
||||
--
|
||||
|
||||
function suite.matchfiles_OnNonRecursive()
|
||||
local result = os.matchfiles("*.lua")
|
||||
test.istrue(table.contains(result, "_tests.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("**/subfolder/*")
|
||||
test.istrue(table.contains(result, "folder/subfolder/hello.txt"))
|
||||
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
|
||||
|
||||
function suite.matchfiles_OnDottedFile()
|
||||
local result = os.matchfiles("base/.*")
|
||||
test.istrue(table.contains(result, "base/.testDotFile"))
|
||||
end
|
||||
|
||||
function suite.matchfiles_onComboSearch()
|
||||
local result = os.matchfiles("folder/**/*.txt")
|
||||
test.istrue(table.contains(result, "folder/subfolder/hello.txt"))
|
||||
end
|
||||
|
||||
function suite.matchfiles_onSymbolicLink()
|
||||
if os.istarget("macosx")
|
||||
or os.istarget("linux")
|
||||
or os.istarget("solaris")
|
||||
or os.istarget("bsd")
|
||||
then
|
||||
os.execute("cd folder && ln -s subfolder symlinkfolder && cd ..")
|
||||
local result = os.matchfiles("folder/**/*.txt")
|
||||
os.execute("rm folder/symlinkfolder")
|
||||
premake.modules.self_test.print(table.tostring(result))
|
||||
test.istrue(table.contains(result, "folder/symlinkfolder/hello.txt"))
|
||||
end
|
||||
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(_TESTS_DIR, os.pathsearch("_tests.lua", _TESTS_DIR))
|
||||
end
|
||||
|
||||
function suite.pathsearch_FindsFile_OnComplexPath()
|
||||
test.isequal(_TESTS_DIR, os.pathsearch("_tests.lua", "aaa;" .. _TESTS_DIR .. ";bbb"))
|
||||
end
|
||||
|
||||
function suite.pathsearch_NilPathsAllowed()
|
||||
test.isequal(_TESTS_DIR, os.pathsearch("_tests.lua", nil, _TESTS_DIR, nil))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- os.outputof() tests
|
||||
--
|
||||
|
||||
-- Check if outputof returns the command exit code
|
||||
-- in addition of the command output
|
||||
function suite.outputof_commandExitCode()
|
||||
if os.istarget("macosx")
|
||||
or os.istarget("linux")
|
||||
or os.istarget("solaris")
|
||||
or os.istarget("bsd")
|
||||
then
|
||||
-- Assumes 'true' and 'false' commands exist
|
||||
-- which should be the case on all *nix platforms
|
||||
for cmd, exitcode in pairs ({
|
||||
["true"] = 0,
|
||||
["false"] = 1
|
||||
})
|
||||
do
|
||||
local o, e = os.outputof(cmd)
|
||||
test.isequal(e, exitcode)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Check outputof content
|
||||
function suite.outputof_streams_output()
|
||||
if (os.istarget("macosx")
|
||||
or os.istarget("linux")
|
||||
or os.istarget("solaris")
|
||||
or os.istarget("bsd"))
|
||||
and os.isdir (_TESTS_DIR)
|
||||
then
|
||||
local ob, e = os.outputof ("ls " .. _TESTS_DIR .. "/base")
|
||||
local oo, e = os.outputof ("ls " .. _TESTS_DIR .. "/base", "output")
|
||||
test.isequal (oo, ob)
|
||||
local s, e = string.find (oo, "test_os.lua")
|
||||
test.istrue(s ~= nil)
|
||||
|
||||
local o, e = os.outputof ("ls " .. cwd .. "/base", "error")
|
||||
test.istrue(o == nil or #o == 0)
|
||||
end
|
||||
end
|
||||
|
||||
--
|
||||
-- os.translateCommand() tests
|
||||
--
|
||||
|
||||
function suite.translateCommand_onNoToken()
|
||||
test.isequal("cp a b", os.translateCommands("cp a b"))
|
||||
end
|
||||
|
||||
function suite.translateCommand_callsProcessor()
|
||||
os.commandTokens.test = {
|
||||
copy = function(value) return "test " .. value end
|
||||
}
|
||||
test.isequal("test a b", os.translateCommands("{COPY} a b", "test"))
|
||||
end
|
||||
|
||||
function suite.translateCommand_callsProcessor_multipleTokens()
|
||||
os.commandTokens.test = {
|
||||
copy = function(value) return "test " .. value end
|
||||
}
|
||||
test.isequal("test a b; test c d; test e f;", os.translateCommands("{COPY} a b; {COPY} c d; {COPY} e f;", "test"))
|
||||
end
|
||||
|
||||
--
|
||||
-- os.translateCommand() windows COPY tests
|
||||
--
|
||||
|
||||
function suite.translateCommand_windowsCopyNoDst()
|
||||
test.isequal('IF EXIST a\\ (xcopy /Q /E /Y /I a > nul) ELSE (xcopy /Q /Y /I a > nul)', os.translateCommands('{COPY} a', "windows"))
|
||||
end
|
||||
|
||||
function suite.translateCommand_windowsCopyNoDst_ExtraSpace()
|
||||
test.isequal('IF EXIST a\\ (xcopy /Q /E /Y /I a > nul) ELSE (xcopy /Q /Y /I a > nul)', os.translateCommands('{COPY} a ', "windows"))
|
||||
end
|
||||
|
||||
function suite.translateCommand_windowsCopyNoQuotes()
|
||||
test.isequal('IF EXIST a\\ (xcopy /Q /E /Y /I a b > nul) ELSE (xcopy /Q /Y /I a b > nul)', os.translateCommands('{COPY} a b', "windows"))
|
||||
end
|
||||
|
||||
function suite.translateCommand_windowsCopyNoQuotes_ExtraSpace()
|
||||
test.isequal('IF EXIST a\\ (xcopy /Q /E /Y /I a b > nul) ELSE (xcopy /Q /Y /I a b > nul)', os.translateCommands('{COPY} a b ', "windows"))
|
||||
end
|
||||
|
||||
function suite.translateCommand_windowsCopyQuotes()
|
||||
test.isequal('IF EXIST "a a"\\ (xcopy /Q /E /Y /I "a a" "b" > nul) ELSE (xcopy /Q /Y /I "a a" "b" > nul)', os.translateCommands('{COPY} "a a" "b"', "windows"))
|
||||
end
|
||||
|
||||
function suite.translateCommand_windowsCopyQuotes_ExtraSpace()
|
||||
test.isequal('IF EXIST "a a"\\ (xcopy /Q /E /Y /I "a a" "b" > nul) ELSE (xcopy /Q /Y /I "a a" "b" > nul)', os.translateCommands('{COPY} "a a" "b" ', "windows"))
|
||||
end
|
||||
|
||||
function suite.translateCommand_windowsCopyNoQuotesDst()
|
||||
test.isequal('IF EXIST "a a"\\ (xcopy /Q /E /Y /I "a a" b > nul) ELSE (xcopy /Q /Y /I "a a" b > nul)', os.translateCommands('{COPY} "a a" b', "windows"))
|
||||
end
|
||||
|
||||
function suite.translateCommand_windowsCopyNoQuotesDst_ExtraSpace()
|
||||
test.isequal('IF EXIST "a a"\\ (xcopy /Q /E /Y /I "a a" b > nul) ELSE (xcopy /Q /Y /I "a a" b > nul)', os.translateCommands('{COPY} "a a" b ', "windows"))
|
||||
end
|
||||
|
||||
function suite.translateCommand_windowsCopyNoQuotesSrc()
|
||||
test.isequal('IF EXIST a\\ (xcopy /Q /E /Y /I a "b" > nul) ELSE (xcopy /Q /Y /I a "b" > nul)', os.translateCommands('{COPY} a "b"', "windows"))
|
||||
end
|
||||
|
||||
function suite.translateCommand_windowsCopyNoQuotesSrc_ExtraSpace()
|
||||
test.isequal('IF EXIST a\\ (xcopy /Q /E /Y /I a "b" > nul) ELSE (xcopy /Q /Y /I a "b" > nul)', os.translateCommands('{COPY} a "b" ', "windows"))
|
||||
end
|
||||
|
||||
--
|
||||
-- os.getWindowsRegistry windows tests
|
||||
--
|
||||
function suite.getreg_nonExistentValue()
|
||||
if os.ishost("windows") then
|
||||
local x = os.getWindowsRegistry("HKCU:Should\\Not\\Exist\\At\\All")
|
||||
test.isequal(nil, x)
|
||||
end
|
||||
end
|
||||
|
||||
function suite.getreg_nonExistentDefaultValue()
|
||||
if os.ishost("windows") then
|
||||
local x = os.getWindowsRegistry("HKCU:Should\\Not\\Exist\\At\\All\\")
|
||||
test.isequal(nil, x)
|
||||
end
|
||||
end
|
||||
|
||||
function suite.getreg_noSeparators()
|
||||
if os.ishost("windows") then
|
||||
local x = os.getWindowsRegistry("HKCU:ShouldNotExistAtAll")
|
||||
test.isequal(nil, x)
|
||||
end
|
||||
end
|
||||
|
||||
function suite.getreg_namedValue()
|
||||
if os.ishost("windows") then
|
||||
local x = os.getWindowsRegistry("HKCU:Environment\\TEMP")
|
||||
test.istrue(x ~= nil)
|
||||
end
|
||||
end
|
||||
|
||||
function suite.getreg_namedValueOptSeparator()
|
||||
if os.ishost("windows") then
|
||||
local x = os.getWindowsRegistry("HKCU:\\Environment\\TEMP")
|
||||
test.istrue(x ~= nil)
|
||||
end
|
||||
end
|
||||
|
||||
function suite.getreg_defaultValue()
|
||||
if os.ishost("windows") then
|
||||
local x = os.getWindowsRegistry("HKLM:SYSTEM\\CurrentControlSet\\Control\\SafeBoot\\Minimal\\AppInfo\\")
|
||||
test.isequal("Service", x)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- os.listWindowsRegistry windows tests
|
||||
--
|
||||
function suite.listreg_nonExistentKey()
|
||||
if os.ishost("windows") then
|
||||
local x = os.listWindowsRegistry("HKCU:Should\\Not\\Exist\\At\\All")
|
||||
test.isequal(nil, x)
|
||||
end
|
||||
end
|
||||
|
||||
function suite.listreg_nonExistentKeyTrailingBackslash()
|
||||
if os.ishost("windows") then
|
||||
local x = os.listWindowsRegistry("HKCU:Should\\Not\\Exist\\At\\All\\")
|
||||
test.isequal(nil, x)
|
||||
end
|
||||
end
|
||||
|
||||
function suite.listreg_noSeparators()
|
||||
if os.ishost("windows") then
|
||||
local x = os.listWindowsRegistry("HKCU:ShouldNotExistAtAll")
|
||||
test.isequal(nil, x)
|
||||
end
|
||||
end
|
||||
|
||||
function suite.listreg_noSeparatorExistingPath()
|
||||
if os.ishost("windows") then
|
||||
local x = os.listWindowsRegistry("HKCU:Environment")
|
||||
test.istrue(x ~= nil and x["TEMP"] ~= nil)
|
||||
end
|
||||
end
|
||||
|
||||
function suite.listreg_optSeparators()
|
||||
if os.ishost("windows") then
|
||||
local x = os.listWindowsRegistry("HKCU:\\Environment\\")
|
||||
test.istrue(x ~= nil and x["TEMP"] ~= nil)
|
||||
end
|
||||
end
|
||||
|
||||
function suite.listreg_keyDefaultValueAndStringValueFormat()
|
||||
if os.ishost("windows") then
|
||||
local x = os.listWindowsRegistry("HKLM:SYSTEM\\CurrentControlSet\\Control\\SafeBoot\\Minimal\\AppInfo")
|
||||
test.isequal(x[""]["value"], "Service")
|
||||
test.isequal(x[""]["type"], "REG_SZ")
|
||||
end
|
||||
end
|
||||
|
||||
function suite.listreg_numericValueFormat()
|
||||
if os.ishost("windows") then
|
||||
local x = os.listWindowsRegistry("HKCU:Console")
|
||||
test.isequal(type(x["FullScreen"]["value"]), "number")
|
||||
test.isequal(x["FullScreen"]["type"], "REG_DWORD")
|
||||
end
|
||||
end
|
||||
|
||||
function suite.listreg_subkeyFormat()
|
||||
if os.ishost("windows") then
|
||||
local x = os.listWindowsRegistry("HKLM:")
|
||||
test.isequal(type(x["SOFTWARE"]), "table")
|
||||
test.isequal(next(x["SOFTWARE"]), nil)
|
||||
end
|
||||
end
|
||||
|
||||
--
|
||||
-- os.getversion tests.
|
||||
--
|
||||
|
||||
function suite.getversion()
|
||||
local version = os.getversion();
|
||||
test.istrue(version ~= nil)
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- os.translateCommandsAndPaths.
|
||||
--
|
||||
|
||||
function suite.translateCommandsAndPaths()
|
||||
test.isequal('cmdtool "../foo/path1"', os.translateCommandsAndPaths("cmdtool %[path1]", '../foo', '.', 'osx'))
|
||||
end
|
||||
|
||||
function suite.translateCommandsAndPaths_PreserveSlash()
|
||||
test.isequal('cmdtool "../foo/path1/"', os.translateCommandsAndPaths("cmdtool %[path1/]", '../foo', '.', 'osx'))
|
||||
end
|
||||
|
||||
function suite.translateCommandsAndPaths_MultipleTokens()
|
||||
test.isequal('cmdtool "../foo/path1" "../foo/path2/"', os.translateCommandsAndPaths("cmdtool %[path1] %[path2/]", '../foo', '.', 'osx'))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Helpers
|
||||
--
|
||||
|
||||
local tmpname = function()
|
||||
local p = os.tmpname()
|
||||
os.remove(p) -- just needed on POSIX
|
||||
return p
|
||||
end
|
||||
|
||||
local tmpfile = function()
|
||||
local p = tmpname()
|
||||
if os.ishost("windows") then
|
||||
os.execute("type nul >" .. p)
|
||||
else
|
||||
os.execute("touch " .. p)
|
||||
end
|
||||
return p
|
||||
end
|
||||
|
||||
local tmpdir = function()
|
||||
local p = tmpname()
|
||||
os.mkdir(p)
|
||||
return p
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- os.remove() tests.
|
||||
--
|
||||
|
||||
function suite.remove_ReturnsError_OnNonExistingPath()
|
||||
local ok, err, exitcode = os.remove(tmpname())
|
||||
test.isnil(ok)
|
||||
test.isequal("string", type(err))
|
||||
test.isequal("number", type(exitcode))
|
||||
test.istrue(0 ~= exitcode)
|
||||
end
|
||||
|
||||
function suite.remove_ReturnsError_OnDirectory()
|
||||
local ok, err, exitcode = os.remove(tmpdir())
|
||||
test.isnil(ok)
|
||||
test.isequal("string", type(err))
|
||||
test.isequal("number", type(exitcode))
|
||||
test.istrue(0 ~= exitcode)
|
||||
end
|
||||
|
||||
function suite.remove_ReturnsTrue_OnFile()
|
||||
local ok, err, exitcode = os.remove(tmpfile())
|
||||
test.isequal(true, ok)
|
||||
test.isnil(err)
|
||||
test.isnil(exitcode)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- os.rmdir() tests.
|
||||
--
|
||||
|
||||
function suite.rmdir_ReturnsError_OnNonExistingPath()
|
||||
local ok, err = os.rmdir(tmpname())
|
||||
test.isnil(ok)
|
||||
test.isequal("string", type(err))
|
||||
end
|
||||
|
||||
function suite.rmdir_ReturnsError_OnFile()
|
||||
local ok, err = os.rmdir(tmpfile())
|
||||
test.isnil(ok)
|
||||
test.isequal("string", type(err))
|
||||
end
|
||||
|
||||
function suite.rmdir_ReturnsTrue_OnDirectory()
|
||||
local ok, err = os.rmdir(tmpdir())
|
||||
test.isequal(true, ok)
|
||||
test.isnil(err)
|
||||
end
|
75
Src/external_dependencies/openmpt-trunk/include/premake/tests/base/test_override.lua
vendored
Normal file
75
Src/external_dependencies/openmpt-trunk/include/premake/tests/base/test_override.lua
vendored
Normal file
|
@ -0,0 +1,75 @@
|
|||
--
|
||||
-- tests/base/test_override.lua
|
||||
-- Verify function override support.
|
||||
-- Copyright (c) 2012 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
|
||||
local p = premake
|
||||
local suite = test.declare("base_override")
|
||||
|
||||
|
||||
--
|
||||
-- Setup
|
||||
--
|
||||
|
||||
local X = {}
|
||||
|
||||
function suite.setup()
|
||||
X.testfunc = function(value)
|
||||
return value or "testfunc"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Should be able to completely replace the function with one of my own.
|
||||
--
|
||||
|
||||
function suite.canOverride()
|
||||
p.override(X, "testfunc", function()
|
||||
return "canOverride"
|
||||
end)
|
||||
test.isequal("canOverride", X.testfunc())
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Should be able to reference the original implementation.
|
||||
--
|
||||
|
||||
function suite.canCallOriginal()
|
||||
p.override(X, "testfunc", function(base)
|
||||
return "canOverride > " .. base()
|
||||
end)
|
||||
test.isequal("canOverride > testfunc", X.testfunc())
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Arguments should pass through.
|
||||
--
|
||||
|
||||
function suite.canPassThroughArguments()
|
||||
p.override(X, "testfunc", function(base, value)
|
||||
return value .. " > " .. base()
|
||||
end)
|
||||
test.isequal("testval > testfunc", X.testfunc("testval"))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Can override the same function multiple times.
|
||||
--
|
||||
|
||||
function suite.canOverrideMultipleTimes()
|
||||
p.override(X, "testfunc", function(base, value)
|
||||
return string.format("[%s > %s]", value, base("base1"))
|
||||
end)
|
||||
|
||||
p.override(X, "testfunc", function(base, value)
|
||||
return string.format("{%s > %s}", value, base("base2"))
|
||||
end)
|
||||
|
||||
test.isequal("{base3 > [base2 > base1]}", X.testfunc("base3"))
|
||||
end
|
789
Src/external_dependencies/openmpt-trunk/include/premake/tests/base/test_path.lua
vendored
Normal file
789
Src/external_dependencies/openmpt-trunk/include/premake/tests/base/test_path.lua
vendored
Normal file
|
@ -0,0 +1,789 @@
|
|||
--
|
||||
-- tests/base/test_path.lua
|
||||
-- Automated test suite for the action list.
|
||||
-- Copyright (c) 2008-2013 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local suite = test.declare("path")
|
||||
|
||||
|
||||
--
|
||||
-- path.getabsolute() tests
|
||||
--
|
||||
|
||||
function suite.getabsolute_worksWithMissingSubdirs()
|
||||
local expected = os.getcwd() .. "/a/b/c"
|
||||
test.isequal(expected, path.getabsolute("a/b/c"))
|
||||
end
|
||||
|
||||
function suite.getabsolute_removesDotDots_onWindows()
|
||||
test.isequal("c:/ProjectB/bin", path.getabsolute("c:/ProjectA/../ProjectB/bin"))
|
||||
end
|
||||
|
||||
function suite.getabsolute_removesDotDots_OnPosix()
|
||||
test.isequal("/ProjectB/bin", path.getabsolute("/ProjectA/../ProjectB/bin"))
|
||||
end
|
||||
|
||||
function suite.getabsolute_limitsDotDots_onWindows()
|
||||
test.isequal("c:/ProjectB/bin", path.getabsolute("c:/ProjectA/../../ProjectB/bin"))
|
||||
end
|
||||
|
||||
function suite.getabsolute_limitsDotDots_OnPosix()
|
||||
test.isequal("/ProjectB/bin", path.getabsolute("/ProjectA/../../ProjectB/bin"))
|
||||
end
|
||||
|
||||
function suite.getabsolute_removesDot()
|
||||
test.isequal("/ProjectA/ProjectB/bin", path.getabsolute("/ProjectA/./ProjectB/bin"))
|
||||
end
|
||||
|
||||
function suite.getabsolute_removesTrailingSlash()
|
||||
test.isequal("/a/b/c", path.getabsolute("/a/b/c/"))
|
||||
end
|
||||
|
||||
function suite.getabsolute_onLeadingEnvVar()
|
||||
test.isequal("$(HOME)/user", path.getabsolute("$(HOME)/user"))
|
||||
end
|
||||
|
||||
function suite.getabsolute_onLeadingEnvVar_dosStyle()
|
||||
test.isequal("%HOME%/user", path.getabsolute("%HOME%/user"))
|
||||
end
|
||||
|
||||
function suite.getabsolute_onServerPath()
|
||||
test.isequal("//Server/Volume", path.getabsolute("//Server/Volume"))
|
||||
end
|
||||
|
||||
function suite.getabsolute_onMultipleEnvVar()
|
||||
test.isequal("$(HOME)/$(USER)", path.getabsolute("$(HOME)/$(USER)"))
|
||||
end
|
||||
|
||||
function suite.getabsolute_onTrailingEnvVar()
|
||||
test.isequal("/home/$(USER)", path.getabsolute("/home/$(USER)"))
|
||||
end
|
||||
|
||||
function suite.getabsolute_onLeadingEnvVarQuoted()
|
||||
test.isequal('"$(HOME)/user"', path.getabsolute('"$(HOME)/user"'))
|
||||
end
|
||||
|
||||
function suite.getabsolute_normalizesPaths()
|
||||
test.isequal("c:/ProjectB/bin", path.getabsolute("c:\\ProjectB\\bin"))
|
||||
end
|
||||
|
||||
function suite.getabsolute_acceptsTables()
|
||||
test.isequal({ "/a/b", "/c/d" }, path.getabsolute({ "/a/b", "/c/d" }))
|
||||
end
|
||||
|
||||
function suite.getabsolute_withRelativeTo()
|
||||
local relto = path.getdirectory(os.getcwd())
|
||||
local expected = relto .. "/a/b/c"
|
||||
test.isequal(expected, path.getabsolute("a/b/c", relto))
|
||||
end
|
||||
|
||||
function suite.getabsolute_withRelativeTo_withTrailingSlashes()
|
||||
local relto = path.getdirectory(os.getcwd())
|
||||
local expected = relto .. "/a/b/c"
|
||||
test.isequal(expected, path.getabsolute("a/b/c", relto .. "/"))
|
||||
end
|
||||
|
||||
function suite.getabsolute_acceptsTables_withRelativeTo()
|
||||
local relto = path.getdirectory(os.getcwd())
|
||||
test.isequal({ relto .. "/a/b", relto .. "/c/d" }, path.getabsolute({ "a/b", "c/d" }, relto))
|
||||
end
|
||||
|
||||
function suite.getabsolute_leavesDotDot_onShellVar()
|
||||
test.isequal("$ORIGIN/../libs", path.getabsolute("$ORIGIN/../libs"))
|
||||
end
|
||||
|
||||
function suite.getabsolute_leavesDotDot2_onShellVar()
|
||||
test.isequal("$ORIGIN/../../libs", path.getabsolute("$ORIGIN/../../libs"))
|
||||
end
|
||||
|
||||
--
|
||||
-- path.deferred_join() tests
|
||||
--
|
||||
function suite.deferred_join_OnMaybeAbsolutePath()
|
||||
test.isequal("p1\a%{foo}", path.deferredjoin("p1", "%{foo}"))
|
||||
end
|
||||
|
||||
function suite.deferred_join_OnValidParts()
|
||||
test.isequal("p1/p2", path.deferredjoin("p1", "p2"))
|
||||
end
|
||||
|
||||
function suite.deferred_join_OnAbsoluteath()
|
||||
test.isequal("/p2", path.deferredjoin("p1", "/p2"))
|
||||
end
|
||||
|
||||
--
|
||||
-- path.has_deferred_join() tests
|
||||
--
|
||||
|
||||
function suite.has_deferred_join_true()
|
||||
test.istrue(path.hasdeferredjoin("p1\a%{foo}"))
|
||||
end
|
||||
|
||||
function suite.has_deferred_join_false()
|
||||
test.isfalse(path.hasdeferredjoin("p1/p2"))
|
||||
end
|
||||
|
||||
function suite.has_deferred_join_true_OnPipe()
|
||||
test.istrue(path.hasdeferredjoin("c1 p1\a%{foo} | c2"))
|
||||
end
|
||||
|
||||
function suite.has_deferred_join_false_OnPipe()
|
||||
test.isfalse(path.hasdeferredjoin("c1 p1/p2 | c2"))
|
||||
end
|
||||
|
||||
function suite.has_deferred_join_true_OnOr()
|
||||
test.istrue(path.hasdeferredjoin("c1 p1\a%{foo} || c2"))
|
||||
end
|
||||
|
||||
function suite.has_deferred_join_false_OnOr()
|
||||
test.isfalse(path.hasdeferredjoin("c1 p1/p2 || c2"))
|
||||
end
|
||||
|
||||
--
|
||||
-- path.resolvedeferredjoin() tests
|
||||
--
|
||||
|
||||
function suite.resolve_deferred_join_OnNoDelimiter()
|
||||
test.isequal("p1", path.resolvedeferredjoin("p1"))
|
||||
end
|
||||
|
||||
function suite.resolve_deferred_join_OnValidParts()
|
||||
test.isequal("p1/p2", path.resolvedeferredjoin("p1\ap2"))
|
||||
end
|
||||
|
||||
function suite.resolve_deferred_join_OnAbsoluteWindowsPath()
|
||||
test.isequal("C:/p2", path.resolvedeferredjoin("p1\aC:/p2"))
|
||||
end
|
||||
|
||||
function suite.resolve_deferred_join_OnCurrentDirectory()
|
||||
test.isequal("p2", path.resolvedeferredjoin(".\ap2"))
|
||||
end
|
||||
|
||||
function suite.resolve_deferred_join_OnBackToBasePath()
|
||||
test.isequal("", path.resolvedeferredjoin("p1/p2/\a../../"))
|
||||
end
|
||||
|
||||
function suite.resolve_deferred_join_OnBackToBasePathWithoutFinalSlash()
|
||||
test.isequal("", path.resolvedeferredjoin("p1/p2/\a../.."))
|
||||
end
|
||||
|
||||
function suite.resolve_deferred_join_OnBothUpTwoFolders()
|
||||
test.isequal("../../../../foo", path.resolvedeferredjoin("../../\a../../foo"))
|
||||
end
|
||||
|
||||
function suite.resolve_deferred_join_OnUptwoFolders()
|
||||
test.isequal("p1/foo", path.resolvedeferredjoin("p1/p2/p3\a../../foo"))
|
||||
end
|
||||
|
||||
function suite.resolve_deferred_join_OnUptoBase()
|
||||
test.isequal("foo", path.resolvedeferredjoin("p1/p2/p3\a../../../foo"))
|
||||
end
|
||||
|
||||
function suite.resolve_deferred_join_ignoreLeadingDots()
|
||||
test.isequal("p1/p2/foo", path.resolvedeferredjoin("p1/p2\a././foo"))
|
||||
end
|
||||
|
||||
function suite.resolve_deferred_join_OnUptoParentOfBase()
|
||||
test.isequal("../../p1", path.resolvedeferredjoin("p1/p2/p3/p4/p5/p6/p7/\a../../../../../../../../../p1"))
|
||||
end
|
||||
|
||||
function suite.resolve_deferred_join_onMoreThanTwoParts()
|
||||
test.isequal("p1/p2/p3", path.resolvedeferredjoin("p1\ap2\ap3"))
|
||||
end
|
||||
|
||||
function suite.resolve_deferred_join_removesExtraInternalSlashes()
|
||||
test.isequal("p1/p2", path.resolvedeferredjoin("p1/\ap2"))
|
||||
end
|
||||
|
||||
function suite.resolve_deferred_join_removesTrailingSlash()
|
||||
test.isequal("p1/p2", path.resolvedeferredjoin("p1\ap2/"))
|
||||
end
|
||||
|
||||
function suite.resolve_deferred_join_ignoresEmptyParts()
|
||||
test.isequal("p2", path.resolvedeferredjoin("\ap2\a"))
|
||||
end
|
||||
|
||||
function suite.resolve_deferred_join_canJoinBareSlash()
|
||||
test.isequal("/Users", path.resolvedeferredjoin("/\aUsers"))
|
||||
end
|
||||
|
||||
function suite.resolve_deferred_join_keepsLeadingEnvVar()
|
||||
test.isequal("$(ProjectDir)/../../Bin", path.resolvedeferredjoin("$(ProjectDir)\a../../Bin"))
|
||||
end
|
||||
|
||||
function suite.resolve_deferred_join_keepsInternalEnvVar()
|
||||
test.isequal("$(ProjectDir)/$(TargetName)/../../Bin", path.resolvedeferredjoin("$(ProjectDir)/$(TargetName)\a../../Bin"))
|
||||
end
|
||||
|
||||
function suite.resolve_deferred_join_keepsComplexInternalEnvVar()
|
||||
test.isequal("$(ProjectDir)/myobj_$(Arch)/../../Bin", path.resolvedeferredjoin("$(ProjectDir)/myobj_$(Arch)\a../../Bin"))
|
||||
end
|
||||
|
||||
function suite.resolve_deferred_join_keepsRecursivePattern()
|
||||
test.isequal("p1/**.lproj/../p2", path.resolvedeferredjoin("p1/**.lproj\a../p2"))
|
||||
end
|
||||
|
||||
function suite.resolve_deferred_join_keepsVSMacros()
|
||||
test.isequal("p1/%(Filename).ext", path.resolvedeferredjoin("p1\a%(Filename).ext"))
|
||||
end
|
||||
|
||||
function suite.resolve_deferred_join_noCombineSingleDot()
|
||||
test.isequal("p1/./../p2", path.resolvedeferredjoin("p1/.\a../p2"))
|
||||
end
|
||||
|
||||
function suite.resolve_deferred_join_absolute_second_part()
|
||||
test.isequal("$ORIGIN", path.resolvedeferredjoin("foo/bar\a$ORIGIN"))
|
||||
end
|
||||
|
||||
function suite.resolve_deferred_join_absolute_second_part1()
|
||||
test.isequal("$(FOO)/bar", path.resolvedeferredjoin("foo/bar\a$(FOO)/bar"))
|
||||
end
|
||||
|
||||
function suite.resolve_deferred_join_absolute_second_part2()
|
||||
test.isequal("%ROOT%/foo", path.resolvedeferredjoin("foo/bar\a%ROOT%/foo"))
|
||||
end
|
||||
|
||||
function suite.resolve_deferred_join_token_in_second_part()
|
||||
test.isequal("foo/bar/%{test}/foo", path.resolvedeferredjoin("foo/bar\a%{test}/foo"))
|
||||
end
|
||||
|
||||
function suite.resolve_deferred_join_ignoresPipe()
|
||||
test.isequal("c1 p1/p2 | c2", path.resolvedeferredjoin("c1 p1/p2 | c2"))
|
||||
end
|
||||
|
||||
function suite.resolve_deferred_join_OnPipe()
|
||||
test.isequal("c1 p1/p2 | c2", path.resolvedeferredjoin("c1 p1\ap2 | c2"))
|
||||
end
|
||||
|
||||
function suite.resolve_deferred_join_ignoresOr()
|
||||
test.isequal("c1 p1/p2 || c2", path.resolvedeferredjoin("c1 p1/p2 || c2"))
|
||||
end
|
||||
|
||||
function suite.resolve_deferred_join_OnOr()
|
||||
test.isequal("c1 p1/p2 || c2", path.resolvedeferredjoin("c1 p1\ap2 || c2"))
|
||||
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_ReturnsEmptyString_OnPathWithDotAndNoExtension()
|
||||
test.isequal("", path.getextension("/.premake/premake"))
|
||||
end
|
||||
|
||||
function suite.getextension_ReturnsExtension()
|
||||
test.isequal(".txt", path.getextension("filename.txt"))
|
||||
end
|
||||
|
||||
function suite.getextension_ReturnsExtension_OnPathWithDot()
|
||||
test.isequal(".lua", path.getextension("/.premake/premake.lua"))
|
||||
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_ReturnsChildPath_OnServerPath()
|
||||
test.isequal("../Volume", path.getrelative("//Server/Shared", "//Server/Volume"))
|
||||
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
|
||||
|
||||
function suite.getrelative_ReturnsAbsPath_OnServerPath()
|
||||
test.isequal("//Server/Volume", path.getrelative("C:/Files", "//Server/Volume"))
|
||||
end
|
||||
|
||||
function suite.getrelative_ReturnsAbsPath_OnDifferentServers()
|
||||
test.isequal("//Server/Volume", path.getrelative("//Computer/Users", "//Server/Volume"))
|
||||
end
|
||||
|
||||
function suite.getrelative_ignoresExtraSlashes2()
|
||||
test.isequal("..", path.getrelative("/a//b/c","/a/b"))
|
||||
end
|
||||
|
||||
function suite.getrelative_ignoresExtraSlashes3()
|
||||
test.isequal("..", path.getrelative("/a///b/c","/a/b"))
|
||||
end
|
||||
|
||||
function suite.getrelative_ignoresTrailingSlashes()
|
||||
test.isequal("c", path.getrelative("/a/b/","/a/b/c"))
|
||||
end
|
||||
|
||||
function suite.getrelative_returnsAbsPath_onContactWithFileSysRoot()
|
||||
test.isequal("C:/Boost/Include", path.getrelative("C:/Code/MyApp", "C:/Boost/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_OnDollarToken()
|
||||
test.istrue(path.isabsolute("$(SDK_HOME)/include"))
|
||||
end
|
||||
|
||||
function suite.isabsolute_ReturnsTrue_OnDotInDollarToken()
|
||||
test.istrue(path.isabsolute("$(configuration.libs)/include"))
|
||||
end
|
||||
|
||||
function suite.isabsolute_ReturnsTrue_OnJustADollarSign()
|
||||
test.istrue(path.isabsolute("$foo/include"))
|
||||
end
|
||||
|
||||
function suite.isabsolute_ReturnsFalse_OnIncompleteDollarToken()
|
||||
test.isfalse(path.isabsolute("$(foo/include"))
|
||||
end
|
||||
|
||||
function suite.isabsolute_ReturnsTrue_OnEnvVar()
|
||||
test.istrue(path.isabsolute("%FOO%/include"))
|
||||
end
|
||||
|
||||
function suite.isabsolute_ReturnsFalse_OnEmptyEnvVar()
|
||||
test.isfalse(path.isabsolute("%%/include"))
|
||||
end
|
||||
|
||||
function suite.isabsolute_ReturnsFalse_OnToken()
|
||||
test.isfalse(path.isabsolute("%{foo}/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_OnBackToBasePath()
|
||||
test.isequal("", path.join("p1/p2/", "../../"))
|
||||
end
|
||||
|
||||
function suite.join_OnBackToBasePathWithoutFinalSlash()
|
||||
test.isequal("", path.join("p1/p2/", "../.."))
|
||||
end
|
||||
|
||||
function suite.join_OnBothUpTwoFolders()
|
||||
test.isequal("../../../../foo", path.join("../../", "../../foo"))
|
||||
end
|
||||
|
||||
function suite.join_OnUptwoFolders()
|
||||
test.isequal("p1/foo", path.join("p1/p2/p3", "../../foo"))
|
||||
end
|
||||
|
||||
function suite.join_OnUptoBase()
|
||||
test.isequal("foo", path.join("p1/p2/p3", "../../../foo"))
|
||||
end
|
||||
|
||||
function suite.join_ignoreLeadingDots()
|
||||
test.isequal("p1/p2/foo", path.join("p1/p2", "././foo"))
|
||||
end
|
||||
|
||||
function suite.join_OnUptoParentOfBase()
|
||||
test.isequal("../../p1", path.join("p1/p2/p3/p4/p5/p6/p7/", "../../../../../../../../../p1"))
|
||||
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
|
||||
|
||||
function suite.join_canJoinBareSlash()
|
||||
test.isequal("/Users", path.join("/", "Users"))
|
||||
end
|
||||
|
||||
function suite.join_keepsLeadingEnvVar()
|
||||
test.isequal("$(ProjectDir)/../../Bin", path.join("$(ProjectDir)", "../../Bin"))
|
||||
end
|
||||
|
||||
function suite.join_keepsInternalEnvVar()
|
||||
test.isequal("$(ProjectDir)/$(TargetName)/../../Bin", path.join("$(ProjectDir)/$(TargetName)", "../../Bin"))
|
||||
end
|
||||
|
||||
function suite.join_keepsComplexInternalEnvVar()
|
||||
test.isequal("$(ProjectDir)/myobj_$(Arch)/../../Bin", path.join("$(ProjectDir)/myobj_$(Arch)", "../../Bin"))
|
||||
end
|
||||
|
||||
function suite.join_keepsRecursivePattern()
|
||||
test.isequal("p1/**.lproj/../p2", path.join("p1/**.lproj", "../p2"))
|
||||
end
|
||||
|
||||
function suite.join_noCombineSingleDot()
|
||||
test.isequal("p1/./../p2", path.join("p1/.", "../p2"))
|
||||
end
|
||||
|
||||
function suite.join_absolute_second_part()
|
||||
test.isequal("$ORIGIN", path.join("foo/bar", "$ORIGIN"))
|
||||
end
|
||||
|
||||
function suite.join_absolute_second_part1()
|
||||
test.isequal("$(FOO)/bar", path.join("foo/bar", "$(FOO)/bar"))
|
||||
end
|
||||
|
||||
function suite.join_absolute_second_part2()
|
||||
test.isequal("%ROOT%/foo", path.join("foo/bar", "%ROOT%/foo"))
|
||||
end
|
||||
|
||||
function suite.join_token_in_second_part()
|
||||
test.isequal("foo/bar/%{test}/foo", path.join("foo/bar", "%{test}/foo"))
|
||||
end
|
||||
|
||||
--
|
||||
-- path.rebase() tests
|
||||
--
|
||||
|
||||
function suite.rebase_WithEndingSlashOnPath()
|
||||
local cwd = os.getcwd()
|
||||
test.isequal("src", path.rebase("../src/", cwd, path.getdirectory(cwd)))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- path.replaceextension() tests
|
||||
--
|
||||
|
||||
function suite.getabsolute_replaceExtension()
|
||||
test.isequal("/AB.foo", path.replaceextension("/AB.exe","foo"))
|
||||
end
|
||||
|
||||
function suite.getabsolute_replaceExtensionWithDot()
|
||||
test.isequal("/AB.foo", path.replaceextension("/AB.exe",".foo"))
|
||||
end
|
||||
|
||||
function suite.getabsolute_replaceExtensionWithDotMultipleDots()
|
||||
test.isequal("/nunit.framework.foo", path.replaceextension("/nunit.framework.dll",".foo"))
|
||||
end
|
||||
|
||||
function suite.getabsolute_replaceExtensionCompletePath()
|
||||
test.isequal("/nunit/framework/main.foo", path.replaceextension("/nunit/framework/main.cpp",".foo"))
|
||||
end
|
||||
|
||||
function suite.getabsolute_replaceExtensionWithoutExtension()
|
||||
test.isequal("/nunit/framework/main.foo", path.replaceextension("/nunit/framework/main",".foo"))
|
||||
end
|
||||
|
||||
function suite.getabsolute_replaceExtensionWithEmptyString()
|
||||
test.isequal("foo", path.replaceextension("foo.lua",""))
|
||||
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", "/")
|
||||
test.isequal("dir/dir/file", actual)
|
||||
end
|
||||
|
||||
function suite.translate_ReturnsTargetOSSeparator_Windows()
|
||||
_OPTIONS["os"] = "windows"
|
||||
test.isequal("dir\\dir\\file", path.translate("dir/dir\\file"))
|
||||
end
|
||||
|
||||
function suite.translate_ReturnsTargetOSSeparator_Linux()
|
||||
_OPTIONS["os"] = "linux"
|
||||
test.isequal("dir/dir/file", path.translate("dir/dir\\file"))
|
||||
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
|
||||
|
||||
function suite.wildcards_escapeSpecialChars()
|
||||
test.isequal("%.%-", path.wildcards(".-"))
|
||||
end
|
||||
|
||||
function suite.wildcards_escapeStar()
|
||||
test.isequal("vs[^/]*", path.wildcards("vs*"))
|
||||
end
|
||||
|
||||
function suite.wildcards_escapeStarStar()
|
||||
test.isequal("Images/.*%.bmp", path.wildcards("Images/**.bmp"))
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- path.normalize tests
|
||||
--
|
||||
function suite.normalize_Test1()
|
||||
local p = path.normalize("d:/game/../test")
|
||||
test.isequal("d:/test", p)
|
||||
end
|
||||
|
||||
function suite.normalize_Test2()
|
||||
local p = path.normalize("d:/game/../../test")
|
||||
test.isequal("d:/../test", p)
|
||||
end
|
||||
|
||||
function suite.normalize_Test3()
|
||||
local p = path.normalize("../../test")
|
||||
test.isequal("../../test", p)
|
||||
end
|
||||
|
||||
function suite.normalize_Test4()
|
||||
local p = path.normalize("../../../test/*.h")
|
||||
test.isequal("../../../test/*.h", p)
|
||||
end
|
||||
|
||||
function suite.normalize_Test5()
|
||||
test.isequal("test", path.normalize("./test"))
|
||||
test.isequal("d:/", path.normalize("d:/"))
|
||||
test.isequal("d:/", path.normalize("d:/./"))
|
||||
local p = path.normalize("d:/game/..")
|
||||
test.isequal("d:/", p)
|
||||
end
|
||||
|
||||
function suite.normalize_trailingDots1()
|
||||
local p = path.normalize("../game/test/..")
|
||||
test.isequal("../game", p)
|
||||
end
|
||||
|
||||
function suite.normalize_trailingDots2()
|
||||
local p = path.normalize("../game/..")
|
||||
test.isequal("..", p)
|
||||
end
|
||||
|
||||
function suite.normalize_singleDot()
|
||||
local p = path.normalize("../../p1/p2/p3/p4/./a.pb.cc")
|
||||
test.isequal("../../p1/p2/p3/p4/a.pb.cc", p)
|
||||
end
|
||||
|
||||
function suite.normalize_trailingSingleDot()
|
||||
local p = path.normalize("../../p1/p2/p3/p4/./.")
|
||||
test.isequal("../../p1/p2/p3/p4", p)
|
||||
end
|
||||
|
||||
function suite.normalize()
|
||||
test.isequal("d:/ProjectB/bin", path.normalize("d:/ProjectA/../ProjectB/bin"))
|
||||
test.isequal("/ProjectB/bin", path.normalize("/ProjectA/../ProjectB/bin"))
|
||||
end
|
||||
|
||||
function suite.normalize_leadingWhitespaces()
|
||||
test.isequal("d:/game", path.normalize("\t\n d:/game"))
|
||||
end
|
||||
|
||||
function suite.normalize_multPath()
|
||||
test.isequal("../a/b ../c/d", path.normalize("../a/b ../c/d"))
|
||||
test.isequal("d:/test ../a/b", path.normalize("d:/game/../test ../a/b"))
|
||||
test.isequal("d:/game/test ../a/b", path.normalize("d:/game/./test ../a/b"))
|
||||
test.isequal("d:/test ../a/b", path.normalize(" d:/game/../test ../a/b"))
|
||||
test.isequal("d:/game ../a/b", path.normalize(" d:/game ../a/./b"))
|
||||
test.isequal("d:/game ../a/b", path.normalize("d:/game/ ../a/b"))
|
||||
test.isequal("d:/game", path.normalize("d:/game/ "))
|
||||
end
|
||||
|
||||
function suite.normalize_legitimateDots()
|
||||
test.isequal("d:/test/test..test", path.normalize("d:/test/test..test"))
|
||||
test.isequal("d:/test..test/test", path.normalize("d:/test..test/test"))
|
||||
test.isequal("d:/test/.test", path.normalize("d:/test/.test"))
|
||||
test.isequal("d:/.test", path.normalize("d:/test/../.test"))
|
||||
test.isequal("d:/test", path.normalize("d:/test/.test/.."))
|
||||
test.isequal("d:/test/..test", path.normalize("d:/test/..test"))
|
||||
test.isequal("d:/..test", path.normalize("d:/test/../..test"))
|
||||
test.isequal("d:/test", path.normalize("d:/test/..test/.."))
|
||||
test.isequal("d:/test/.test", path.normalize("d:/test/..test/../.test"))
|
||||
test.isequal("d:/test/..test/.test", path.normalize("d:/test/..test/test/../.test"))
|
||||
test.isequal("d:/test", path.normalize("d:/test/..test/../.test/.."))
|
||||
end
|
||||
|
||||
function suite.normalize_serverpath()
|
||||
test.isequal("//myawesomeserver/test", path.normalize("//myawesomeserver/test/"))
|
||||
test.isequal("//myawesomeserver/test", path.normalize("///myawesomeserver/test/"))
|
||||
end
|
||||
|
||||
function suite.normalize_quotedpath()
|
||||
test.isequal("\"../../test/test/\"", path.normalize("\"../../test/test/\""))
|
||||
test.isequal("\"../../test/\"", path.normalize("\"../../test/../test/\""))
|
||||
end
|
||||
|
||||
function suite.normalize_withTokens()
|
||||
-- Premake tokens
|
||||
test.isequal("%{wks.location}../../test", path.normalize("%{wks.location}../../test"))
|
||||
-- Visual Studio var
|
||||
test.isequal("$(SolutionDir)../../test", path.normalize("$(SolutionDir)../../test"))
|
||||
-- Windows env var
|
||||
test.isequal("%APPDATA%../../test", path.normalize("%APPDATA%../../test"))
|
||||
-- Unix env var
|
||||
test.isequal("${HOME}../../test", path.normalize("${HOME}../../test"))
|
||||
|
||||
-- Middle
|
||||
test.isequal("../../${MYVAR}/../test", path.normalize("../../${MYVAR}/../test"))
|
||||
-- End
|
||||
test.isequal("../../test/${MYVAR}", path.normalize("../../test/${MYVAR}"))
|
||||
end
|
||||
|
||||
function suite.normalize_quotedpath_withTokens()
|
||||
-- Premake tokens
|
||||
test.isequal("\"%{wks.location}../../test\"", path.normalize("\"%{wks.location}../../test\""))
|
||||
-- Visual Studio var
|
||||
test.isequal("\"$(SolutionDir)../../test\"", path.normalize("\"$(SolutionDir)../../test\""))
|
||||
-- Windows env var
|
||||
test.isequal("\"%APPDATA%../../test\"", path.normalize("\"%APPDATA%../../test\""))
|
||||
-- Unix env var
|
||||
test.isequal("\"${HOME}../../test\"", path.normalize("\"${HOME}../../test\""))
|
||||
|
||||
-- Middle
|
||||
test.isequal("\"../../${MYVAR}/../test\"", path.normalize("\"../../${MYVAR}/../test\""))
|
||||
-- End
|
||||
test.isequal("\"../../test/${MYVAR}\"", path.normalize("\"../../test/${MYVAR}\""))
|
||||
end
|
12
Src/external_dependencies/openmpt-trunk/include/premake/tests/base/test_premake_command.lua
vendored
Normal file
12
Src/external_dependencies/openmpt-trunk/include/premake/tests/base/test_premake_command.lua
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
--
|
||||
-- tests/base/test_premake_command.lua
|
||||
-- Test the initialization of the _PREMAKE_COMMAND global.
|
||||
-- Copyright (c) 2012-2014 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local suite = test.declare("premake_command")
|
||||
|
||||
|
||||
function suite.valueIsSet()
|
||||
test.istrue(os.isfile(_PREMAKE_COMMAND))
|
||||
end
|
85
Src/external_dependencies/openmpt-trunk/include/premake/tests/base/test_rule.lua
vendored
Normal file
85
Src/external_dependencies/openmpt-trunk/include/premake/tests/base/test_rule.lua
vendored
Normal file
|
@ -0,0 +1,85 @@
|
|||
--
|
||||
-- tests/base/test_rule.lua
|
||||
-- Automated test suite for custom rule.
|
||||
-- Copyright (c) 2008-2021 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local suite = test.declare("rule")
|
||||
|
||||
local p = premake
|
||||
|
||||
function suite.setup()
|
||||
rule "TestRule"
|
||||
display "Test Rule"
|
||||
fileextension ".rule"
|
||||
|
||||
propertydefinition {
|
||||
name = "TestPropertyFalse",
|
||||
kind = "boolean",
|
||||
value = false,
|
||||
switch = "-dummy"
|
||||
}
|
||||
propertydefinition {
|
||||
name = "TestPropertyTrue",
|
||||
kind = "boolean",
|
||||
value = false,
|
||||
switch = "-p"
|
||||
}
|
||||
|
||||
propertydefinition {
|
||||
name = "TestListProperty",
|
||||
kind = "list"
|
||||
}
|
||||
|
||||
propertydefinition {
|
||||
name = "TestListPropertyWithSwitch",
|
||||
kind = "list",
|
||||
switch = "-S"
|
||||
}
|
||||
|
||||
propertydefinition {
|
||||
name = "TestListPropertySeparator",
|
||||
kind = "list",
|
||||
separator = ","
|
||||
}
|
||||
|
||||
propertydefinition {
|
||||
name = "TestListPropertySeparatorWithSwitch",
|
||||
kind = "list",
|
||||
separator = ",",
|
||||
switch = "-O"
|
||||
}
|
||||
|
||||
propertydefinition {
|
||||
name = "TestEnumProperty",
|
||||
values = { [0] = "V0", [1] = "V1"},
|
||||
switch = { [0] = "S0", [1] = "S1"},
|
||||
value = 0
|
||||
}
|
||||
end
|
||||
|
||||
--
|
||||
-- rule tests
|
||||
--
|
||||
function suite.prepareEnvironment()
|
||||
local rule = premake.global.getRule("TestRule")
|
||||
local environ = {}
|
||||
local cfg = {
|
||||
["_rule_TestRule_TestPropertyFalse"] = false,
|
||||
["_rule_TestRule_TestPropertyTrue"] = true,
|
||||
["_rule_TestRule_TestListProperty"] = {"a", "b"},
|
||||
["_rule_TestRule_TestListPropertyWithSwitch"] = {"c", "d"},
|
||||
["_rule_TestRule_TestListPropertySeparator"] = {"e", "f"},
|
||||
["_rule_TestRule_TestListPropertySeparatorWithSwitch"] = {"1", "2"},
|
||||
["_rule_TestRule_TestEnumProperty"] = 'V1'
|
||||
}
|
||||
p.rule.prepareEnvironment(rule, environ, cfg)
|
||||
|
||||
test.isequal(nil, environ["TestPropertyFalse"])
|
||||
test.isequal("-p", environ["TestPropertyTrue"])
|
||||
test.isequal("a b", environ["TestListProperty"])
|
||||
test.isequal("-Sc -Sd", environ["TestListPropertyWithSwitch"])
|
||||
test.isequal("e,f", environ["TestListPropertySeparator"])
|
||||
test.isequal("-O1,2", environ["TestListPropertySeparatorWithSwitch"])
|
||||
test.isequal("S1", environ["TestEnumProperty"])
|
||||
end
|
97
Src/external_dependencies/openmpt-trunk/include/premake/tests/base/test_table.lua
vendored
Normal file
97
Src/external_dependencies/openmpt-trunk/include/premake/tests/base/test_table.lua
vendored
Normal file
|
@ -0,0 +1,97 @@
|
|||
--
|
||||
-- tests/base/test_table.lua
|
||||
-- Automated test suite for the new table functions.
|
||||
-- Copyright (c) 2008-2013 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
|
||||
local suite = test.declare("table")
|
||||
|
||||
local t
|
||||
|
||||
|
||||
--
|
||||
-- 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.indexof() tests
|
||||
--
|
||||
|
||||
function suite.indexof_returnsIndexOfValueFound()
|
||||
local idx = table.indexof({ "a", "b", "c" }, "b")
|
||||
test.isequal(2, idx)
|
||||
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
|
||||
|
||||
|
||||
--
|
||||
-- table.insertsorted() tests
|
||||
--
|
||||
|
||||
function suite.insertsorted()
|
||||
local t = {}
|
||||
table.insertsorted(t, 5)
|
||||
table.insertsorted(t, 2)
|
||||
table.insertsorted(t, 8)
|
||||
table.insertsorted(t, 4)
|
||||
table.insertsorted(t, 1)
|
||||
|
||||
test.istrue(#t == 5)
|
||||
test.istrue(t[1] == 1)
|
||||
test.istrue(t[2] == 2)
|
||||
test.istrue(t[3] == 4)
|
||||
test.istrue(t[4] == 5)
|
||||
test.istrue(t[5] == 8)
|
||||
end
|
286
Src/external_dependencies/openmpt-trunk/include/premake/tests/base/test_tree.lua
vendored
Normal file
286
Src/external_dependencies/openmpt-trunk/include/premake/tests/base/test_tree.lua
vendored
Normal file
|
@ -0,0 +1,286 @@
|
|||
--
|
||||
-- tests/base/test_tree.lua
|
||||
-- Automated test suite source code tree handling.
|
||||
-- Copyright (c) 2009-2012 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local p = premake
|
||||
local suite = test.declare("base_tree")
|
||||
local tree = p.tree
|
||||
|
||||
|
||||
--
|
||||
-- Setup/teardown
|
||||
--
|
||||
|
||||
local tr
|
||||
|
||||
function suite.setup()
|
||||
tr = tree.new()
|
||||
end
|
||||
|
||||
local function prepare()
|
||||
tree.traverse(tr, {
|
||||
onnode = function(node, depth)
|
||||
_p(depth + 2, node.name)
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Tests for tree.new()
|
||||
--
|
||||
|
||||
function suite.NewReturnsObject()
|
||||
test.isnotnil(tr)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Tests for tree.add()
|
||||
--
|
||||
|
||||
function suite.CanAddAtRoot()
|
||||
tree.add(tr, "Root")
|
||||
prepare()
|
||||
test.capture [[
|
||||
Root
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.CanAddAtChild()
|
||||
tree.add(tr, "Root/Child")
|
||||
prepare()
|
||||
test.capture [[
|
||||
Root
|
||||
Child
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.CanAddAtGrandchild()
|
||||
tree.add(tr, "Root/Child/Grandchild")
|
||||
prepare()
|
||||
test.capture [[
|
||||
Root
|
||||
Child
|
||||
Grandchild
|
||||
]]
|
||||
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)
|
||||
prepare()
|
||||
test.capture [[
|
||||
A
|
||||
1
|
||||
2
|
||||
B
|
||||
1
|
||||
2
|
||||
3
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- If the root of the tree contains multiple items, it should not
|
||||
-- be removed by trimroot()
|
||||
--
|
||||
|
||||
function suite.trimroot_onItemsAtRoot()
|
||||
tree.add(tr, "A/1")
|
||||
tree.add(tr, "B/1")
|
||||
tree.trimroot(tr)
|
||||
prepare()
|
||||
test.capture [[
|
||||
A
|
||||
1
|
||||
B
|
||||
1
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Should trim to first level with multiple items.
|
||||
--
|
||||
|
||||
function suite.trimroot_onItemsInFirstNode()
|
||||
tree.add(tr, "A/1")
|
||||
tree.add(tr, "A/2")
|
||||
tree.trimroot(tr)
|
||||
prepare()
|
||||
test.capture [[
|
||||
1
|
||||
2
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- If the tree contains only a single node, don't trim it.
|
||||
--
|
||||
|
||||
function suite.trimroot_onSingleNode()
|
||||
tree.add(tr, "A")
|
||||
tree.trimroot(tr)
|
||||
prepare()
|
||||
test.capture [[
|
||||
A
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- If the tree contains only a single node, don't trim it.
|
||||
--
|
||||
|
||||
function suite.trimroot_onSingleLeafNode()
|
||||
tree.add(tr, "A/1")
|
||||
tree.trimroot(tr)
|
||||
prepare()
|
||||
test.capture [[
|
||||
1
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- A ".." folder containing a single subfolder should never appear
|
||||
-- at the top of the source tree.
|
||||
--
|
||||
|
||||
function suite.trimroot_removesDotDot_onTopLevelSiblings()
|
||||
tree.add(tr, "../../tests/test_hello.c")
|
||||
tree.add(tr, "../src/test.c")
|
||||
tree.trimroot(tr)
|
||||
prepare()
|
||||
test.capture [[
|
||||
tests
|
||||
test_hello.c
|
||||
src
|
||||
test.c
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.trimroot_removesDotDot_onTopLevel()
|
||||
tree.add(tr, "../tests/test_hello.c")
|
||||
tree.add(tr, "src/test.c")
|
||||
tree.trimroot(tr)
|
||||
prepare()
|
||||
test.capture [[
|
||||
tests
|
||||
test_hello.c
|
||||
src
|
||||
test.c
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.trimroot_removesDotDot_onMultipleNestings()
|
||||
tree.add(tr, "../../../tests/test_hello.c")
|
||||
tree.add(tr, "../src/test.c")
|
||||
tree.trimroot(tr)
|
||||
prepare()
|
||||
test.capture [[
|
||||
tests
|
||||
test_hello.c
|
||||
src
|
||||
test.c
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- When nodes are trimmed, the paths on the remaining nodes should
|
||||
-- be updated to reflect the new hierarchy.
|
||||
--
|
||||
|
||||
function suite.trimroot_updatesPaths_onNodesRemoved()
|
||||
tree.add(tr, "A/1")
|
||||
tree.add(tr, "A/2")
|
||||
tree.trimroot(tr)
|
||||
test.isequal("1", tr.children[1].path)
|
||||
end
|
||||
|
||||
|
||||
function suite.trimroot_updatesPaths_onDotDotRemoved()
|
||||
tree.add(tr, "../../../tests/test_hello.c")
|
||||
tree.add(tr, "../src/test.c")
|
||||
tree.trimroot(tr)
|
||||
test.isequal("tests", tr.children[1].path)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Nodes with the key "trim" set to false should be removed.
|
||||
--
|
||||
|
||||
function suite.trimroot_respectsTrimFlag()
|
||||
local n = tree.add(tr, "A")
|
||||
tree.add(tr, "A/1")
|
||||
n.trim = false
|
||||
tree.trimroot(tr)
|
||||
prepare()
|
||||
test.capture [[
|
||||
A
|
||||
1
|
||||
]]
|
||||
end
|
52
Src/external_dependencies/openmpt-trunk/include/premake/tests/base/test_uuid.lua
vendored
Normal file
52
Src/external_dependencies/openmpt-trunk/include/premake/tests/base/test_uuid.lua
vendored
Normal file
|
@ -0,0 +1,52 @@
|
|||
--
|
||||
-- tests/base/test_uuid.lua
|
||||
-- Automated test suite for UUID generation.
|
||||
-- Copyright (c) 2008-2012 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local suite = test.declare("os_uuid")
|
||||
|
||||
|
||||
--
|
||||
-- Setup and teardown
|
||||
--
|
||||
|
||||
local builtin_print, result
|
||||
|
||||
function suite.setup()
|
||||
builtin_print = print
|
||||
print = function(value)
|
||||
result = value
|
||||
end
|
||||
end
|
||||
|
||||
function suite.teardown()
|
||||
print = builtin_print
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Make sure the return value looks like a UUID.
|
||||
--
|
||||
|
||||
function suite.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
|
||||
|
||||
|
||||
--
|
||||
-- Make sure the value returned is deterministic if a name is provided.
|
||||
--
|
||||
|
||||
function suite.isDeterministic_onName()
|
||||
test.isequal("885E8F4B-F43D-0EE7-FD55-99BD69B47448", os.uuid("MyValue"))
|
||||
end
|
130
Src/external_dependencies/openmpt-trunk/include/premake/tests/base/test_validation.lua
vendored
Normal file
130
Src/external_dependencies/openmpt-trunk/include/premake/tests/base/test_validation.lua
vendored
Normal file
|
@ -0,0 +1,130 @@
|
|||
--
|
||||
-- tests/base/test_validation.lua
|
||||
-- Verify the project information sanity checking.
|
||||
-- Copyright (c) 2013-20124 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local suite = test.declare("premake_validation")
|
||||
|
||||
local p = premake
|
||||
|
||||
|
||||
--
|
||||
-- Setup
|
||||
--
|
||||
|
||||
local function validate()
|
||||
return pcall(function() p.container.validate(p.api.rootContainer()) end)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Validate should pass if the minimum requirements are met.
|
||||
--
|
||||
|
||||
function suite.passes_onSane()
|
||||
workspace("MyWorkspace")
|
||||
configurations { "Debug", "Release" }
|
||||
project "MyProject"
|
||||
kind "ConsoleApp"
|
||||
language "C++"
|
||||
test.istrue(validate())
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Fail if no configurations are present on the workspace.
|
||||
--
|
||||
|
||||
function suite.fails_onNoWorkspaceConfigs()
|
||||
workspace "MyWorkspace"
|
||||
project "MyProject"
|
||||
kind "ConsoleApp"
|
||||
language "C++"
|
||||
test.isfalse(validate())
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Fail on duplicate project UUIDs.
|
||||
--
|
||||
|
||||
function suite.fails_onDuplicateProjectIDs()
|
||||
workspace "MyWorkspace"
|
||||
configurations { "Debug", "Release" }
|
||||
kind "ConsoleApp"
|
||||
language "C++"
|
||||
project "MyProject1"
|
||||
uuid "D4110D7D-FB18-4A1C-A75B-CA432F4FE770"
|
||||
project "MyProject2"
|
||||
uuid "D4110D7D-FB18-4A1C-A75B-CA432F4FE770"
|
||||
test.isfalse(validate())
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Fail if no kind is set on the configuration.
|
||||
--
|
||||
|
||||
function suite.fails_onNoConfigKind()
|
||||
workspace "MyWorkspace"
|
||||
configurations { "Debug", "Release" }
|
||||
project "MyProject"
|
||||
language "C++"
|
||||
test.isfalse(validate())
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Warn if a configuration value is set in the wrong scope.
|
||||
--
|
||||
|
||||
function suite.warns_onWorkspaceStringField_inConfig()
|
||||
workspace "MyWorkspace"
|
||||
configurations { "Debug", "Release" }
|
||||
filter "Debug"
|
||||
startproject "MyProject"
|
||||
project "MyProject"
|
||||
kind "ConsoleApp"
|
||||
language "C++"
|
||||
validate()
|
||||
test.stderr("'startproject' on config")
|
||||
end
|
||||
|
||||
function suite.warns_onProjectStringField_inConfig()
|
||||
workspace "MyWorkspace"
|
||||
configurations { "Debug", "Release" }
|
||||
project "MyProject"
|
||||
kind "ConsoleApp"
|
||||
language "C++"
|
||||
filter "Debug"
|
||||
location "MyProject"
|
||||
validate()
|
||||
test.stderr("'location' on config")
|
||||
end
|
||||
|
||||
function suite.warns_onProjectListField_inConfig()
|
||||
workspace "MyWorkspace"
|
||||
configurations { "Debug", "Release" }
|
||||
project "MyProject"
|
||||
kind "ConsoleApp"
|
||||
language "C++"
|
||||
filter "Debug"
|
||||
configurations "Deployment"
|
||||
validate()
|
||||
test.stderr("'configurations' on config")
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- If a rule is specified for inclusion, it must have been defined.
|
||||
--
|
||||
|
||||
function suite.fails_onNoSuchRule()
|
||||
workspace "MyWorkspace"
|
||||
configurations { "Debug", "Release" }
|
||||
project "MyProject"
|
||||
rules { "NoSuchRule" }
|
||||
test.isfalse(validate())
|
||||
end
|
||||
|
187
Src/external_dependencies/openmpt-trunk/include/premake/tests/base/test_versions.lua
vendored
Normal file
187
Src/external_dependencies/openmpt-trunk/include/premake/tests/base/test_versions.lua
vendored
Normal file
|
@ -0,0 +1,187 @@
|
|||
--
|
||||
-- tests/base/test_versions.lua
|
||||
-- Verify the version comparisons.
|
||||
-- Copyright (c) 2015 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local suite = test.declare("premake_versions")
|
||||
|
||||
local p = premake
|
||||
|
||||
|
||||
--
|
||||
-- If only major version is specified, anything after should pass.
|
||||
--
|
||||
|
||||
function suite.pass_majorOnly_sameMajor()
|
||||
test.istrue(p.checkVersion("1.0.0", "1"))
|
||||
end
|
||||
|
||||
function suite.pass_majorOnly_laterMajor()
|
||||
test.istrue(p.checkVersion("2.0.0", "1"))
|
||||
end
|
||||
|
||||
function suite.pass_majorOnly_laterMinor()
|
||||
test.istrue(p.checkVersion("1.1.0", "1"))
|
||||
end
|
||||
|
||||
function suite.pass_majorOnly_laterPatch()
|
||||
test.istrue(p.checkVersion("1.0.1", "1"))
|
||||
end
|
||||
|
||||
--
|
||||
-- prereleases should be fail against true release.
|
||||
--
|
||||
|
||||
function suite.fail_majorOnly_alpha()
|
||||
test.isfalse(p.checkVersion("1.0.0-alpha1", "1"))
|
||||
end
|
||||
|
||||
function suite.fail_majorOnly_dev()
|
||||
test.isfalse(p.checkVersion("1.0.0-dev", "1"))
|
||||
end
|
||||
|
||||
--
|
||||
-- ealier versions should be fail against major release.
|
||||
--
|
||||
|
||||
function suite.fail_earlierMajor()
|
||||
test.isfalse(p.checkVersion("0.9.0", "1"))
|
||||
end
|
||||
|
||||
--
|
||||
-- If major and minor are specified, anything after should pass
|
||||
--
|
||||
|
||||
function suite.pass_majorMinor_sameMajorMinor()
|
||||
test.istrue(p.checkVersion("1.1.0", "1.1"))
|
||||
end
|
||||
|
||||
function suite.pass_majorMinor_sameMajorLaterMinor()
|
||||
test.istrue(p.checkVersion("1.2.0", "1.1"))
|
||||
end
|
||||
|
||||
function suite.pass_majorMinor_sameMajorLaterPath()
|
||||
test.istrue(p.checkVersion("1.1.1", "1.1"))
|
||||
end
|
||||
|
||||
function suite.pass_majorMinor_laterMajorSameMinor()
|
||||
test.istrue(p.checkVersion("2.0.0", "1.1"))
|
||||
end
|
||||
|
||||
function suite.pass_majorMinor_laterMajorEarlierMinor()
|
||||
test.istrue(p.checkVersion("2.0.0", "1.1"))
|
||||
end
|
||||
|
||||
function suite.pass_majorMinor_laterMajorLaterMinor()
|
||||
test.istrue(p.checkVersion("2.2.0", "1.1"))
|
||||
end
|
||||
|
||||
function suite.fail_majorMinor_sameMajorEarlierMinor()
|
||||
test.isfalse(p.checkVersion("1.0.0", "1.1"))
|
||||
end
|
||||
|
||||
function suite.fail_majorMinor_earlierMajor()
|
||||
test.isfalse(p.checkVersion("0.9.0", "1.1"))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Alpha comes before beta comes before dev
|
||||
--
|
||||
|
||||
function suite.pass_alphaBeforeBeta()
|
||||
test.istrue(p.checkVersion("1.0.0-beta1", "1.0.0-alpha1"))
|
||||
end
|
||||
|
||||
function suite.fail_alphaBeforeBeta()
|
||||
test.isfalse(p.checkVersion("1.0.0-alpha1", "1.0.0-beta1"))
|
||||
end
|
||||
|
||||
function suite.pass_betaBeforeDev()
|
||||
test.istrue(p.checkVersion("1.0.0-dev", "1.0.0-beta1"))
|
||||
end
|
||||
|
||||
function suite.fail_betaBeforeDev()
|
||||
test.isfalse(p.checkVersion("1.0.0-beta1", "1.0.0-dev"))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Check ">=" operator
|
||||
--
|
||||
|
||||
function suite.pass_ge_sameMajorMinorPatch()
|
||||
test.istrue(p.checkVersion("1.1.0", ">=1.1"))
|
||||
end
|
||||
|
||||
function suite.pass_ge_sameMajorMinorLaterPatch()
|
||||
test.istrue(p.checkVersion("1.1.1", ">=1.1"))
|
||||
end
|
||||
|
||||
function suite.pass_ge_laterMajorEarlierMinor()
|
||||
test.istrue(p.checkVersion("2.0.1", ">=1.1"))
|
||||
end
|
||||
|
||||
function suite.pass_ge_sameMajorLaterMinor()
|
||||
test.istrue(p.checkVersion("1.2.1", ">=1.1"))
|
||||
end
|
||||
|
||||
function suite.fail_ge_earlierMajor()
|
||||
test.isfalse(p.checkVersion("0.1.1", ">=1.1"))
|
||||
end
|
||||
|
||||
function suite.fail_ge_earlierMinor()
|
||||
test.isfalse(p.checkVersion("1.0.1", ">=1.1"))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Check ">" operator
|
||||
--
|
||||
|
||||
function suite.pass_gt_sameMajorMinorLaterPatch()
|
||||
test.istrue(p.checkVersion("1.1.1", ">1.1"))
|
||||
end
|
||||
|
||||
function suite.pass_gt_laterMajor()
|
||||
test.istrue(p.checkVersion("2.0.1", ">1.1"))
|
||||
end
|
||||
|
||||
function suite.pass_gt_laterMinor()
|
||||
test.istrue(p.checkVersion("1.2.1", ">1.1"))
|
||||
end
|
||||
|
||||
function suite.fail_gt_sameMajorMinorPatch()
|
||||
test.isfalse(p.checkVersion("1.1.0", ">1.1"))
|
||||
end
|
||||
|
||||
function suite.fail_gt_earlierMajor()
|
||||
test.isfalse(p.checkVersion("0.1.1", ">1.1"))
|
||||
end
|
||||
|
||||
function suite.fail_gt_earlierMinor()
|
||||
test.isfalse(p.checkVersion("1.0.1", ">1.1"))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Check multiple conditions
|
||||
--
|
||||
|
||||
function suite.pass_onMultipleConditions()
|
||||
test.istrue(p.checkVersion("1.2.0", ">=1.0 <2.0"))
|
||||
end
|
||||
|
||||
function suite.fail_onMultipleConditions()
|
||||
test.isfalse(p.checkVersion("2.2.0", ">=1.0 <2.0"))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- If there is no version information, fails.
|
||||
--
|
||||
|
||||
function suite.fail_onNoVersion()
|
||||
test.isfalse(p.checkVersion(nil, "1.0"))
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue