2013-02-01 19:54:14 +00:00
|
|
|
--
|
|
|
|
-- tests/base/test_validation.lua
|
|
|
|
-- Verify the project information sanity checking.
|
2014-04-25 15:53:01 +00:00
|
|
|
-- Copyright (c) 2013-20124 Jason Perkins and the Premake project
|
2013-02-01 19:54:14 +00:00
|
|
|
--
|
|
|
|
|
|
|
|
local suite = test.declare("premake_validation")
|
|
|
|
|
2014-11-21 22:04:43 +00:00
|
|
|
local p = premake
|
|
|
|
|
2013-02-01 19:54:14 +00:00
|
|
|
|
|
|
|
--
|
|
|
|
-- Setup
|
|
|
|
--
|
|
|
|
|
2014-11-21 22:04:43 +00:00
|
|
|
local function validate()
|
|
|
|
return pcall(function() p.container.validate(p.api.rootContainer()) end)
|
2013-02-01 19:54:14 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Validate should pass if the minimum requirements are met.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.passes_onSane()
|
|
|
|
solution "MySolution"
|
|
|
|
configurations { "Debug", "Release" }
|
|
|
|
project "MyProject"
|
|
|
|
kind "ConsoleApp"
|
|
|
|
language "C++"
|
2014-11-21 22:04:43 +00:00
|
|
|
test.istrue(validate())
|
2013-02-01 19:54:14 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Fail if no configurations are present on the solution.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.fails_onNoSolutionConfigs()
|
|
|
|
solution "MySolution"
|
|
|
|
project "MyProject"
|
|
|
|
kind "ConsoleApp"
|
|
|
|
language "C++"
|
2014-11-21 22:04:43 +00:00
|
|
|
test.isfalse(validate())
|
2013-02-01 19:54:14 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Fail on duplicate project UUIDs.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.fails_onDuplicateProjectIDs()
|
|
|
|
solution "MySolution"
|
|
|
|
configurations { "Debug", "Release" }
|
|
|
|
kind "ConsoleApp"
|
|
|
|
language "C++"
|
|
|
|
project "MyProject1"
|
|
|
|
uuid "D4110D7D-FB18-4A1C-A75B-CA432F4FE770"
|
|
|
|
project "MyProject2"
|
|
|
|
uuid "D4110D7D-FB18-4A1C-A75B-CA432F4FE770"
|
2014-11-21 22:04:43 +00:00
|
|
|
test.isfalse(validate())
|
2013-02-01 19:54:14 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Fail if no kind is set on the configuration.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.fails_onNoConfigKind()
|
|
|
|
solution "MySolution"
|
|
|
|
configurations { "Debug", "Release" }
|
|
|
|
project "MyProject"
|
|
|
|
language "C++"
|
2014-11-21 22:04:43 +00:00
|
|
|
test.isfalse(validate())
|
2013-02-01 19:54:14 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Warn if a configuration value is set in the wrong scope.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.warns_onSolutionStringField_inConfig()
|
|
|
|
solution "MySolution"
|
|
|
|
configurations { "Debug", "Release" }
|
2014-04-25 15:53:01 +00:00
|
|
|
filter "Debug"
|
2013-02-01 19:54:14 +00:00
|
|
|
startproject "MyProject"
|
|
|
|
project "MyProject"
|
|
|
|
kind "ConsoleApp"
|
|
|
|
language "C++"
|
2014-11-21 22:04:43 +00:00
|
|
|
validate()
|
2014-08-27 20:38:58 +00:00
|
|
|
test.stderr("'startproject' on config")
|
2013-02-01 19:54:14 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.warns_onProjectStringField_inConfig()
|
|
|
|
solution "MySolution"
|
|
|
|
configurations { "Debug", "Release" }
|
|
|
|
project "MyProject"
|
|
|
|
kind "ConsoleApp"
|
|
|
|
language "C++"
|
2014-04-25 15:53:01 +00:00
|
|
|
filter "Debug"
|
2013-02-01 19:54:14 +00:00
|
|
|
location "MyProject"
|
2014-11-21 22:04:43 +00:00
|
|
|
validate()
|
2013-02-01 19:54:14 +00:00
|
|
|
test.stderr("'location' on config")
|
|
|
|
end
|
|
|
|
|
|
|
|
function suite.warns_onProjectListField_inConfig()
|
|
|
|
solution "MySolution"
|
|
|
|
configurations { "Debug", "Release" }
|
|
|
|
project "MyProject"
|
|
|
|
kind "ConsoleApp"
|
|
|
|
language "C++"
|
2014-04-25 15:53:01 +00:00
|
|
|
filter "Debug"
|
2013-02-01 19:54:14 +00:00
|
|
|
configurations "Deployment"
|
2014-11-21 22:04:43 +00:00
|
|
|
validate()
|
2013-02-01 19:54:14 +00:00
|
|
|
test.stderr("'configurations' on config")
|
|
|
|
end
|
2014-10-20 19:41:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- If a rule is specified for inclusion, it must have been defined.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.fails_onNoSuchRule()
|
|
|
|
solution "MySolution"
|
|
|
|
configurations { "Debug", "Release" }
|
|
|
|
project "MyProject"
|
|
|
|
rules { "NoSuchRule" }
|
2014-11-21 22:04:43 +00:00
|
|
|
test.isfalse(validate())
|
2014-10-20 19:41:00 +00:00
|
|
|
end
|
|
|
|
|