test-bot: print output if ARGV.verbose?
Closes Homebrew/homebrew#39078. Signed-off-by: Xu Cheng <xucheng@me.com>
This commit is contained in:
parent
a76a6b2a9b
commit
9ed00fc7fa
@ -112,31 +112,38 @@ module Homebrew
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
verbose = ARGV.verbose?
|
||||||
|
puts if verbose
|
||||||
|
@output = ""
|
||||||
|
working_dir = Pathname.new(@command.first == "git" ? @repository : Dir.pwd)
|
||||||
start_time = Time.now
|
start_time = Time.now
|
||||||
|
read, write = IO.pipe
|
||||||
|
|
||||||
log = log_file_path
|
begin
|
||||||
|
|
||||||
pid = fork do
|
pid = fork do
|
||||||
File.open(log, "wb") do |f|
|
read.close
|
||||||
STDOUT.reopen(f)
|
$stdout.reopen(write)
|
||||||
STDERR.reopen(f)
|
$stderr.reopen(write)
|
||||||
|
write.close
|
||||||
|
working_dir.cd { exec(*@command) }
|
||||||
end
|
end
|
||||||
Dir.chdir(@repository) if @command.first == "git"
|
write.close
|
||||||
exec(*@command)
|
while line = read.gets
|
||||||
|
puts line if verbose
|
||||||
|
@output += line
|
||||||
end
|
end
|
||||||
|
ensure
|
||||||
|
read.close
|
||||||
|
end
|
||||||
|
|
||||||
Process.wait(pid)
|
Process.wait(pid)
|
||||||
|
|
||||||
@time = Time.now - start_time
|
@time = Time.now - start_time
|
||||||
|
|
||||||
@status = $?.success? ? :passed : :failed
|
@status = $?.success? ? :passed : :failed
|
||||||
puts_result
|
puts_result
|
||||||
|
|
||||||
if File.exist?(log)
|
if has_output?
|
||||||
@output = fix_encoding File.read(log)
|
puts @output if (failed? or @puts_output_on_success) && !verbose
|
||||||
if has_output? and (failed? or @puts_output_on_success)
|
File.write(log_file_path, @output) if ARGV.include? "--keep-logs"
|
||||||
puts @output
|
|
||||||
end
|
|
||||||
FileUtils.rm(log) unless ARGV.include? "--keep-logs"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
exit 1 if ARGV.include?("--fail-fast") && @status == :failed
|
exit 1 if ARGV.include?("--fail-fast") && @status == :failed
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user