diff --git a/cmd/brewcask-ci.rb b/cmd/brewcask-ci.rb index 837c6a3aa4..7174e64a5a 100755 --- a/cmd/brewcask-ci.rb +++ b/cmd/brewcask-ci.rb @@ -15,6 +15,9 @@ module Hbc raise CaskError, "This command isn’t meant to be run locally." end + $stdout.sync = true + $stderr.sync = true + unless tap raise CaskError, "This command must be run from inside a tap directory." end @@ -96,7 +99,15 @@ module Hbc Travis.fold travis_id do print "#{Tty.bold}#{Tty.yellow}#{name}#{Tty.reset} " - $stdout.flush + + real_stdout = $stdout.dup + + travis_wait = Thread.new do + loop do + sleep 595 + real_stdout.print "\u200b" + end + end success, output = capture do begin @@ -107,9 +118,12 @@ module Hbc end end + travis_wait.kill + travis_wait.join + if success puts Formatter.success("✔") - puts output + puts output unless output.empty? else puts Formatter.error("✘") end @@ -118,9 +132,6 @@ module Hbc puts output unless success success - ensure - $stdout.flush - $stderr.flush end def tap diff --git a/cmd/lib/capture.rb b/cmd/lib/capture.rb index b300fa0217..b93204ad18 100644 --- a/cmd/lib/capture.rb +++ b/cmd/lib/capture.rb @@ -12,7 +12,6 @@ def capture begin yield ensure - w.flush w.close end end diff --git a/cmd/lib/travis.rb b/cmd/lib/travis.rb index 0a7bec1819..ac96a997a8 100644 --- a/cmd/lib/travis.rb +++ b/cmd/lib/travis.rb @@ -4,34 +4,28 @@ module Travis @start = {} def fold(id, &block) - begin - puts fold_start(id) - time(rand(2**32).to_s(16), &block) - ensure - puts fold_end(id) - $stdout.flush - $stderr.flush - end + print fold_start(id) + time(rand(2**32).to_s(16), &block) + print fold_end(id) end def fold_start(id) - "travis_fold:start:#{id}" + "travis_fold:start:#{id}\r\033[0K" end def fold_end(id) - "travis_fold:end:#{id}" + "travis_fold:end:#{id}\r\033[0K" end def time(id) - puts time_start(id) + print time_start(id) yield - ensure - puts time_end(id) + print time_end(id) end def time_start(id) @start[id] = Time.now - "travis_time:start:#{id}" + "travis_time:start:#{id}\r\033[0K" end def time_end(id) @@ -39,6 +33,6 @@ module Travis finish = (Time.now.to_f * 1_000_000_000).to_i duration = finish - start - "travis_time:end:#{id},start=#{start},finish=#{finish},duration=#{duration}" + "travis_time:end:#{id},start=#{start},finish=#{finish},duration=#{duration}\r\033[0K" end end