Skip to content

Commit ed4eee5

Browse files
authoredJun 13, 2024··
Merge pull request #9393 from joshcooper/uniquefile_9385
Check for nil before closing Uniquefile
2 parents a423af8 + 7296cce commit ed4eee5

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed
 

Diff for: ‎lib/puppet/util/execution.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ def self.execute(command, options = NoOptionsSpecified)
323323
unless options[:squelch]
324324
# if we opened a pipe, we need to clean it up.
325325
reader.close if reader
326-
stdout.close! if Puppet::Util::Platform.windows?
326+
stdout.close! if stdout && Puppet::Util::Platform.windows?
327327
end
328328
end
329329

Diff for: ‎spec/unit/util/execution_spec.rb

+9
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,15 @@ def expect_cwd_to_be(cwd)
834834

835835
Puppet::Util::Execution.execute('test command')
836836
end
837+
838+
it "should raise if it fails to create a Uniquefile for stdout" do
839+
allow(Puppet::FileSystem::Uniquefile).to receive(:new)
840+
.and_raise(Errno::ENOENT, 'C:\Users\ADMINI~1\AppData\Local\Temp\doesnotexist')
841+
842+
expect {
843+
Puppet::Util::Execution.execute('test command')
844+
}.to raise_error(Errno::ENOENT, 'No such file or directory - C:\Users\ADMINI~1\AppData\Local\Temp\doesnotexist')
845+
end
837846
end
838847

839848
it "should raise an error if failonfail is true and the child failed" do

0 commit comments

Comments
 (0)
Please sign in to comment.