summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Edwards <adamed@opscode.com>2014-03-29 16:22:25 -0700
committerAdam Edwards <adamed@opscode.com>2014-03-29 16:33:36 -0700
commit0c5e2151a3f9c6f9eb4344e79883f944d1de1b4d (patch)
tree6f8da05a4c97754c88026db3f87c9e68b0ecb296
parent43b3f4c0a48a5f6a5c242bb649f72239197b0097 (diff)
downloadchef-0c5e2151a3f9c6f9eb4344e79883f944d1de1b4d.tar.gz
Address regression with convert_boolean_return always set to true
-rw-r--r--lib/chef/provider/powershell_script.rb2
-rw-r--r--spec/functional/resource/powershell_spec.rb29
2 files changed, 29 insertions, 2 deletions
diff --git a/lib/chef/provider/powershell_script.rb b/lib/chef/provider/powershell_script.rb
index f3135f1a35..967b2d822b 100644
--- a/lib/chef/provider/powershell_script.rb
+++ b/lib/chef/provider/powershell_script.rb
@@ -44,7 +44,7 @@ class Chef
EXIT_STATUS_NORMALIZATION_SCRIPT )
convert_boolean_return = @new_resource.convert_boolean_return
@code = <<EOH
-new-variable -name interpolatedexitcode -visibility private -value #{convert_boolean_return}
+new-variable -name interpolatedexitcode -visibility private -value $#{convert_boolean_return}
new-variable -name chefscriptresult -visibility private
$chefscriptresult = {
#{target_code}
diff --git a/spec/functional/resource/powershell_spec.rb b/spec/functional/resource/powershell_spec.rb
index 9b5c498ea7..5001e870a9 100644
--- a/spec/functional/resource/powershell_spec.rb
+++ b/spec/functional/resource/powershell_spec.rb
@@ -111,6 +111,32 @@ describe Chef::Resource::WindowsScript::PowershellScript, :windows_only do
resource.run_action(:run)
end
+ it "returns 0 for $false as the last line of the script when convert_boolean_return is false" do
+ resource.code "$false"
+ resource.returns(0)
+ resource.run_action(:run)
+ end
+
+ it "returns 0 for $true as the last line of the script when convert_boolean_return is false" do
+ resource.code "$true"
+ resource.returns(0)
+ resource.run_action(:run)
+ end
+
+ it "returns 1 for $false as the last line of the script when convert_boolean_return is true" do
+ resource.convert_boolean_return true
+ resource.code "$false"
+ resource.returns(1)
+ resource.run_action(:run)
+ end
+
+ it "returns 0 for $true as the last line of the script when convert_boolean_return is true" do
+ resource.convert_boolean_return true
+ resource.code "$true"
+ resource.returns(0)
+ resource.run_action(:run)
+ end
+
it "executes a script with a 64-bit process on a 64-bit OS, otherwise a 32-bit process" do
resource.code(processor_architecture_script_content + " | out-file -encoding ASCII #{script_output_path}")
resource.returns(0)
@@ -360,11 +386,12 @@ describe Chef::Resource::WindowsScript::PowershellScript, :windows_only do
end
it "evaluates a simple boolean false as nonzero status code when convert_boolean_return is true for only_if" do
+ resource.convert_boolean_return true
resource.only_if "$false"
resource.should_skip?(:run).should be_true
end
- it "evaluates a simple boolean true as nonzero status code when convert_boolean_return is true for not_if" do
+ it "evaluates a simple boolean false as nonzero status code when convert_boolean_return is true for not_if" do
resource.convert_boolean_return true
resource.not_if "$false"
resource.should_skip?(:run).should be_false