Fixed issues with duplicate tests

- Test suite will now fail when test names are reused
- Fixed several unit tests that reused test names
This commit is contained in:
Sam Surtees 2018-04-30 23:40:49 +10:00 committed by Tom van Dijck
parent a2cd65bb50
commit 138a443b3c
18 changed files with 56 additions and 66 deletions

View File

@ -196,7 +196,7 @@ cmd2</StartupCommands>
]]
end
function suite.OnProject_PreBuild()
function suite.OnProject_PostBuild()
postbuildcommands { "cmd0", "cmd1" }
prepare()
codelite.project.postBuild(prj)

View File

@ -143,7 +143,7 @@
prepare { "ldFlags", "libs", "ldDeps" }
test.capture [[
ALL_LDFLAGS += $(LDFLAGS) -s
ALL_LDFLAGS += $(LDFLAGS) -Wl,-rpath,'$$ORIGIN/../../build/bin/Debug' -s
LIBS += build/bin/Debug/libMyProject2.so
LDDEPS += build/bin/Debug/libMyProject2.so
]]
@ -153,7 +153,7 @@
-- Check a linking to a sibling shared library using -l and -L.
--
function suite.links_onSiblingSharedLib()
function suite.links_onSiblingSharedLibRelativeLinks()
links "MyProject2"
flags { "RelativeLinks" }
@ -260,7 +260,7 @@
-- is stripped
--
function suite.onExternalLibraryWithPath()
function suite.onExternalLibraryWithPathAndVersion()
location "MyProject"
links { "libs/SomeLib-1.1" }
prepare { "libs", }

View File

@ -30,6 +30,6 @@
-- Remove parenthesis.
--
function suite.removesDashes()
function suite.removesParenthesis()
test.isequal("MyProject_x86", make.tovar("MyProject (x86)"))
end

View File

@ -46,7 +46,7 @@ endif
-- If a map is present, the configuration change should be applied.
--
function suite.passesThroughConfigs_onNoMap()
function suite.passesThroughConfigs_onMap()
configmap { Debug = "Development" }
prepare()
test.capture [[
@ -65,7 +65,7 @@ endif
-- no mapping should be created.
--
function suite.passesThroughConfigs_onNoMap()
function suite.passesThroughConfigs_onNoMapRemovedConfiguration()
removeconfigurations { "Debug" }
prepare()
test.capture [[

View File

@ -145,7 +145,7 @@ LDDEPS += build/bin/Debug/libMyProject2.a
prepare { "ldFlags", "libs", "ldDeps" }
test.capture [[
ALL_LDFLAGS += $(LDFLAGS) -s
ALL_LDFLAGS += $(LDFLAGS) -Wl,-rpath,'$$ORIGIN/../../build/bin/Debug' -s
LIBS += build/bin/Debug/libMyProject2.so
LDDEPS += build/bin/Debug/libMyProject2.so
]]
@ -155,7 +155,7 @@ LDDEPS += build/bin/Debug/libMyProject2.so
-- Check a linking to a sibling shared library using -l and -L.
--
function suite.links_onSiblingSharedLib()
function suite.links_onSiblingSharedLibRelativeLinks()
links "MyProject2"
flags { "RelativeLinks" }
@ -262,7 +262,7 @@ LIBS += -lSomeLib
-- is stripped
--
function suite.onExternalLibraryWithPath()
function suite.onExternalLibraryWithPathAndVersion()
location "MyProject"
links { "libs/SomeLib-1.1" }
prepare { "libs", }

View File

@ -37,7 +37,9 @@
function m.executeSelfTest()
m.detectDuplicateTests = true
m.loadTestsFromManifests()
m.detectDuplicateTests = false
local test, err = m.getTestWithIdentifier(_OPTIONS["test-only"])
if err then

View File

@ -36,7 +36,14 @@
error('Duplicate test suite "'.. suiteName .. '"', 2)
end
local suite = {}
local _suite = {}
-- Setup a metatable for the test suites to use, this will catch duplicate tests
local suite = setmetatable({}, {
__index = _suite,
__newindex = function (table, key, value) if m.detectDuplicateTests and _suite[key] ~= nil then error('Duplicate test "'.. key .. '"', 2) end _suite[key] = value end,
__pairs = function (table) return pairs(_suite) end,
__ipairs = function (table) return ipairs(_suite) end,
})
suite._SCRIPT_DIR = _SCRIPT_DIR
suite._TESTS_DIR = _TESTS_DIR

View File

@ -126,7 +126,7 @@ Environment="key=value&#x0A;foo=bar"
-- flag is set.
--
function suite.environmentVarsSet_onDebugEnvs()
function suite.environmentVarsSet_onDebugEnvsAndDebugEnvsDontMerge()
debugenvs { "key=value" }
flags { "DebugEnvsDontMerge" }
prepare()

View File

@ -260,7 +260,7 @@
-- If defines are specified with escapable characters, they should be escaped.
--
function suite.preprocessorDefinitions_onDefines()
function suite.preprocessorDefinitions_onDefinesWithEscapeCharacters()
p.escaper(p.vstudio.vs2010.esc)
defines { "&", "<", ">" }
prepare()
@ -477,8 +477,32 @@
]]
end
--
-- Check handling of the explicitly disabling symbols.
-- Note: VS2013 and older have a bug with setting
-- DebugInformationFormat to None. The workaround
-- is to leave the field blank.
--
function suite.onNoSymbols()
symbols "Off"
symbols 'Off'
prepare()
test.capture [[
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat></DebugInformationFormat>
<Optimization>Disabled</Optimization>
]]
end
--
-- VS2015 and newer can use DebugInformationFormat None.
--
function suite.onNoSymbolsVS2015()
symbols 'Off'
p.action.set("vs2015")
prepare()
test.capture [[
<ClCompile>
@ -486,7 +510,6 @@
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>None</DebugInformationFormat>
<Optimization>Disabled</Optimization>
</ClCompile>
]]
end
@ -837,42 +860,6 @@
end
--
-- Check handling of the explicitly disabling symbols.
-- Note: VS2013 and older have a bug with setting
-- DebugInformationFormat to None. The workaround
-- is to leave the field blank.
--
function suite.onNoSymbols()
symbols 'Off'
prepare()
test.capture [[
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat></DebugInformationFormat>
<Optimization>Disabled</Optimization>
]]
end
--
-- VS2015 and newer can use DebugInformationFormat None.
--
function suite.onNoSymbolsVS2015()
symbols 'Off'
p.action.set("vs2015")
prepare()
test.capture [[
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>None</DebugInformationFormat>
<Optimization>Disabled</Optimization>
]]
end
--
-- Check handling of the stringpooling api
--

View File

@ -92,7 +92,7 @@
-- Multiple environment variables should be separated by a "\n" sequence.
--
function suite.localDebuggerEnv_onDebugEnv()
function suite.localDebuggerEnv_onMultipleDebugEnv()
debugenvs { "key=value", "foo=bar" }
prepare()
test.capture [[

View File

@ -190,7 +190,7 @@
--
-- Check handling of .asm files
--
function suite.itemGroup_onNoneSection()
function suite.itemGroup_onMasmSection()
files { "hello.asm" }
prepare()
test.capture [[

View File

@ -45,7 +45,7 @@
--
-- Ensure configuration file is output in ImageXex block
--
function suite.defaultSettings()
function suite.onConfigfile()
configfile "testconfig.xml"
prepare()
test.capture [[

View File

@ -716,7 +716,7 @@
-- Test ignoring default libraries without extensions specified.
--
function suite.ignoreDefaultLibraries_WithExtensions()
function suite.ignoreDefaultLibraries_WithoutExtensions()
ignoredefaultlibraries { "lib1", "lib2.obj" }
prepare()
test.capture [[

View File

@ -80,7 +80,7 @@
-- Managed C++ projects write out references a little differently.
--
function suite.referencesAreRelative_onDifferentProjectLocation()
function suite.referencesAreRelative_onDifferentProjectLocationWithCLR()
links { "MyProject" }
clr "On"
prepare()

View File

@ -116,7 +116,7 @@
test.istrue(path.hasdeferredjoin("p1|%{foo}"))
end
function suite.deferred_join_OnValidParts()
function suite.has_deferred_join_false()
test.isfalse(path.hasdeferredjoin("p1/p2"))
end

View File

@ -77,7 +77,7 @@
-- Shared library should use implibname() if present.
--
function suite.basenameIsTargetName_onTargetName()
function suite.basenameIsImplibName_onTargetName()
kind "SharedLib"
targetname "MyTarget"
implibname "MyTargetImports"

View File

@ -188,7 +188,7 @@
-- Name should use ".exe" for Xbox360 executables.
--
function suite.nameUsesExe_onWindowsConsoleApp()
function suite.nameUsesExe_onXbox360ConsoleApp()
kind "ConsoleApp"
system "Xbox360"
i = prepare()
@ -265,7 +265,7 @@
-- .NET libraries should always default to ".dll" extensions.
--
function suite.appUsesExe_onDotNet()
function suite.appUsesExe_onDotNetSharedLib()
_TARGET_OS = "macosx"
language "C#"
kind "SharedLib"

View File

@ -100,12 +100,6 @@
test.isequal("Headers/hello.h", run())
end
function suite.MatchFilePattern_ToNestedGroup_Flat()
files { "src/myproject/hello.h" }
vpaths { ["Group/Headers"] = "**.h" }
test.isequal("Group/Headers/hello.h", run())
end
function suite.MatchFilePattern_ToGroup_Nested()
files { "src/myproject/hello.h" }
vpaths { ["Headers/*"] = "**.h" }