Skip to content

Commit

Permalink
Merge pull request #617 from Blizzard/fix-rules-xml
Browse files Browse the repository at this point in the history
fix switch/separator in rules_xml
  • Loading branch information
tvandijck authored Jun 13, 2017
2 parents 34bb100 + 21631dd commit 9d4fa01
Show file tree
Hide file tree
Showing 2 changed files with 143 additions and 9 deletions.
26 changes: 20 additions & 6 deletions src/actions/vstudio/vs2010_rules_xml.lua
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@
function m.boolProperty(def)
p.push('<BoolProperty')
m.baseProperty(def)
p.w('Switch="%s" />', def.switch or "[value]")
if def.switch then
p.w('Switch="%s"', def.switch)
end
p.w('/>')
p.pop()
end

Expand All @@ -166,10 +169,13 @@
p.w('Name="%d"', key)
if switches[key] then
p.w('DisplayName="%s"', values[key])
p.w('Switch="%s" />', switches[key])
if switches[key] then
p.w('Switch="%s"', switches[key])
end
else
p.w('DisplayName="%s" />', values[key])
p.w('DisplayName="%s"', values[key])
end
p.w('/>')
p.pop()
end

Expand All @@ -180,16 +186,24 @@
function m.stringProperty(def)
p.push('<StringProperty')
m.baseProperty(def)
p.w('Switch="%s" />', def.switch or "[value]")
if def.switch then
p.w('Switch="%s"', def.switch)
end
p.w('/>')
p.pop()
end


function m.stringListProperty(def)
p.push('<StringListProperty')
m.baseProperty(def)
p.w('Separator="%s"', def.separator or " ")
p.w('Switch="%s" />', def.switch or "[value]")
if def.separator then
p.w('Separator="%s"', def.separator)
end
if def.switch then
p.w('Switch="%s"', def.switch)
end
p.w('/>')
p.pop()
end

Expand Down
126 changes: 123 additions & 3 deletions tests/actions/vstudio/vc2010/test_rule_xml.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
-- Property definitions
---

function suite.properties_onString()
function suite.properties_onStringNoSwitch()
createVar { name="MyVar", kind="string" }
local r = test.getRule("MyRule")
m.properties(r)
Expand All @@ -43,7 +43,21 @@
Name="MyVar"
HelpContext="0"
DisplayName="MyVar"
Switch="[value]" />
/>
]]
end

function suite.properties_onString()
createVar { name="MyVar", kind="string", switch="[value]" }
local r = test.getRule("MyRule")
m.properties(r)
test.capture [[
<StringProperty
Name="MyVar"
HelpContext="0"
DisplayName="MyVar"
Switch="[value]"
/>
]]
end

Expand All @@ -56,6 +70,112 @@
Name="MyVar"
HelpContext="0"
DisplayName="MyVar"
Switch="[value]" />
/>
]]
end


function suite.properties_onBooleanNoSwitch()
createVar { name="MyVar", kind="boolean" }
local r = test.getRule("MyRule")
m.properties(r)
test.capture [[
<BoolProperty
Name="MyVar"
HelpContext="0"
DisplayName="MyVar"
/>
]]
end

function suite.properties_onBoolean()
createVar { name="MyVar", kind="boolean", switch="[value]" }
local r = test.getRule("MyRule")
m.properties(r)
test.capture [[
<BoolProperty
Name="MyVar"
HelpContext="0"
DisplayName="MyVar"
Switch="[value]"
/>
]]
end

function suite.properties_onEnum()
createVar {
name = "OptimizationLevel",
display = "Optimization Level",
values = {
[0] = "None",
[1] = "Size",
[2] = "Speed",
},
switch = {
[0] = "-O0",
[1] = "-O1",
[2] = "-O3",
},
value = 2,
}

local r = test.getRule("MyRule")
m.properties(r)
test.capture [[
<EnumProperty
Name="OptimizationLevel"
HelpContext="0"
DisplayName="Optimization Level">
<EnumValue
Name="0"
DisplayName="None"
Switch="-O0"
/>
<EnumValue
Name="1"
DisplayName="Size"
Switch="-O1"
/>
<EnumValue
Name="2"
DisplayName="Speed"
Switch="-O3"
/>
</EnumProperty>
]]
end

function suite.properties_onEnumNoSwitches()
createVar {
name = "OptimizationLevel",
display = "Optimization Level",
values = {
[0] = "None",
[1] = "Size",
[2] = "Speed",
},
value = 2,
}

local r = test.getRule("MyRule")
m.properties(r)
test.capture [[
<EnumProperty
Name="OptimizationLevel"
HelpContext="0"
DisplayName="Optimization Level">
<EnumValue
Name="0"
DisplayName="None"
/>
<EnumValue
Name="1"
DisplayName="Size"
/>
<EnumValue
Name="2"
DisplayName="Speed"
/>
</EnumProperty>
]]
end

0 comments on commit 9d4fa01

Please sign in to comment.