From 157e084cef71c31af86d751ccd55410fa3611885 Mon Sep 17 00:00:00 2001 From: Pete Higgins Date: Fri, 26 Jun 2020 13:38:57 -0700 Subject: Update tests and docs for umask on Windows. Signed-off-by: Pete Higgins --- lib/chef/resource.rb | 2 +- spec/unit/resource_spec.rb | 33 +++++++++++++++++++++++++-------- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb index 37e964a243..bd6757c6f7 100644 --- a/lib/chef/resource.rb +++ b/lib/chef/resource.rb @@ -460,7 +460,7 @@ class Chef property :umask, String, desired_state: false, introduced: "16.2", - description: "Set a umask to be used for the duration of converging the resource. Defaults to `nil`, which means to use the system umask." + description: "Set a umask to be used for the duration of converging the resource. Defaults to `nil`, which means to use the system umask. Unsupported on Windows because Windows lacks a direct equivalent to UNIX's umask." # The time it took (in seconds) to run the most recently-run action. Not # cumulative across actions. This is set to 0 as soon as a new action starts diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb index 5181414215..7a19e0e8e1 100644 --- a/spec/unit/resource_spec.rb +++ b/spec/unit/resource_spec.rb @@ -1255,19 +1255,36 @@ describe Chef::Resource do expect(block_value).to eq(original_umask) end - it "changes the umask in the block to the set value" do - resource.umask = "0123" + if windows? + it "is a no-op on Windows" do + resource.umask = "0123" - block_value = nil + block_value = nil - resource.with_umask do - block_value = ::File.umask + resource.with_umask do + block_value = ::File.umask + end + + # Format the returned value so a potential error message is easier to understand. + actual_value = block_value.to_s(8).rjust(4, "0") + + expect(actual_value).to eq("0000") end + else + it "changes the umask in the block to the set value" do + resource.umask = "0123" + + block_value = nil - # Format the returned value so a potential error message is easier to understand. - actual_value = block_value.to_s(8).rjust(4, "0") + resource.with_umask do + block_value = ::File.umask + end - expect(actual_value).to eq("0123") + # Format the returned value so a potential error message is easier to understand. + actual_value = block_value.to_s(8).rjust(4, "0") + + expect(actual_value).to eq("0123") + end end it "resets the umask afterwards" do -- cgit v1.2.1