2009-07-16 14:29:08 +00:00
|
|
|
--
|
|
|
|
-- tests/base/test_action.lua
|
|
|
|
-- Automated test suite for the action list.
|
|
|
|
-- Copyright (c) 2009 Jason Perkins and the Premake project
|
|
|
|
--
|
|
|
|
|
|
|
|
T.action = { }
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Setup/teardown
|
|
|
|
--
|
|
|
|
|
|
|
|
local fake = {
|
|
|
|
trigger = "fake",
|
|
|
|
description = "Fake action used for testing",
|
|
|
|
}
|
|
|
|
|
|
|
|
function T.action.setup()
|
2009-08-11 00:11:48 +00:00
|
|
|
premake.action.list["fake"] = fake
|
2009-08-11 00:49:11 +00:00
|
|
|
solution "MySolution"
|
|
|
|
configurations "Debug"
|
|
|
|
project "MyProject"
|
|
|
|
premake.buildconfigs()
|
2009-07-16 14:29:08 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function T.action.teardown()
|
2009-08-11 00:11:48 +00:00
|
|
|
premake.action.list["fake"] = nil
|
2009-07-16 14:29:08 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--
|
2009-08-11 00:49:11 +00:00
|
|
|
-- Tests for call()
|
2009-07-16 14:29:08 +00:00
|
|
|
--
|
|
|
|
|
2009-08-11 00:49:11 +00:00
|
|
|
function T.action.CallCallsExecuteIfPresent()
|
2009-07-16 14:29:08 +00:00
|
|
|
local called = false
|
|
|
|
fake.execute = function () called = true end
|
|
|
|
premake.action.call("fake")
|
|
|
|
test.istrue(called)
|
|
|
|
end
|
2009-08-11 00:49:11 +00:00
|
|
|
|
|
|
|
function T.action.CallCallsOnSolutionIfPresent()
|
|
|
|
local called = false
|
|
|
|
fake.onsolution = function () called = true end
|
|
|
|
premake.action.call("fake")
|
|
|
|
test.istrue(called)
|
|
|
|
end
|
|
|
|
|
|
|
|
function T.action.CallCallsOnProjectIfPresent()
|
|
|
|
local called = false
|
|
|
|
fake.onproject = function () called = true end
|
|
|
|
premake.action.call("fake")
|
|
|
|
test.istrue(called)
|
|
|
|
end
|
2009-07-16 14:29:08 +00:00
|
|
|
|
2009-08-11 00:49:11 +00:00
|
|
|
function T.action.CallSkipsCallbacksIfNotPresent()
|
2009-07-16 14:29:08 +00:00
|
|
|
test.success(premake.action.call, "fake")
|
|
|
|
end
|
2009-09-29 18:32:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Tests for set()
|
|
|
|
--
|
|
|
|
|
|
|
|
function T.action.set_SetsActionOS()
|
2009-09-29 19:27:33 +00:00
|
|
|
local oldos = _OS
|
2009-09-29 18:32:34 +00:00
|
|
|
_OS = "linux"
|
|
|
|
premake.action.set("vs2008")
|
|
|
|
test.isequal(_OS, "windows")
|
2009-09-29 19:27:33 +00:00
|
|
|
_OS = oldos
|
2009-09-29 18:32:34 +00:00
|
|
|
end
|