From e4045fa7e55fb69ffad69ba19e470889684b60d7 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 10 Nov 2012 09:36:58 +0000 Subject: [PATCH] brew-test-bot: general cleanup. --- Library/Contributions/cmds/brew-test-bot.rb | 30 ++++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/Library/Contributions/cmds/brew-test-bot.rb b/Library/Contributions/cmds/brew-test-bot.rb index 29bdd50412..d5cfa12813 100755 --- a/Library/Contributions/cmds/brew-test-bot.rb +++ b/Library/Contributions/cmds/brew-test-bot.rb @@ -70,21 +70,29 @@ class Step end end - def self.run test, command, output_on_success = false + def self.run test, command, puts_output = false step = new test, command step.puts_command - command = "#{step.command} &>#{step.log_file_path}" - if command.start_with? 'git ' - Dir.chdir step.repository { `#{command}` } - else - `#{command}` + command = "#{step.command}" + unless puts_output and not ARGV.include? "--log" + command += " &>#{step.log_file_path}" end + output = nil + if command.start_with? 'git ' + Dir.chdir step.repository do + output = `#{command}` + end + else + output = `#{command}` + end + output = IO.read(step.log_file_path) if ARGV.include? "--log" + step.status = $?.success? ? :passed : :failed step.puts_result - puts IO.read(step.log_file_path) if output_on_success step.write_html + puts output if puts_output and output and not output.empty? end end @@ -215,8 +223,8 @@ class Test test "brew audit #{formula}" test "brew install --verbose --build-bottle #{formula}" return unless steps.last.status == :passed - test "brew test #{formula}" if defined? Formula.factory(formula).test test "brew bottle #{formula}", true + test "brew test #{formula}" if defined? Formula.factory(formula).test test "brew uninstall #{formula}" end @@ -230,7 +238,9 @@ class Test if ARGV.include? "--cleanup" test "git fetch origin" test "git reset --hard origin/master" + test "brew cleanup" test "git clean --force -dx" + test "git gc" else unless ARGV.include? "--skip-cleanup" git('diff --exit-code HEAD 2>/dev/null') @@ -240,8 +250,8 @@ class Test end end - def test cmd, output_on_success = false - Step.run self, cmd, output_on_success + def test cmd, puts_output = false + Step.run self, cmd, puts_output end def check_results