-- -- tests/actions/vstudio/vc2010/test_build_events.lua -- Check generation of pre- and post-build commands for C++ projects. -- Copyright (c) 2012-2013 Jason Perkins and the Premake project -- local p = premake local suite = test.declare("vstudio_vc2010_build_events") local vc2010 = p.vstudio.vc2010 -- -- Setup -- local wks, prj, cfg function suite.setup() p.action.set("vs2010") p.escaper(p.vstudio.vs2010.esc) wks = test.createWorkspace() end local function prepare(platform) prj = test.getproject(wks, 1) vc2010.buildEvents(prj) end -- -- If no build steps are specified, nothing should be written. -- function suite.noOutput_onNoEvents() prepare() test.isemptycapture() end -- -- If one command set is used and not the other, only the one should be written. -- function suite.onlyOne_onPreBuildOnly() prebuildcommands { "command1" } prepare() test.capture [[ command1 ]] end function suite.onlyOne_onPostBuildOnly() postbuildcommands { "command1" } prepare() test.capture [[ command1 ]] end function suite.both_onBoth() prebuildcommands { "command1" } postbuildcommands { "command2" } prepare() test.capture [[ command1 command2 ]] end -- -- Multiple commands should be separated with un-escaped EOLs. -- function suite.splits_onMultipleCommands() postbuildcommands { "command1", "command2" } prepare() test.capture ("\n\tcommand1\r\ncommand2\n\n") end -- -- Multiple of the same command should be emit. -- function suite.onCommandTwice() postbuildcommands { "command", "command" } prepare() test.capture ("\n\tcommand\r\ncommand\n\n") end -- -- Quotes should not be escaped, other special characters should. -- function suite.onSpecialChars() postbuildcommands { '\' " < > &' } prepare() test.capture [[ ' " < > & ]] end -- -- If a message is specified, it should be included. -- function suite.onMessageProvided() postbuildcommands { "command1" } postbuildmessage "Post-building..." prepare() test.capture [[ command1 Post-building... ]] end