2012-11-28 16:14:47 +00:00
|
|
|
--
|
|
|
|
-- tests/actions/vstudio/cs2005/test_build_events.lua
|
|
|
|
-- Check generation of pre- and post-build commands for C# projects.
|
2013-05-22 15:15:48 +00:00
|
|
|
-- Copyright (c) 2012-2013 Jason Perkins and the Premake project
|
2012-11-28 16:14:47 +00:00
|
|
|
--
|
|
|
|
|
2013-05-22 15:15:48 +00:00
|
|
|
local suite = test.declare("vstudio_cs2005_build_events")
|
2012-11-28 16:14:47 +00:00
|
|
|
local cs2005 = premake.vstudio.cs2005
|
|
|
|
|
|
|
|
|
|
|
|
--
|
2013-05-22 15:15:48 +00:00
|
|
|
-- Setup
|
2012-11-28 16:14:47 +00:00
|
|
|
--
|
|
|
|
|
2015-08-28 20:16:14 +00:00
|
|
|
local wks, prj, cfg
|
2013-05-22 15:15:48 +00:00
|
|
|
|
2012-11-28 16:14:47 +00:00
|
|
|
function suite.setup()
|
2015-10-14 12:04:22 +00:00
|
|
|
premake.action.set("vs2005")
|
2014-02-08 15:44:57 +00:00
|
|
|
premake.escaper(premake.vstudio.vs2010.esc)
|
2015-08-28 20:16:14 +00:00
|
|
|
wks = test.createWorkspace()
|
2012-11-28 16:14:47 +00:00
|
|
|
end
|
2013-05-22 15:15:48 +00:00
|
|
|
|
2012-11-28 16:14:47 +00:00
|
|
|
local function prepare(platform)
|
2015-08-30 15:38:35 +00:00
|
|
|
prj = test.getproject(wks, 1)
|
2012-11-28 16:14:47 +00:00
|
|
|
cs2005.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 [[
|
|
|
|
<PropertyGroup>
|
|
|
|
<PreBuildEvent>command1</PreBuildEvent>
|
|
|
|
</PropertyGroup>
|
|
|
|
]]
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.onlyOne_onPostBuildOnly()
|
|
|
|
postbuildcommands { "command1" }
|
|
|
|
prepare()
|
|
|
|
test.capture [[
|
|
|
|
<PropertyGroup>
|
|
|
|
<PostBuildEvent>command1</PostBuildEvent>
|
|
|
|
</PropertyGroup>
|
|
|
|
]]
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.both_onBoth()
|
|
|
|
prebuildcommands { "command1" }
|
|
|
|
postbuildcommands { "command2" }
|
|
|
|
prepare()
|
|
|
|
test.capture [[
|
|
|
|
<PropertyGroup>
|
|
|
|
<PreBuildEvent>command1</PreBuildEvent>
|
|
|
|
<PostBuildEvent>command2</PostBuildEvent>
|
|
|
|
</PropertyGroup>
|
|
|
|
]]
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
2014-01-09 23:06:03 +00:00
|
|
|
-- Multiple commands should be separated with un-escaped EOLs.
|
2012-11-28 16:14:47 +00:00
|
|
|
--
|
|
|
|
|
|
|
|
function suite.splits_onMultipleCommands()
|
|
|
|
postbuildcommands { "command1", "command2" }
|
|
|
|
prepare()
|
2014-01-09 23:06:03 +00:00
|
|
|
test.capture ("\t<PropertyGroup>\n\t\t<PostBuildEvent>command1\r\ncommand2</PostBuildEvent>\n\t</PropertyGroup>\n")
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Quotes should not be escaped, other special characters should.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.onSpecialChars()
|
|
|
|
postbuildcommands { '\' " < > &' }
|
|
|
|
prepare()
|
2012-11-28 16:14:47 +00:00
|
|
|
test.capture [[
|
|
|
|
<PropertyGroup>
|
2014-01-09 23:06:03 +00:00
|
|
|
<PostBuildEvent>' " < > &</PostBuildEvent>
|
2012-11-28 16:14:47 +00:00
|
|
|
</PropertyGroup>
|
|
|
|
]]
|
|
|
|
end
|