aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew
diff options
context:
space:
mode:
authorXu Cheng2015-04-27 23:42:35 +0800
committerXu Cheng2015-04-27 23:59:59 +0800
commit9ed00fc7faca2159fc317c48caad369632700f95 (patch)
treeaff013ac34e1c938ae8a608196e3151e71a67597 /Library/Homebrew
parenta76a6b2a9b089ef9a7c4b3a2ecf1655961b3b88f (diff)
downloadbrew-9ed00fc7faca2159fc317c48caad369632700f95.tar.bz2
test-bot: print output if ARGV.verbose?
Closes Homebrew/homebrew#39078. Signed-off-by: Xu Cheng <xucheng@me.com>
Diffstat (limited to 'Library/Homebrew')
-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