Permalink
Browse files

Exit with bad exit code on command failures.

  • Loading branch information...
1 parent c6d37fb commit 48a82e5f023bfc3605306156d7eaa4e029d2d8ea @MikeMcQuaid MikeMcQuaid committed Mar 14, 2012
@@ -420,7 +420,7 @@ def audit
if errors
puts "#{problem_count} problems in #{brew_count} brews"
- exit 1
+ Homebrew.failed = true
end
end
end
@@ -4,8 +4,16 @@
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 @@ def check_os_version
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 @@ def install_formulae formulae
fi.finish
rescue CannotInstallFormulaError => e
onoe e.message
+ Homebrew.failed = true
end
end
end
@@ -13,21 +13,24 @@ def test
# 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 @@ def uninstall
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 @@ def upgrade_formula f
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 @@ def mkpath
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]
View
@@ -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 comments on commit 48a82e5

Please sign in to comment.