Adding some tests.
This commit is contained in:
parent
8b7b4c1139
commit
d2580bab86
@ -53,6 +53,11 @@
|
||||
end
|
||||
|
||||
|
||||
function m.getRule(name)
|
||||
p.oven.bake()
|
||||
return p.global.getRule(name)
|
||||
end
|
||||
|
||||
|
||||
function m.getProject(wks, i)
|
||||
wks = m.getWorkspace(wks)
|
||||
|
@ -131,6 +131,8 @@ return {
|
||||
"actions/vstudio/vc2010/test_project_refs.lua",
|
||||
"actions/vstudio/vc2010/test_prop_sheet.lua",
|
||||
"actions/vstudio/vc2010/test_resource_compile.lua",
|
||||
"actions/vstudio/vc2010/test_rule_props.lua",
|
||||
"actions/vstudio/vc2010/test_rule_targets.lua",
|
||||
"actions/vstudio/vc2010/test_rule_vars.lua",
|
||||
"actions/vstudio/vc2010/test_target_machine.lua",
|
||||
"actions/vstudio/vc2010/test_user_file.lua",
|
||||
|
71
tests/actions/vstudio/vc2010/test_rule_props.lua
Normal file
71
tests/actions/vstudio/vc2010/test_rule_props.lua
Normal file
@ -0,0 +1,71 @@
|
||||
--
|
||||
-- tests/actions/vstudio/vc2010/vstudio_vs2010_rule_props.lua
|
||||
-- Validate generation of custom rules
|
||||
-- Author Tom van Dijck
|
||||
-- Copyright (c) 2016 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local suite = test.declare("vstudio_vs2010_rule_props")
|
||||
|
||||
local vc2010 = premake.vstudio.vc2010
|
||||
local m = premake.vstudio.vs2010.rules.props
|
||||
|
||||
|
||||
--
|
||||
-- Setup
|
||||
--
|
||||
|
||||
local wks, prj
|
||||
|
||||
function suite.setup()
|
||||
premake.action.set("vs2010")
|
||||
rule 'example'
|
||||
display 'Example compiler'
|
||||
fileExtension '.example'
|
||||
|
||||
propertydefinition {
|
||||
name = "output_path",
|
||||
kind = "string",
|
||||
display = "Output Path",
|
||||
description = "",
|
||||
}
|
||||
|
||||
buildmessage 'Compiling %{file.basename} with example-compiler...'
|
||||
buildcommands {
|
||||
'package-example-compiler.exe %{output_path} "%{file.relpath}"'
|
||||
}
|
||||
buildoutputs {
|
||||
'%{output_path}%{file.basename}.example.cc',
|
||||
'%{output_path}%{file.basename}.example.h'
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- commandLineTemplates
|
||||
--
|
||||
|
||||
function suite.commandLineTemplates()
|
||||
local r = test.getRule("example")
|
||||
m.commandLineTemplates(r)
|
||||
|
||||
test.capture [[
|
||||
<CommandLineTemplate>@echo off
|
||||
package-example-compiler.exe [output_path] "%(Identity)"</CommandLineTemplate>
|
||||
]]
|
||||
end
|
||||
|
||||
--
|
||||
-- executionDescription
|
||||
--
|
||||
|
||||
function suite.executionDescription()
|
||||
local r = test.getRule("example")
|
||||
m.executionDescription(r)
|
||||
|
||||
test.capture [[
|
||||
<ExecutionDescription>Compiling %(Filename) with example-compiler...</ExecutionDescription>
|
||||
]]
|
||||
end
|
||||
|
97
tests/actions/vstudio/vc2010/test_rule_targets.lua
Normal file
97
tests/actions/vstudio/vc2010/test_rule_targets.lua
Normal file
@ -0,0 +1,97 @@
|
||||
--
|
||||
-- tests/actions/vstudio/vc2010/vstudio_vs2010_rule_targets.lua
|
||||
-- Validate generation of custom rules
|
||||
-- Author Tom van Dijck
|
||||
-- Copyright (c) 2016 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
local suite = test.declare("vstudio_vs2010_rule_targets")
|
||||
|
||||
local vc2010 = premake.vstudio.vc2010
|
||||
local m = premake.vstudio.vs2010.rules.targets
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Setup
|
||||
--
|
||||
|
||||
local wks, prj
|
||||
|
||||
function suite.setup()
|
||||
premake.action.set("vs2010")
|
||||
rule 'example'
|
||||
display 'Example compiler'
|
||||
fileExtension '.example'
|
||||
|
||||
propertydefinition {
|
||||
name = "output_path",
|
||||
kind = "string",
|
||||
display = "Output Path",
|
||||
description = "",
|
||||
}
|
||||
|
||||
buildmessage 'Compiling %{file.basename} with example-compiler...'
|
||||
buildcommands {
|
||||
'package-example-compiler.exe %{output_path} "%{file.relpath}"'
|
||||
}
|
||||
buildoutputs {
|
||||
'%{output_path}%{file.basename}.example.cc',
|
||||
'%{output_path}%{file.basename}.example.h'
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- availableItemName
|
||||
--
|
||||
|
||||
function suite.availableItemName()
|
||||
local r = test.getRule("example")
|
||||
m.availableItemName(r)
|
||||
|
||||
test.capture [[
|
||||
<AvailableItemName Include="example">
|
||||
<Targets>_example</Targets>
|
||||
</AvailableItemName>
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- computedProperties
|
||||
--
|
||||
|
||||
function suite.computedProperties()
|
||||
local r = test.getRule("example")
|
||||
m.computedProperties(r)
|
||||
|
||||
test.capture [[
|
||||
<ItemDefinitionGroup>
|
||||
<example>
|
||||
<Outputs>%(output_path)%(Filename).example.cc;%(output_path)%(Filename).example.h</Outputs>
|
||||
</example>
|
||||
</ItemDefinitionGroup>
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- usingTask
|
||||
--
|
||||
|
||||
function suite.usingTask()
|
||||
local r = test.getRule("example")
|
||||
m.usingTask(r)
|
||||
|
||||
test.capture [[
|
||||
<UsingTask
|
||||
TaskName="example"
|
||||
TaskFactory="XamlTaskFactory"
|
||||
AssemblyName="Microsoft.Build.Tasks.v4.0">
|
||||
<Task>$(MSBuildThisFileDirectory)$(MSBuildThisFileName).xml</Task>
|
||||
</UsingTask>
|
||||
]]
|
||||
end
|
@ -51,3 +51,25 @@
|
||||
configset.store(cset, field.get("targetname"), "MyProject%{1 + 1}")
|
||||
test.isequal("MyProject2", ctx.targetname)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Token environment in extended context overrides context.
|
||||
--
|
||||
|
||||
function suite.extent()
|
||||
-- set in toplevel context.
|
||||
configset.store(cset, field.get("targetname"), "%{value}")
|
||||
|
||||
-- detoken in toplevel context should result in empty string.
|
||||
test.isequal("", ctx.targetname)
|
||||
|
||||
-- create an extended context with a local environ.
|
||||
local environ = {
|
||||
value = "text"
|
||||
}
|
||||
local ext = context.extent(ctx, environ)
|
||||
|
||||
-- detoken in extended context should result in value set in that environ.
|
||||
test.isequal("text", ext.targetname)
|
||||
end
|
||||
|
Reference in New Issue
Block a user