Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for nil before closing Uniquefile #9393

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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