2013-02-15 23:57:34 +00:00
|
|
|
--
|
|
|
|
-- tests/api/test_containers.lua
|
|
|
|
-- Tests the API's solution() and project() container definitions.
|
2014-04-25 15:53:01 +00:00
|
|
|
-- Copyright (c) 2013-2014 Jason Perkins and the Premake project
|
2013-02-15 23:57:34 +00:00
|
|
|
--
|
|
|
|
|
|
|
|
local suite = test.declare("api_containers")
|
|
|
|
local api = premake.api
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Setup and teardown
|
|
|
|
--
|
|
|
|
|
|
|
|
local sln
|
|
|
|
|
|
|
|
function suite.setup()
|
|
|
|
sln = solution("MySolution")
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- The first time a name is encountered, a new container should be created.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.solution_createsOnFirstUse()
|
|
|
|
test.isnotnil(premake.solution.get("MySolution"))
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.project_createsOnFirstUse()
|
|
|
|
project("MyProject")
|
2013-09-13 15:52:00 +00:00
|
|
|
test.isnotnil(premake.solution.getproject(sln, "MyProject"))
|
2013-02-15 23:57:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- When a container is created, it should become the active scope.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.solution_setsActiveScope()
|
2013-11-20 18:26:52 +00:00
|
|
|
test.issame(api.scope.solution, sln)
|
2013-02-15 23:57:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.project_setsActiveScope()
|
|
|
|
local prj = project("MyProject")
|
2013-11-20 18:26:52 +00:00
|
|
|
test.issame(api.scope.project, prj)
|
2013-02-15 23:57:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- When container function is called with no arguments, that should
|
|
|
|
-- become the current scope.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.solution_setsActiveScope_onNoArgs()
|
|
|
|
project("MyProject")
|
|
|
|
group("MyGroup")
|
|
|
|
solution()
|
2013-11-20 18:26:52 +00:00
|
|
|
test.issame(sln, api.scope.solution)
|
2013-02-15 23:57:34 +00:00
|
|
|
test.isnil(api.scope.project)
|
|
|
|
test.isnil(api.scope.group)
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.project_setsActiveScope_onNoArgs()
|
|
|
|
local prj = project("MyProject")
|
|
|
|
group("MyGroup")
|
|
|
|
project()
|
2013-11-20 18:26:52 +00:00
|
|
|
test.issame(prj, api.scope.project)
|
2013-02-15 23:57:34 +00:00
|
|
|
end
|
|
|
|
|
2013-10-24 13:59:24 +00:00
|
|
|
|
|
|
|
--
|
|
|
|
-- The "*" name should activate the parent scope.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.solution_onStar()
|
|
|
|
project("MyProject")
|
|
|
|
group("MyGroup")
|
2014-04-25 15:53:01 +00:00
|
|
|
filter("Debug")
|
2013-10-24 13:59:24 +00:00
|
|
|
solution "*"
|
|
|
|
test.isnil(api.scope.solution)
|
|
|
|
test.isnil(api.scope.project)
|
|
|
|
test.isnil(api.scope.group)
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.project_onStar()
|
|
|
|
project("MyProject")
|
|
|
|
group("MyGroup")
|
2014-04-25 15:53:01 +00:00
|
|
|
filter("Debug")
|
2013-10-24 13:59:24 +00:00
|
|
|
project "*"
|
2013-11-20 18:26:52 +00:00
|
|
|
test.issame(sln, api.scope.solution)
|
2013-10-24 13:59:24 +00:00
|
|
|
test.isnil(api.scope.project)
|
|
|
|
end
|