aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/formula_installer.rb2
-rwxr-xr-xLibrary/Homebrew/test/unittest.rb18
-rw-r--r--Library/Homebrew/utils.rb22
3 files changed, 31 insertions, 11 deletions
diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb
index 498029d2f..9ab03c11f 100644
--- a/Library/Homebrew/formula_installer.rb
+++ b/Library/Homebrew/formula_installer.rb
@@ -60,7 +60,7 @@ class FormulaInstaller
exit! 1
end
end
- ignore_interrupts do
+ ignore_interrupts do # because child proc will get it and marshall it back
write.close
Process.wait
data = read.read
diff --git a/Library/Homebrew/test/unittest.rb b/Library/Homebrew/test/unittest.rb
index bfa84bfd9..90d9ecdbc 100755
--- a/Library/Homebrew/test/unittest.rb
+++ b/Library/Homebrew/test/unittest.rb
@@ -30,6 +30,24 @@ MACOS_VERSION=10.6
Dir.chdir HOMEBREW_PREFIX
at_exit { HOMEBREW_PREFIX.parent.rmtree }
+# for some reason our utils.rb safe_system behaves completely differently
+# during these tests. This is worrying for sure.
+def safe_system *args
+ Kernel.system *args
+end
+
+class ExecutionError <RuntimeError
+ attr :status
+
+ def initialize cmd, args=[], status=nil
+ super "Failure while executing: #{cmd} #{args*' '}"
+ @status = status
+ end
+end
+
+class BuildError <ExecutionError
+end
+
require 'test/unit' # must be after at_exit
require 'extend/ARGV' # needs to be after test/unit to avoid conflict with OptionsParser
ARGV.extend(HomebrewArgvExtension)
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb
index e30512ff9..d980c328c 100644
--- a/Library/Homebrew/utils.rb
+++ b/Library/Homebrew/utils.rb
@@ -69,27 +69,29 @@ def pretty_duration s
end
def interactive_shell
- pid=fork
- if pid.nil?
+ fork do
# TODO make the PS1 var change pls
#brown="\[\033[0;33m\]"
#reset="\[\033[0m\]"
#ENV['PS1']="Homebrew-#{HOMEBREW_VERSION} #{brown}\W#{reset}\$ "
exec ENV['SHELL']
end
- Process.wait pid
- raise SystemExit, "Aborting due to non-zero exit status" if $? != 0
+ Process.wait
+ unless $?.success?
+ puts "Aborting due to non-zero exit status"
+ exit $?
+ end
end
# Kernel.system but with exceptions
def safe_system cmd, *args
puts "#{cmd} #{args*' '}" if ARGV.verbose?
- exec_success = Kernel.system cmd, *args
- # some tools, eg. tar seem to confuse ruby and it doesn't propogate the
- # CTRL-C interrupt to us too, so execution continues, but the exit code is
- # still 2 so we raise our own interrupt
- raise Interrupt, cmd if $?.termsig == 2
- raise ExecutionError.new(cmd, args, $?) unless exec_success
+ fork do
+ trap("EXIT") {} # no bt on exit from this short-lived fork
+ exit! 1 unless exec(cmd, *args)
+ end
+ Process.wait
+ raise ExecutionError.new(cmd, args, $?) unless $?.success?
end
def curl *args