diff --git a/modules/self-test/test_helpers.lua b/modules/self-test/test_helpers.lua
index 0550245a..4faf2a8b 100644
--- a/modules/self-test/test_helpers.lua
+++ b/modules/self-test/test_helpers.lua
@@ -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)
diff --git a/tests/_tests.lua b/tests/_tests.lua
index 4d778e26..57a6966a 100644
--- a/tests/_tests.lua
+++ b/tests/_tests.lua
@@ -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",
diff --git a/tests/actions/vstudio/vc2010/test_rule_props.lua b/tests/actions/vstudio/vc2010/test_rule_props.lua
new file mode 100644
index 00000000..767f4102
--- /dev/null
+++ b/tests/actions/vstudio/vc2010/test_rule_props.lua
@@ -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 [[
+@echo off
+package-example-compiler.exe [output_path] "%(Identity)"
+ ]]
+ end
+
+--
+-- executionDescription
+--
+
+ function suite.executionDescription()
+ local r = test.getRule("example")
+ m.executionDescription(r)
+
+ test.capture [[
+Compiling %(Filename) with example-compiler...
+ ]]
+ end
+
diff --git a/tests/actions/vstudio/vc2010/test_rule_targets.lua b/tests/actions/vstudio/vc2010/test_rule_targets.lua
new file mode 100644
index 00000000..f17a3745
--- /dev/null
+++ b/tests/actions/vstudio/vc2010/test_rule_targets.lua
@@ -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 [[
+
+ _example
+
+ ]]
+ end
+
+
+--
+-- computedProperties
+--
+
+ function suite.computedProperties()
+ local r = test.getRule("example")
+ m.computedProperties(r)
+
+ test.capture [[
+
+
+ %(output_path)%(Filename).example.cc;%(output_path)%(Filename).example.h
+
+
+ ]]
+ end
+
+
+
+--
+-- usingTask
+--
+
+ function suite.usingTask()
+ local r = test.getRule("example")
+ m.usingTask(r)
+
+ test.capture [[
+
+ $(MSBuildThisFileDirectory)$(MSBuildThisFileName).xml
+
+ ]]
+ end
diff --git a/tests/base/test_context.lua b/tests/base/test_context.lua
index 6369fa1f..eeee0e8b 100644
--- a/tests/base/test_context.lua
+++ b/tests/base/test_context.lua
@@ -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