aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cmd/test-bot.rb39
1 files changed, 23 insertions, 16 deletions
diff --git a/Library/Homebrew/cmd/test-bot.rb b/Library/Homebrew/cmd/test-bot.rb
index 16784bc3b..31e4bc5be 100644
--- a/Library/Homebrew/cmd/test-bot.rb
+++ b/Library/Homebrew/cmd/test-bot.rb
@@ -112,31 +112,38 @@ module Homebrew
return
end
+ verbose = ARGV.verbose?
+ puts if verbose
+ @output = ""
+ working_dir = Pathname.new(@command.first == "git" ? @repository : Dir.pwd)
start_time = Time.now
+ read, write = IO.pipe
- log = log_file_path
-
- pid = fork do
- File.open(log, "wb") do |f|
- STDOUT.reopen(f)
- STDERR.reopen(f)
+ begin
+ pid = fork do
+ read.close
+ $stdout.reopen(write)
+ $stderr.reopen(write)
+ write.close
+ working_dir.cd { exec(*@command) }
+ end
+ write.close
+ while line = read.gets
+ puts line if verbose
+ @output += line
end
- Dir.chdir(@repository) if @command.first == "git"
- exec(*@command)
+ ensure
+ read.close
end
- Process.wait(pid)
+ Process.wait(pid)
@time = Time.now - start_time
-
@status = $?.success? ? :passed : :failed
puts_result
- if File.exist?(log)
- @output = fix_encoding File.read(log)
- if has_output? and (failed? or @puts_output_on_success)
- puts @output
- end
- FileUtils.rm(log) unless ARGV.include? "--keep-logs"
+ if has_output?
+ puts @output if (failed? or @puts_output_on_success) && !verbose
+ File.write(log_file_path, @output) if ARGV.include? "--keep-logs"
end
exit 1 if ARGV.include?("--fail-fast") && @status == :failed