Merge pull request #3515 from sjackman/popen

Utils.popen_read: Nonexistent program should fail
This commit is contained in:
Mike McQuaid 2017-12-03 09:23:01 +00:00 committed by GitHub
commit 0d53831b90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View File

@ -15,6 +15,12 @@ describe Utils do
).to eq("success")
expect($CHILD_STATUS).to be_a_success
end
it "fails when the command does not exist" do
expect(subject.popen_read("./nonexistent", err: :out))
.to eq("brew: command not found: ./nonexistent\n")
expect($CHILD_STATUS).to be_a_failure
end
end
describe "::popen_write" do

View File

@ -14,7 +14,15 @@ module Utils
yield pipe
else
options[:err] ||= :close unless ENV["HOMEBREW_STDERR"]
begin
exec(*args, options)
rescue Errno::ENOENT
$stderr.puts "brew: command not found: #{args[0]}" unless options[:err] == :close
exit! 127
rescue SystemCallError
$stderr.puts "brew: exec failed: #{args[0]}" unless options[:err] == :close
exit! 1
end
end
end
end