This repository has been archived on 2022-12-23. You can view files and clone it, but cannot push or open issues or pull requests.
fuck-premake-old2/tests/base/test_validation.lua

131 lines
2.6 KiB
Lua

--
-- tests/base/test_validation.lua
-- Verify the project information sanity checking.
-- Copyright (c) 2013-20124 Jason Perkins and the Premake project
--
local suite = test.declare("premake_validation")
local p = premake
--
-- Setup
--
local function validate()
return pcall(function() p.container.validate(p.api.rootContainer()) end)
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++"
test.istrue(validate())
end
--
-- Fail if no configurations are present on the solution.
--
function suite.fails_onNoSolutionConfigs()
solution "MySolution"
project "MyProject"
kind "ConsoleApp"
language "C++"
test.isfalse(validate())
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"
test.isfalse(validate())
end
--
-- Fail if no kind is set on the configuration.
--
function suite.fails_onNoConfigKind()
solution "MySolution"
configurations { "Debug", "Release" }
project "MyProject"
language "C++"
test.isfalse(validate())
end
--
-- Warn if a configuration value is set in the wrong scope.
--
function suite.warns_onSolutionStringField_inConfig()
solution "MySolution"
configurations { "Debug", "Release" }
filter "Debug"
startproject "MyProject"
project "MyProject"
kind "ConsoleApp"
language "C++"
validate()
test.stderr("'startproject' on config")
end
function suite.warns_onProjectStringField_inConfig()
solution "MySolution"
configurations { "Debug", "Release" }
project "MyProject"
kind "ConsoleApp"
language "C++"
filter "Debug"
location "MyProject"
validate()
test.stderr("'location' on config")
end
function suite.warns_onProjectListField_inConfig()
solution "MySolution"
configurations { "Debug", "Release" }
project "MyProject"
kind "ConsoleApp"
language "C++"
filter "Debug"
configurations "Deployment"
validate()
test.stderr("'configurations' on config")
end
--
-- 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" }
test.isfalse(validate())
end