Skip to content

Commit

Permalink
Merge pull request #9393 from joshcooper/uniquefile_9385
Browse files Browse the repository at this point in the history
Check for nil before closing Uniquefile
  • Loading branch information
mhashizume committed Jun 13, 2024
2 parents a423af8 + 7296cce commit ed4eee5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/puppet/util/execution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ def self.execute(command, options = NoOptionsSpecified)
unless options[:squelch]
# if we opened a pipe, we need to clean it up.
reader.close if reader
stdout.close! if Puppet::Util::Platform.windows?
stdout.close! if stdout && Puppet::Util::Platform.windows?
end
end

Expand Down
9 changes: 9 additions & 0 deletions spec/unit/util/execution_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,15 @@ def expect_cwd_to_be(cwd)

Puppet::Util::Execution.execute('test command')
end

it "should raise if it fails to create a Uniquefile for stdout" do
allow(Puppet::FileSystem::Uniquefile).to receive(:new)
.and_raise(Errno::ENOENT, 'C:\Users\ADMINI~1\AppData\Local\Temp\doesnotexist')

expect {
Puppet::Util::Execution.execute('test command')
}.to raise_error(Errno::ENOENT, 'No such file or directory - C:\Users\ADMINI~1\AppData\Local\Temp\doesnotexist')
end
end

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

0 comments on commit ed4eee5

Please sign in to comment.