Add ofail command and fix bottle command output.

This commit is contained in:
Mike McQuaid 2012-04-30 14:08:59 +10:00
parent a1ce504e7d
commit fe969c21ad
9 changed files with 18 additions and 25 deletions

View File

@ -91,7 +91,7 @@ class Test
begin
Formula.factory arg
rescue FormulaUnavailableError
ofail "#{arg} is not a pull request number or formula." unless arg.to_i > 0
odie "#{arg} is not a pull request number or formula." unless arg.to_i > 0
@url = arg
@formulae = []
else
@ -214,7 +214,7 @@ class Test
test "git clean --force -dx"
else
`git diff --exit-code HEAD 2>/dev/null`
ofail "Uncommitted changes, aborting." unless $?.success?
odie "Uncommitted changes, aborting." unless $?.success?
test "git reset --hard #{@start_sha1}" if @start_sha1
end
end
@ -267,7 +267,7 @@ class Test
end
if ARGV.empty?
ofail 'This command requires at least one argument containing a pull request number or formula.'
odie 'This command requires at least one argument containing a pull request number or formula.'
end
Dir.chdir HOMEBREW_REPOSITORY

View File

@ -418,9 +418,6 @@ module Homebrew extend self
end
end
if errors
puts "#{problem_count} problems in #{brew_count} brews"
Homebrew.failed = true
end
ofail "#{problem_count} problems in #{brew_count} brews" if errors
end
end

View File

@ -5,14 +5,12 @@ require 'tab'
module Homebrew extend self
def bottle_formula f
unless f.installed?
onoe "Formula not installed: #{f.name}"
Homebrew.failed = true
return ofail "Formula not installed: #{f.name}"
return
end
unless built_bottle? f
onoe "Formula not installed with '--build-bottle': #{f.name}"
Homebrew.failed = true
return ofail "Formula not installed with '--build-bottle': #{f.name}"
end
directory = Pathname.pwd

View File

@ -904,9 +904,8 @@ module Homebrew extend self
unless out.nil? or out.empty?
puts unless Homebrew.failed?
lines = out.to_s.split('\n')
opoo lines.shift
ofail lines.shift
puts lines
Homebrew.failed = true
end
end

View File

@ -76,8 +76,7 @@ module Homebrew extend self
fi.caveats
fi.finish
rescue CannotInstallFormulaError => e
onoe e.message
Homebrew.failed = true
ofail e.message
end
end
end

View File

@ -12,15 +12,13 @@ module Homebrew extend self
ARGV.formulae.each do |f|
# Cannot test uninstalled formulae
unless f.installed?
puts "Testing requires the latest version of #{f.name}"
Homebrew.failed = true
ofail "Testing requires the latest version of #{f.name}"
next
end
# Cannot test formulae without a test method
unless f.respond_to? :test
puts "#{f.name} defines no test"
Homebrew.failed = true
ofail "#{f.name} defines no test"
next
end
@ -29,8 +27,7 @@ module Homebrew extend self
# tests can also return false to indicate failure
raise if f.test == false
rescue
puts "#{f.name}: failed"
Homebrew.failed = true
ofail "#{f.name}: failed"
end
end
end

View File

@ -33,8 +33,7 @@ module Homebrew extend self
end
end
rescue MultipleVersionsInstalledError => e
onoe e
ofail e
puts "Use `brew remove --force #{e.name}` to remove all versions."
Homebrew.failed = true
end
end

View File

@ -66,8 +66,7 @@ module Homebrew extend self
installer.caveats
installer.finish
rescue CannotInstallFormulaError => e
onoe e
Homebrew.failed = true
ofail e
rescue BuildError => e
e.dump
puts

View File

@ -54,6 +54,11 @@ def onoe error
end
def ofail error
onoe error
Homebrew.failed = true
end
def odie error
onoe error
exit 1
end