From bc38d316887263a1a53783efb73968e69acadfcd Mon Sep 17 00:00:00 2001 From: Jason Perkins Date: Fri, 11 Jan 2013 08:53:59 -0500 Subject: Bug 268: Target extension not set properly for Visual Studio 2010 --- tests/actions/vstudio/test_vs2010_flags.lua | 57 +++---- .../actions/vstudio/test_vs2010_project_kinds.lua | 45 ------ tests/actions/vstudio/test_vs2010_vcxproj.lua | 60 ------- tests/actions/vstudio/vc2010/test_output_props.lua | 179 +++++++++++++++++++++ tests/premake4.lua | 17 +- tests/test | 2 +- tests/testfx.lua | 126 ++++++++------- 7 files changed, 291 insertions(+), 195 deletions(-) create mode 100644 tests/actions/vstudio/vc2010/test_output_props.lua (limited to 'tests') diff --git a/tests/actions/vstudio/test_vs2010_flags.lua b/tests/actions/vstudio/test_vs2010_flags.lua index c09776c..973ab71 100644 --- a/tests/actions/vstudio/test_vs2010_flags.lua +++ b/tests/actions/vstudio/test_vs2010_flags.lua @@ -9,12 +9,12 @@ function vs10_flags.setup() sln = solution "MySolution" configurations { "Debug" } platforms {} - + prj = project "MyProject" language "C++" kind "ConsoleApp" - uuid "AE61726D-187C-E440-BD07-2556188A6565" - includedirs{"foo/bar"} + uuid "AE61726D-187C-E440-BD07-2556188A6565" + includedirs{"foo/bar"} end function vs10_flags.teardown() @@ -35,14 +35,14 @@ end function vs10_flags.sseSet() flags {"EnableSSE"} - + local buffer = get_buffer() test.string_contains(buffer,'StreamingSIMDExtensions') end function vs10_flags.sse2Set() flags {"EnableSSE2"} - + local buffer = get_buffer() test.string_contains(buffer,'StreamingSIMDExtensions2') end @@ -54,63 +54,63 @@ end function vs10_flags.extraWarning_warningLevelIsFour() flags {"ExtraWarnings"} - + local buffer = get_buffer() test.string_contains(buffer,'Level4') end function vs10_flags.extraWarning_treatWarningsAsError_setToTrue() flags {"FatalWarnings"} - + local buffer = get_buffer() test.string_contains(buffer,'true') end function vs10_flags.floatFast_floatingPointModel_setToFast() flags {"FloatFast"} - + local buffer = get_buffer() test.string_contains(buffer,'Fast') end function vs10_flags.floatStrict_floatingPointModel_setToStrict() flags {"FloatStrict"} - + local buffer = get_buffer() test.string_contains(buffer,'Strict') end function vs10_flags.nativeWideChar_TreatWChar_tAsBuiltInType_setToTrue() flags {"NativeWChar"} - + local buffer = get_buffer() test.string_contains(buffer,'true') end function vs10_flags.nativeWideChar_TreatWChar_tAsBuiltInType_setToFalse() flags {"NoNativeWChar"} - + local buffer = get_buffer() test.string_contains(buffer,'false') end function vs10_flags.noExceptions_exceptionHandling_setToFalse() flags {"NoExceptions"} - + local buffer = get_buffer() test.string_contains(buffer,'false') end function vs10_flags.structuredExceptions_exceptionHandling_setToAsync() flags {"SEH"} - + local buffer = get_buffer() test.string_contains(buffer,'Async') end function vs10_flags.noFramePointer_omitFramePointers_setToTrue() flags {"NoFramePointer"} - + local buffer = get_buffer() test.string_contains(buffer,'true') end @@ -118,27 +118,27 @@ end function vs10_flags.noRTTI_runtimeTypeInfo_setToFalse() flags {"NoRTTI"} - + local buffer = get_buffer() test.string_contains(buffer,'false') end function vs10_flags.optimizeSize_optimization_setToMinSpace() flags {"OptimizeSize"} - + local buffer = get_buffer() test.string_contains(buffer,'MinSpace') end function vs10_flags.optimizeSpeed_optimization_setToMaxSpeed() flags {"OptimizeSpeed"} - + local buffer = get_buffer() test.string_contains(buffer,'MaxSpeed') end function vs10_flags.optimizeSpeed_optimization_setToMaxSpeed() flags {"Optimize"} - + local buffer = get_buffer() test.string_contains(buffer,'Full') end @@ -177,7 +177,7 @@ end function vs10_flags.unicode_characterSet_setToUnicode() flags {"Unicode"} - + local buffer = get_buffer() test.string_contains(buffer,'Unicode') end @@ -186,28 +186,28 @@ end function vs10_flags.debugAndNoMinimalRebuildAndSymbols_minimalRebuild_setToFalse() flags {debug_string,"NoMinimalRebuild"} - + local buffer = get_buffer() test.string_contains(buffer,'false') end function vs10_flags.debugYetNotMinimalRebuild_minimalRebuild_setToTrue() flags {debug_string} - + local buffer = get_buffer() test.string_contains(buffer,'true') end function vs10_flags.release_minimalRebuild_setToFalse() flags {release_string} - + local buffer = get_buffer() test.string_contains(buffer,'false') end function vs10_flags.mfc_useOfMfc_setToStatic() flags{"MFC"} - + local buffer = get_buffer() test.string_contains(buffer,'Dynamic') end @@ -232,14 +232,14 @@ end function vs10_flags.symbolsAndNoEditAndContinue_DebugInformationFormat_setToProgramDatabase() flags{"Symbols","NoEditAndContinue"} - + local buffer = get_buffer() test.string_contains(buffer,'ProgramDatabase') end function vs10_flags.symbolsAndRelease_DebugInformationFormat_setToProgramDatabase() flags{"Symbols",release_string} - + local buffer = get_buffer() test.string_contains(buffer,'ProgramDatabase') end @@ -255,13 +255,6 @@ function vs10_flags.noSymbols_DebugInformationFormat_blockIsEmpty() test.string_contains(buffer,'') end -function vs10_flags.noManifest_GenerateManifest_setToFalse() - flags{"NoManifest"} - - local buffer = get_buffer() - test.string_contains(buffer,'false') -end - function vs10_flags.noSymbols_bufferDoesNotContainprogramDataBaseFile() local buffer = get_buffer() test.string_does_not_contain(buffer,'.*.*') diff --git a/tests/actions/vstudio/test_vs2010_project_kinds.lua b/tests/actions/vstudio/test_vs2010_project_kinds.lua index 1de75a4..d32146a 100644 --- a/tests/actions/vstudio/test_vs2010_project_kinds.lua +++ b/tests/actions/vstudio/test_vs2010_project_kinds.lua @@ -65,51 +65,6 @@ test.string_contains(buffer,'.*.*.*') end - function vs10_project_kinds.sharedLib_bufferContainsImportLibrary() - kind "SharedLib" - local buffer = get_buffer() - test.string_contains(buffer,'.*MyProject.lib.*') - end - - function vs10_project_kinds.sharedLib_withNoImportLibraryFlag_linkSectionContainsImportLibrary() - kind "SharedLib" - flags{"NoImportLib"} - local buffer = get_buffer() - test.string_contains(buffer,'.*.*.*') - end - - function vs10_project_kinds.sharedLib_withOutNoImportLibraryFlag_propertyGroupSectionContainsIgnoreImportLibrary() - kind "SharedLib" - local buffer = get_buffer() - test.string_contains(buffer,'.*.*') - end - - function vs10_project_kinds.sharedLib_withNoImportLibraryFlag_propertyGroupSectionContainsIgnoreImportLibrary() - kind "SharedLib" - flags{"NoImportLib"} - local buffer = get_buffer() - test.string_contains(buffer,'.*.*') - end - - function vs10_project_kinds.sharedLib_withOutNoImportLibraryFlag_ignoreImportLibraryValueIsFalse() - kind "SharedLib" - local buffer = get_buffer() - test.string_contains(buffer,'.*.*') - end - - function vs10_project_kinds.sharedLib_withNoImportLibraryFlag_ignoreImportLibraryValueIsTrue() - kind "SharedLib" - flags{"NoImportLib"} - local buffer = get_buffer() - test.string_contains(buffer,'.*.*') - end - - function vs10_project_kinds.staticLib_doesNotContainLinkIncremental() - kind "StaticLib" - local buffer = get_buffer() - test.string_does_not_contain(buffer,'') - end - function vs10_project_kinds.sharedLib_withoutOptimisation_linkIncrementalValueIsTrue() kind "SharedLib" local buffer = get_buffer() diff --git a/tests/actions/vstudio/test_vs2010_vcxproj.lua b/tests/actions/vstudio/test_vs2010_vcxproj.lua index a7a3942..c5b3401 100644 --- a/tests/actions/vstudio/test_vs2010_vcxproj.lua +++ b/tests/actions/vstudio/test_vs2010_vcxproj.lua @@ -117,20 +117,6 @@ test.string_contains(buffer,'') end - function vs10_vcxproj.intermediateAndOutDirsPropertyGroupWithMagicNumber() - local buffer = get_buffer() - test.string_contains(buffer,'.*<_ProjectFileVersion>10%.0%.30319%.1') - end - - function vs10_vcxproj.outDirPresent() - local buffer = get_buffer() - test.string_contains(buffer,'') - end - function vs10_vcxproj.initDirPresent() - local buffer = get_buffer() - test.string_contains(buffer,'') - end - function vs10_vcxproj.projectWithDebugAndReleaseConfig_twoOutDirsAndTwoIntDirs() local buffer = get_buffer() test.string_contains(buffer,'.*.*.*') @@ -233,52 +219,6 @@ test.string_contains(buffer,'.*"doSomeThing".*') end - function vs10_vcxproj.outDir_directorySuppliedIsNotSlashPostFixed_bufferContainsOutDirSlashPostFixed() - targetdir("dir") - local buffer = get_buffer() - test.string_contains(buffer,'dir\\') - end - --postfixed directory slashes are removed by default - --yet these following two tests are to ensure if this behaviour is changed they will fail - function vs10_vcxproj.outDir_directorySuppliedWhichIsForwardSlashPostFixed_bufferContainsOutDirSlashPostFixed() - targetdir("dir/") - local buffer = get_buffer() - test.string_contains(buffer,'dir\\') - end - - function vs10_vcxproj.outDir_directorySuppliedWhichIsWindowsSlashPostFixed_bufferContainsOutDirSlashPostFixed() - targetdir("dir\\") - local buffer = get_buffer() - test.string_contains(buffer,'dir\\') - end - - function vs10_vcxproj.objectDir_directorySuppliedIsNotSlashPostFixed_bufferContainsIntermediateDirSlashPostFixed() - objdir ("dir") - - local buffer = get_buffer() - test.string_contains(buffer,'dir\\') - end - - --postfixed directory slashes are removed by default - --yet these following two tests are to ensure if this behaviour is changed they will fail - function vs10_vcxproj.objectDir_directorySuppliedWhichIsSlashPostFixed_bufferContainsIntermediateDirSlashPostFixed() - objdir ("dir/") - local buffer = get_buffer() - test.string_contains(buffer,'dir\\') - end - - function vs10_vcxproj.objectDir_directorySuppliedWhichIsWindowsSlashPostFixed_bufferContainsIntermediateDirSlashPostFixed() - objdir ("dir\\") - local buffer = get_buffer() - test.string_contains(buffer,'dir\\') - end - function vs10_vcxproj.targetName() - configuration("Debug") - targetname ("foo_d") - local buffer = get_buffer() - test.string_contains(buffer,'foo_d') - end - function vs10_vcxproj.noExtraWarnings_bufferDoesNotContainSmallerTypeCheck() local buffer = get_buffer() test.string_does_not_contain(buffer,'') diff --git a/tests/actions/vstudio/vc2010/test_output_props.lua b/tests/actions/vstudio/vc2010/test_output_props.lua new file mode 100644 index 0000000..30c6375 --- /dev/null +++ b/tests/actions/vstudio/vc2010/test_output_props.lua @@ -0,0 +1,179 @@ +-- +-- tests/actions/vstudio/vc2010/test_output_props.lua +-- Validate generation of the output property groups. +-- Copyright (c) 2011-2013 Jason Perkins and the Premake project +-- + + T.vstudio_vs2010_output_props = {} + local suite = T.vstudio_vs2010_output_props + local vc2010 = premake.vstudio.vc2010 + + +-- +-- Setup +-- + + local sln + + function suite.setup() + _ACTION = "vs2010" + sln = test.createsolution() + end + + local function prepare() + premake.bake.buildconfigs() + sln.vstudio_configs = premake.vstudio.buildconfigs(sln) + local prj = premake.solution.getproject(sln, 1) + vc2010.outputProperties(prj) + end + + +-- +-- Check the structure with the default project values. +-- + + function suite.structureIsCorrect_onDefaultValues() + prepare() + test.capture [[ + + .\ + obj\Debug\ + MyProject + .exe + true + + + ]] + end + + +-- +-- Static libraries should omit the link incremental element entirely. +-- + + function suite.omitLinkIncremental_onStaticLib() + kind "StaticLib" + prepare() + test.capture [[ + + .\ + obj\Debug\ + MyProject + .lib + + ]] + end + +-- +-- Optimized builds should not link incrementally. +-- + + function suite.noIncrementalLink_onOptimizedBuild() + flags "Optimize" + prepare() + test.capture [[ + + .\ + obj\Debug\ + MyProject + .exe + false + + ]] + end + +-- +-- The target directory is applied, if specified. +-- + + function suite.outDir_onTargetDir() + targetdir "../bin" + prepare() + test.capture [[ + + ..\bin\ + ]] + end + +-- +-- The objeccts directory is applied, if specified. +-- + + function suite.intDir_onTargetDir() + objdir "../tmp" + prepare() + test.capture [[ + + .\ + ..\tmp\Debug\ + ]] + end + +-- +-- The target name is applied, if specified. +-- + + function suite.targetName_onTargetName() + targetname "MyTarget" + prepare() + test.capture [[ + + .\ + obj\Debug\ + MyTarget + ]] + end + +-- +-- A target extension should be used if specified. +-- + + function suite.targetExt_onTargetExtension() + targetextension ".delta" + prepare() + test.capture [[ + + .\ + obj\Debug\ + MyProject + .delta + ]] + end + +-- +-- If the NoImportLib flag is set, add the IgnoreImportLibrary element. +-- + + function suite.ignoreImportLib_onNoImportLib() + kind "SharedLib" + flags "NoImportLib" + prepare() + test.capture [[ + + .\ + obj\Debug\ + MyProject + .dll + true + ]] + end + + +-- +-- If the NoManifest flag is set, add the GenerateManifest element. +-- + + function suite.generateManifest_onNoManifest() + flags "NoManifest" + prepare() + test.capture [[ + + .\ + obj\Debug\ + MyProject + .exe + true + false + + ]] + end diff --git a/tests/premake4.lua b/tests/premake4.lua index a2d0d5f..2f64d7f 100644 --- a/tests/premake4.lua +++ b/tests/premake4.lua @@ -110,6 +110,7 @@ dofile("actions/vstudio/vc2010/test_link_settings.lua") dofile("actions/vstudio/vc2010/test_links.lua") dofile("actions/vstudio/vc2010/test_mfc.lua") + dofile("actions/vstudio/vc2010/test_output_props.lua") dofile("actions/vstudio/vc2010/test_pch.lua") dofile("actions/vstudio/vc2010/test_project_refs.lua") @@ -142,15 +143,27 @@ -- Register a test action -- + newoption { + trigger = "test", + description = "A suite or test to run" + } + newaction { trigger = "test", description = "Run the automated test suite", execute = function () - passed, failed = test.runall() + if _OPTIONS["test"] then + local t = string.explode(_OPTIONS["test"] or "", ".", true) + passed, failed = test.runall(t[1], t[2]) + else + passed, failed = test.runall() + end + msg = string.format("%d tests passed, %d failed", passed, failed) if (failed > 0) then - error(msg, 0) + -- should probably return an error code here somehow + print(msg) else print(msg) end diff --git a/tests/test b/tests/test index e138ca1..4b3918d 100755 --- a/tests/test +++ b/tests/test @@ -1,2 +1,2 @@ #!/bin/sh -cd `dirname $0` && ../bin/debug/premake4 /scripts=../src test +cd `dirname $0` && ../bin/debug/premake4 /scripts=../src $1 $2 $3 test diff --git a/tests/testfx.lua b/tests/testfx.lua index a33a391..8342086 100644 --- a/tests/testfx.lua +++ b/tests/testfx.lua @@ -20,19 +20,19 @@ test.fail("\n==Fail==: Expected to find :\n%s\nyet it was not found in buffer:\n%s\n", expected,buffer) end end - + function test.string_does_not_contain(buffer, expected) if string.find(buffer,expected) then test.fail("\n==Fail==: Did not expected to find :\n%s\nyet it was found in buffer:\n%s\n", expected,buffer) end end - + function test.capture(expected) local actual = io.endcapture() - + local ait = actual:gfind("(.-)" .. io.eol) local eit = expected:gfind("(.-)\n") - + local linenum = 1 local atxt = ait() local etxt = eit() @@ -40,14 +40,14 @@ if (etxt ~= atxt) then test.fail("(%d) expected:\n%s\n...but was:\n%s", linenum, etxt, atxt) end - + linenum = linenum + 1 atxt = ait() etxt = eit() end end - + function test.closedfile(expected) if expected and not test.value_closedfile then test.fail("expected file to be closed") @@ -55,19 +55,19 @@ test.fail("expected file to remain open") end end - + function test.contains(value, expected) if not table.contains(value, expected) then test.fail("expected value %s not found", expected) end end - - + + function test.fail(format, ...) -- convert nils into something more usefuls for i = 1, arg.n do - if (arg[i] == nil) then + if (arg[i] == nil) then arg[i] = "(nil)" elseif (type(arg[i]) == "table") then arg[i] = "{" .. table.concat(arg[i], ", ") .. "}" @@ -75,8 +75,8 @@ end error(string.format(format, unpack(arg)), 3) end - - + + function test.filecontains(expected, fn) local f = io.open(fn) local actual = f:read("*a") @@ -85,7 +85,7 @@ test.fail("expected %s but was %s", expected, actual) end end - + function test.isemptycapture() local actual = io.endcapture() @@ -94,7 +94,7 @@ end end - + function test.isequal(expected, actual) if (type(expected) == "table") then for k,v in pairs(expected) do @@ -109,36 +109,36 @@ end return true end - - + + function test.isfalse(value) if (value) then test.fail("expected false but was true") end end - + function test.isnil(value) if (value ~= nil) then test.fail("expected nil but was " .. tostring(value)) end end - - + + function test.isnotnil(value) if (value == nil) then test.fail("expected not nil") end end - - + + function test.istrue(value) if (not value) then test.fail("expected true but was false") end end - + function test.openedfile(fname) if fname ~= test.value_openedfilename then local msg = "expected to open file '" .. fname .. "'" @@ -148,8 +148,8 @@ test.fail(msg) end end - - + + function test.success(fn, ...) local ok, err = pcall(fn, unpack(arg)) if not ok then @@ -172,14 +172,14 @@ end } end - + local function stub_io_output(f) end - + local function stub_print(s) end - - + + -- -- Define a collection for the test suites -- @@ -213,13 +213,13 @@ return true end end - + local function test_run(suite, fn) io.capture() return pcall(fn) end - + local function test_teardown(suite, fn) if suite.teardown then @@ -230,42 +230,58 @@ end - function test.runall() + function test.runall(suitename, testname) test.print = print print = stub_print io.open = stub_io_open io.output = stub_io_output - + local numpassed = 0 local numfailed = 0 local start_time = os.clock() - for suitename, suitetests in pairs(T) do - for testname, testfunc in pairs(suitetests) do - - if suitetests.setup ~= testfunc and suitetests.teardown ~= testfunc then - local ok, err = test_setup(suitetests, testfunc) - - if ok then - ok, err = test_run(suitetests, testfunc) - end - - local tok, terr = test_teardown(suitetests, testfunc) - ok = ok and tok - err = err or tok - - if (not ok) then - test.print(string.format("%s.%s: %s", suitename, testname, err)) - numfailed = numfailed + 1 - else - numpassed = numpassed + 1 - end + + function runtest(suitename, suitetests, testname, testfunc) + if suitetests.setup ~= testfunc and suitetests.teardown ~= testfunc then + local ok, err = test_setup(suitetests, testfunc) + + if ok then + ok, err = test_run(suitetests, testfunc) + end + + local tok, terr = test_teardown(suitetests, testfunc) + ok = ok and tok + err = err or terr + + if (not ok) then + test.print(string.format("%s.%s: %s", suitename, testname, err)) + numfailed = numfailed + 1 + else + numpassed = numpassed + 1 + end + end + end + + function runsuite(suitename, suitetests, testname) + if testname then + runtest(suitename, suitetests, testname, suitetests[testname]) + else + for testname, testfunc in pairs(suitetests) do + runtest(suitename, suitetests, testname, testfunc) end - end end + + if suitename then + runsuite(suitename, T[suitename], testname) + else + for suitename, suitetests in pairs(T) do + runsuite(suitename, suitetests, testname) + end + end + io.write('running time : ', os.clock() - start_time,'\n') print = test.print - return numpassed, numfailed + return numpassed, numfailed end - + -- cgit v1.2.3