diff --git a/Library/Contributions/cmd/brew-test-bot.rb b/Library/Contributions/cmd/brew-test-bot.rb index baf0e9c939..80abe24043 100755 --- a/Library/Contributions/cmd/brew-test-bot.rb +++ b/Library/Contributions/cmd/brew-test-bot.rb @@ -7,6 +7,7 @@ # --cleanup: Clean the Homebrew directory. Very dangerous. Use with care. # --skip-setup: Don't check the local system is setup correctly. # --junit: Generate a JUnit XML test results file. +# --email: Generate an email subject file. require 'formula' require 'utils' @@ -377,4 +378,24 @@ if ARGV.include? "--junit" end end +if ARGV.include? "--email" + failed_steps = [] + tests.each do |test| + test.steps.each do |step| + next unless step.failed? + failed_steps << step.command.gsub(/(brew|--verbose) /, '') + end + end + + if failed_steps.empty? + email_subject = 'brew test-bot: PASSED' + else + email_subject = "brew test-bot: FAILED: #{failed_steps.join ', '}" + end + + File.open "brew test-bot.email.txt", 'w' do |file| + file.write email_subject + end +end + exit any_errors ? 0 : 1