aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike McQuaid2013-05-25 21:32:43 +0100
committerMike McQuaid2013-05-25 21:32:56 +0100
commitb1f00c57573bcb852f97cdbd863ba664635e9ab2 (patch)
treeaa08b0f96ecb75523e675a2d0f2ebdab1bcbb0f2
parent05f92b5c98775b554a609d10c96f6c55377045be (diff)
downloadbrew-b1f00c57573bcb852f97cdbd863ba664635e9ab2.tar.bz2
brew-test-bot: add optional JUnit support.
-rwxr-xr-xLibrary/Contributions/cmd/brew-test-bot.rb43
1 files changed, 30 insertions, 13 deletions
diff --git a/Library/Contributions/cmd/brew-test-bot.rb b/Library/Contributions/cmd/brew-test-bot.rb
index 2ada7baa7..a3364f5df 100755
--- a/Library/Contributions/cmd/brew-test-bot.rb
+++ b/Library/Contributions/cmd/brew-test-bot.rb
@@ -6,15 +6,17 @@
# --keep-logs: Write and keep log files under ./brewbot/
# --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.
require 'formula'
require 'utils'
require 'date'
+require 'erb'
HOMEBREW_CONTRIBUTED_CMDS = HOMEBREW_REPOSITORY + "Library/Contributions/cmd/"
class Step
- attr_reader :command, :repository
+ attr_reader :command, :repository, :name
attr_accessor :status
def initialize test, command
@@ -269,17 +271,16 @@ class Test
status == :passed
end
- def self.run argument
- test = new argument
- test.cleanup_before
- test.download
- test.setup unless ARGV.include? "--skip-setup"
- test.formulae.each do |formula|
- test.formula formula
+ def run
+ cleanup_before
+ download
+ setup unless ARGV.include? "--skip-setup"
+ formulae.each do |f|
+ formula(f)
end
- test.homebrew if test.core_changed
- test.cleanup_after
- test.check_results
+ homebrew if core_changed
+ cleanup_after
+ check_results
end
end
@@ -287,11 +288,27 @@ if Pathname.pwd == HOMEBREW_PREFIX and ARGV.include? "--cleanup"
odie 'cannot use --cleanup from HOMEBREW_PREFIX as it will delete all output.'
end
+tests = []
any_errors = false
if ARGV.named.empty?
# With no arguments just build the most recent commit.
- any_errors = Test.run 'HEAD'
+ test = Test.new('HEAD')
+ any_errors = test.run
+ tests << test
else
- ARGV.named.each { |argument| any_errors = Test.run(argument) or any_errors }
+ ARGV.named.each do |argument|
+ test = Test.new(argument)
+ any_errors = test.run or any_errors
+ tests << test
+ end
end
+
+if ARGV.include? "--junit"
+ xml_erb = HOMEBREW_CONTRIBUTED_CMDS + "brew-test-bot.xml.erb"
+ erb = ERB.new IO.read xml_erb
+ open("brew-test-bot.xml", "w") do |xml|
+ xml.write erb.result binding
+ end
+end
+
exit any_errors ? 0 : 1