Skip to content
Snippets Groups Projects
Commit 0cbdeeaa authored by Mike McQuaid's avatar Mike McQuaid
Browse files

Exit with bad exit code on command failures.

parent 61444ee3
No related branches found
No related tags found
No related merge requests found
......@@ -420,7 +420,7 @@ module Homebrew extend self
if errors
puts "#{problem_count} problems in #{brew_count} brews"
exit 1
Homebrew.failed = true
end
end
end
......@@ -4,8 +4,16 @@ require 'tab'
module Homebrew extend self
def bottle_formula f
return onoe "Formula not installed: #{f.name}" unless f.installed?
return onoe "Formula not installed with '--build-bottle': #{f.name}" unless built_bottle? f
unless f.installed?
onoe "Formula not installed: #{f.name}"
Homebrew.failed = true
return
end
unless built_bottle? f
onoe "Formula not installed with '--build-bottle': #{f.name}"
Homebrew.failed = true
end
directory = Pathname.pwd
filename = bottle_filename f
......
......@@ -879,22 +879,19 @@ end # end class Checks
module Homebrew extend self
def doctor
raring_to_brew = true
checks = Checks.new
checks.methods.select{ |method| method =~ /^check_/ }.sort.each do |method|
out = checks.send(method)
unless out.nil? or out.empty?
puts unless raring_to_brew
puts unless Homebrew.failed?
lines = out.to_s.split('\n')
opoo lines.shift
puts lines
raring_to_brew = false
Homebrew.failed = true
end
end
puts "Your system is raring to brew." if raring_to_brew
exit raring_to_brew ? 0 : 1
puts "Your system is raring to brew." unless Homebrew.failed?
end
end
......@@ -77,6 +77,7 @@ module Homebrew extend self
fi.finish
rescue CannotInstallFormulaError => e
onoe e.message
Homebrew.failed = true
end
end
end
......
......@@ -13,21 +13,24 @@ module Homebrew extend self
# Cannot test uninstalled formulae
unless f.installed?
puts "#{f.name} not installed"
Homebrew.failed = true
next
end
# Cannot test formulae without a test method
unless f.respond_to? :test
puts "#{f.name} defines no test"
Homebrew.failed = true
next
end
puts "Testing #{f.name}"
begin
# tests can also return false to indicate failure
puts "#{f.name}: failed" if f.test == false
raise if f.test == false
rescue
puts "#{f.name}: failed"
Homebrew.failed = true
end
end
end
......
......@@ -35,5 +35,6 @@ module Homebrew extend self
rescue MultipleVersionsInstalledError => e
onoe e
puts "Use `brew remove --force #{e.name}` to remove all versions."
Homebrew.failed = true
end
end
......@@ -67,9 +67,11 @@ module Homebrew extend self
installer.finish
rescue CannotInstallFormulaError => e
onoe e
Homebrew.failed = true
rescue BuildError => e
e.dump
puts
Homebrew.failed = true
ensure
# restore previous installation state if build failed
outdated_keg.link if outdated_keg and not f.installed? rescue nil
......
......@@ -79,6 +79,9 @@ HOMEBREW_CURL_ARGS = '-qf#LA'
require 'fileutils'
module Homebrew extend self
include FileUtils
attr_accessor :failed
alias_method :failed?, :failed
end
FORMULA_META_FILES = %w[README README.md ChangeLog CHANGES COPYING LICENSE LICENCE COPYRIGHT AUTHORS]
......
......@@ -112,4 +112,6 @@ rescue Exception => e
puts " #{Tty.em}#{ISSUES_URL}#{Tty.reset}"
puts e.backtrace
exit 1
else
exit 1 if Homebrew.failed?
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment