aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/formula.rb6
-rw-r--r--Library/Homebrew/global.rb7
-rwxr-xr-xLibrary/Homebrew/test/configure_fails.tar.gzbin0 -> 196 bytes
-rw-r--r--Library/Homebrew/test/test_formula_install.rb12
-rw-r--r--Library/Homebrew/test/testball.rb15
-rw-r--r--Library/Homebrew/test/testing_env.rb16
6 files changed, 53 insertions, 3 deletions
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb
index 284161853..2d25d248b 100644
--- a/Library/Homebrew/formula.rb
+++ b/Library/Homebrew/formula.rb
@@ -205,6 +205,12 @@ class Formula
onoe e.inspect
puts e.backtrace
ohai "Rescuing build..."
+ if (e.was_running_configure? rescue false) and File.exist? 'config.log'
+ puts "It looks like an autotools configure failed."
+ puts "Gist 'config.log' and any error output when reporting an issue."
+ puts
+ end
+
puts "When you exit this shell Homebrew will attempt to finalise the installation."
puts "If nothing is installed or the shell exits with a non-zero error code,"
puts "Homebrew will abort. The installation prefix is:"
diff --git a/Library/Homebrew/global.rb b/Library/Homebrew/global.rb
index cb889bbb3..06cca3859 100644
--- a/Library/Homebrew/global.rb
+++ b/Library/Homebrew/global.rb
@@ -44,13 +44,18 @@ RECOMMENDED_GCC_42 = (MACOS_VERSION >= 10.6) ? 5646 : 5577
class ExecutionError <RuntimeError
- attr :exit_status
+ attr :exit_status, :command
def initialize cmd, args = [], es = nil
+ @command = cmd
super "Failure while executing: #{cmd} #{pretty(args)*' '}"
@exit_status = es.exitstatus rescue 1
end
+ def was_running_configure?
+ @command == './configure'
+ end
+
private
def pretty args
diff --git a/Library/Homebrew/test/configure_fails.tar.gz b/Library/Homebrew/test/configure_fails.tar.gz
new file mode 100755
index 000000000..8be00ee46
--- /dev/null
+++ b/Library/Homebrew/test/configure_fails.tar.gz
Binary files differ
diff --git a/Library/Homebrew/test/test_formula_install.rb b/Library/Homebrew/test/test_formula_install.rb
index eb2dcb491..db1a2b103 100644
--- a/Library/Homebrew/test/test_formula_install.rb
+++ b/Library/Homebrew/test/test_formula_install.rb
@@ -21,6 +21,18 @@ class TestScriptFileFormula <ScriptFileFormula
end
+class ConfigureTests < Test::Unit::TestCase
+ def test_detect_failed_configure
+ f=ConfigureFails.new
+ begin
+ f.brew { f.install }
+ rescue ExecutionError => e
+ assert e.was_running_configure?
+ end
+ end
+end
+
+
class InstallTests < Test::Unit::TestCase
def temporary_install f
# Brew and install the given formula
diff --git a/Library/Homebrew/test/testball.rb b/Library/Homebrew/test/testball.rb
index 6393342e5..58af9d2b7 100644
--- a/Library/Homebrew/test/testball.rb
+++ b/Library/Homebrew/test/testball.rb
@@ -12,3 +12,18 @@ class TestBall <Formula
prefix.install "libexec"
end
end
+
+class ConfigureFails <Formula
+ # name parameter required for some Formula::factory
+ def initialize name=nil
+ @url="file:///#{TEST_FOLDER}/configure_fails.tar.gz"
+ @homepage = 'http://example.com/'
+ @version = '1.0.0'
+ @md5 = '9385e1b68ab8af68ac2c35423443159b'
+ super "configurefails"
+ end
+
+ def install
+ system "./configure"
+ end
+end
diff --git a/Library/Homebrew/test/testing_env.rb b/Library/Homebrew/test/testing_env.rb
index 0f243607e..dbe3d1687 100644
--- a/Library/Homebrew/test/testing_env.rb
+++ b/Library/Homebrew/test/testing_env.rb
@@ -26,15 +26,21 @@ at_exit { HOMEBREW_PREFIX.parent.rmtree }
# Test fixtures and files can be found relative to this path
TEST_FOLDER = Pathname.new(ABS__FILE__).parent.realpath
-
+# Note: These exceptions duplicate those defined in globals.
+# Perhaps the same definitions should be used in both places.
class ExecutionError <RuntimeError
- attr :exit_status
+ attr :exit_status, :command
def initialize cmd, args = [], es = nil
+ @command = cmd
super "Failure while executing: #{cmd} #{pretty(args)*' '}"
@exit_status = es.exitstatus rescue 1
end
+ def was_running_configure?
+ @command == './configure'
+ end
+
private
def pretty args
@@ -49,6 +55,12 @@ class ExecutionError <RuntimeError
end
class BuildError <ExecutionError
+ attr :env
+
+ def initialize cmd, args = [], es = nil
+ super
+ @env = ENV.to_hash
+ end
end
require 'test/unit' # must be after at_exit