aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cmd/test-bot.rb
diff options
context:
space:
mode:
Diffstat (limited to 'Library/Homebrew/cmd/test-bot.rb')
-rw-r--r--Library/Homebrew/cmd/test-bot.rb158
1 files changed, 79 insertions, 79 deletions
diff --git a/Library/Homebrew/cmd/test-bot.rb b/Library/Homebrew/cmd/test-bot.rb
index 6a14c3d05..0336796ca 100644
--- a/Library/Homebrew/cmd/test-bot.rb
+++ b/Library/Homebrew/cmd/test-bot.rb
@@ -23,19 +23,19 @@
# --ci-upload: Homebrew CI bottle upload.
# --ci-reset-and-update: Homebrew CI repository and tap reset and update.
-require 'formula'
-require 'utils'
-require 'date'
-require 'rexml/document'
-require 'rexml/xmldecl'
-require 'rexml/cdata'
-require 'cmd/tap'
+require "formula"
+require "utils"
+require "date"
+require "rexml/document"
+require "rexml/xmldecl"
+require "rexml/cdata"
+require "cmd/tap"
module Homebrew
EMAIL_SUBJECT_FILE = "brew-test-bot.#{MacOS.cat}.email.txt"
BYTES_IN_1_MEGABYTE = 1024*1024
- def homebrew_git_repo tap=nil
+ def homebrew_git_repo(tap = nil)
if tap
user, repo = tap.split "/"
HOMEBREW_LIBRARY/"Taps/#{user}/homebrew-#{repo}"
@@ -47,7 +47,7 @@ module Homebrew
class Step
attr_reader :command, :name, :status, :output, :time
- def initialize test, command, options={}
+ def initialize(test, command, options = {})
@test = test
@category = test.category
@command = command
@@ -92,7 +92,7 @@ module Homebrew
cmd = @command.join(" ")
print "#{Tty.blue}==>#{Tty.white} #{cmd}#{Tty.reset}"
tabs = (80 - "PASSED".length + 1 - cmd.length) / 8
- tabs.times{ print "\t" }
+ tabs.times { print "\t" }
$stdout.flush
end
@@ -129,8 +129,8 @@ module Homebrew
end
write.close
while line = read.gets
- puts line if verbose
- @output += line
+ puts line if verbose
+ @output += line
end
ensure
read.close
@@ -143,7 +143,7 @@ module Homebrew
if has_output?
@output = fix_encoding(@output)
- puts @output if (failed? or @puts_output_on_success) && !verbose
+ puts @output if (failed? || @puts_output_on_success) && !verbose
File.write(log_file_path, @output) if ARGV.include? "--keep-logs"
end
@@ -174,7 +174,7 @@ module Homebrew
class Test
attr_reader :log_root, :category, :name, :steps
- def initialize argument, tap=nil
+ def initialize(argument, tap = nil)
@hash = nil
@url = nil
@formulae = []
@@ -208,7 +208,7 @@ module Homebrew
end
def no_args?
- @hash == 'HEAD'
+ @hash == "HEAD"
end
def git(*args)
@@ -231,23 +231,23 @@ module Homebrew
end
def download
- def shorten_revision revision
+ def shorten_revision(revision)
git("rev-parse", "--short", revision).strip
end
def current_sha1
- shorten_revision 'HEAD'
+ shorten_revision "HEAD"
end
def current_branch
git("symbolic-ref", "HEAD").gsub("refs/heads/", "").strip
end
- def single_commit? start_revision, end_revision
+ def single_commit?(start_revision, end_revision)
git("rev-list", "--count", "#{start_revision}..#{end_revision}").to_i == 1
end
- def diff_formulae start_revision, end_revision, path, filter
+ def diff_formulae(start_revision, end_revision, path, filter)
git(
"diff-tree", "-r", "--name-only", "--diff-filter=#{filter}",
start_revision, end_revision, "--", path
@@ -266,10 +266,10 @@ module Homebrew
@start_branch = current_branch
# Use Jenkins environment variables if present.
- if no_args? and ENV['GIT_PREVIOUS_COMMIT'] and ENV['GIT_COMMIT'] \
- and not ENV['ghprbPullLink']
- diff_start_sha1 = shorten_revision ENV['GIT_PREVIOUS_COMMIT']
- diff_end_sha1 = shorten_revision ENV['GIT_COMMIT']
+ if no_args? && ENV["GIT_PREVIOUS_COMMIT"] && ENV["GIT_COMMIT"] \
+ && !ENV["ghprbPullLink"]
+ diff_start_sha1 = shorten_revision ENV["GIT_PREVIOUS_COMMIT"]
+ diff_end_sha1 = shorten_revision ENV["GIT_COMMIT"]
brew_update
elsif @hash
diff_start_sha1 = current_sha1
@@ -280,14 +280,14 @@ module Homebrew
end
# Handle Jenkins pull request builder plugin.
- if ENV['ghprbPullLink']
- @url = ENV['ghprbPullLink']
+ if ENV["ghprbPullLink"]
+ @url = ENV["ghprbPullLink"]
@hash = nil
end
if no_args?
- if diff_start_sha1 == diff_end_sha1 or \
- single_commit?(diff_start_sha1, diff_end_sha1)
+ if diff_start_sha1 == diff_end_sha1 || \
+ single_commit?(diff_start_sha1, diff_end_sha1)
@name = diff_end_sha1
else
@name = "#{diff_start_sha1}-#{diff_end_sha1}"
@@ -302,8 +302,8 @@ module Homebrew
test "git", "checkout", diff_start_sha1
test "brew", "pull", "--clean", @url
diff_end_sha1 = current_sha1
- @short_url = @url.gsub('https://github.com/', '')
- if @short_url.include? '/commit/'
+ @short_url = @url.gsub("https://github.com/", "")
+ if @short_url.include? "/commit/"
# 7 characters should be enough for a commit (not 40).
@short_url.gsub!(/(commit\/\w{7}).*/, '\1')
@name = @short_url
@@ -319,7 +319,7 @@ module Homebrew
FileUtils.mkdir_p @log_root
return unless diff_start_sha1 != diff_end_sha1
- return if @url and not steps.last.passed?
+ return if @url && !steps.last.passed?
if @tap
formula_path = %w[Formula HomebrewFormula].find { |dir| (@repository/dir).directory? } || ""
@@ -332,11 +332,11 @@ module Homebrew
@formulae += @added_formulae + @modified_formula
end
- def skip formula_name
+ def skip(formula_name)
puts "#{Tty.blue}==>#{Tty.white} SKIPPING: #{formula_name}#{Tty.reset}"
end
- def satisfied_requirements? formula, spec, dependency=nil
+ def satisfied_requirements?(formula, spec, dependency = nil)
requirements = formula.send(spec).requirements
unsatisfied_requirements = requirements.reject do |requirement|
@@ -370,7 +370,7 @@ module Homebrew
test "brew", "config"
end
- def formula formula_name
+ def formula(formula_name)
@category = "#{__method__}.#{formula_name}"
canonical_formula_name = if @tap
@@ -384,7 +384,7 @@ module Homebrew
formula = Formulary.factory(canonical_formula_name)
formula.conflicts.map { |c| Formulary.factory(c.name) }.
- select { |f| f.installed? }.each do |conflict|
+ select(&:installed?).each do |conflict|
test "brew", "unlink", conflict.name
end
@@ -402,7 +402,7 @@ module Homebrew
return unless satisfied_requirements?(formula, :devel)
end
- if formula.devel && !ARGV.include?('--HEAD')
+ if formula.devel && !ARGV.include?("--HEAD")
deps |= formula.devel.deps.to_a
reqs |= formula.devel.requirements.to_a
end
@@ -448,8 +448,8 @@ module Homebrew
(installed & dependencies).each do |installed_dependency|
installed_dependency_formula = Formulary.factory(installed_dependency)
if installed_dependency_formula.installed? &&
- !installed_dependency_formula.keg_only? &&
- !installed_dependency_formula.linked_keg.exist?
+ !installed_dependency_formula.keg_only? &&
+ !installed_dependency_formula.linked_keg.exist?
test "brew", "link", installed_dependency
end
end
@@ -466,7 +466,7 @@ module Homebrew
dependents = Utils.popen_read("brew", "uses", "--skip-build", "--skip-optional", canonical_formula_name).split("\n")
dependents -= @formulae
- dependents = dependents.map {|d| Formulary.factory(d)}
+ dependents = dependents.map { |d| Formulary.factory(d) }
testable_dependents = dependents.select { |d| d.test_defined? && d.bottled? }
@@ -507,12 +507,12 @@ module Homebrew
audit_args << "--strict" << "--online" if @added_formulae.include? formula_name
test "brew", "audit", *audit_args
if install_passed
- if formula.stable? && !ARGV.include?('--no-bottle')
+ if formula.stable? && !ARGV.include?("--no-bottle")
bottle_args = ["--verbose", "--rb", canonical_formula_name]
bottle_args << { :puts_output_on_success => true }
test "brew", "bottle", *bottle_args
bottle_step = steps.last
- if bottle_step.passed? and bottle_step.has_output?
+ if bottle_step.passed? && bottle_step.has_output?
bottle_filename =
bottle_step.output.gsub(/.*(\.\/\S+#{bottle_native_regex}).*/m, '\1')
test "brew", "uninstall", "--force", canonical_formula_name
@@ -528,7 +528,7 @@ module Homebrew
unless dependent.installed?
test "brew", "fetch", "--retry", dependent.name
next if steps.last.failed?
- conflicts = dependent.conflicts.map { |c| Formulary.factory(c.name) }.select { |f| f.installed? }
+ conflicts = dependent.conflicts.map { |c| Formulary.factory(c.name) }.select(&:installed?)
conflicts.each do |conflict|
test "brew", "unlink", conflict.name
end
@@ -542,7 +542,7 @@ module Homebrew
test "brew", "uninstall", "--force", canonical_formula_name
end
- if formula.devel && formula.stable? && !ARGV.include?('--HEAD') \
+ if formula.devel && formula.stable? && !ARGV.include?("--HEAD") \
&& satisfied_requirements?(formula, :devel)
test "brew", "fetch", "--retry", "--devel", *formula_fetch_options
run_as_not_developer { test "brew", "install", "--devel", "--verbose", canonical_formula_name }
@@ -568,7 +568,7 @@ module Homebrew
def cleanup_before
@category = __method__
- return unless ARGV.include? '--cleanup'
+ return unless ARGV.include? "--cleanup"
git "stash"
git "am", "--abort"
git "rebase", "--abort"
@@ -576,25 +576,25 @@ module Homebrew
git "checkout", "-f", "master"
git "clean", "-ffdx"
pr_locks = "#{HOMEBREW_REPOSITORY}/.git/refs/remotes/*/pr/*/*.lock"
- Dir.glob(pr_locks) {|lock| FileUtils.rm_rf lock }
+ Dir.glob(pr_locks) { |lock| FileUtils.rm_rf lock }
end
def cleanup_after
@category = __method__
checkout_args = []
- if ARGV.include? '--cleanup'
+ if ARGV.include? "--cleanup"
test "git", "clean", "-ffdx"
checkout_args << "-f"
end
checkout_args << @start_branch
- if ARGV.include? '--cleanup' or @url or @hash
+ if ARGV.include?("--cleanup") || @url || @hash
test "git", "checkout", *checkout_args
end
- if ARGV.include? '--cleanup'
+ if ARGV.include? "--cleanup"
test "git", "reset", "--hard"
git "stash", "pop"
test "brew", "cleanup", "--prune=30"
@@ -635,7 +635,7 @@ module Homebrew
end
end
- changed_formulae = changed_formulae_dependents.sort do |a1,a2|
+ changed_formulae = changed_formulae_dependents.sort do |a1, a2|
a2[1].to_i <=> a1[1].to_i
end
changed_formulae.map!(&:first)
@@ -643,11 +643,11 @@ module Homebrew
changed_formulae + unchanged_formulae
end
- def head_only_tap? formula
+ def head_only_tap?(formula)
formula.head && formula.devel.nil? && formula.stable.nil? && formula.tap == "homebrew/homebrew-head-only"
end
- def devel_only_tap? formula
+ def devel_only_tap?(formula)
formula.devel && formula.stable.nil? && formula.tap == "homebrew/homebrew-devel-only"
end
@@ -665,17 +665,17 @@ module Homebrew
end
def test_bot
- tap = ARGV.value('tap')
+ tap = ARGV.value("tap")
- if !tap && ENV['UPSTREAM_BOT_PARAMS']
- bot_argv = ENV['UPSTREAM_BOT_PARAMS'].split " "
+ if !tap && ENV["UPSTREAM_BOT_PARAMS"]
+ bot_argv = ENV["UPSTREAM_BOT_PARAMS"].split " "
bot_argv.extend HomebrewArgvExtension
- tap ||= bot_argv.value('tap')
+ tap ||= bot_argv.value("tap")
end
tap.gsub!(/homebrew\/homebrew-/i, "Homebrew/") if tap
- git_url = ENV['UPSTREAM_GIT_URL'] || ENV['GIT_URL']
+ git_url = ENV["UPSTREAM_GIT_URL"] || ENV["GIT_URL"]
if !tap && git_url
# Also can get tap from Jenkins GIT_URL.
url_path = git_url.gsub(%r{^https?://github\.com/}, "").gsub(%r{/$}, "")
@@ -683,33 +683,33 @@ module Homebrew
tap = "#{$1}/#{$3}" if $1 && $3
end
- if Pathname.pwd == HOMEBREW_PREFIX and ARGV.include? "--cleanup"
- odie 'cannot use --cleanup from HOMEBREW_PREFIX as it will delete all output.'
+ if Pathname.pwd == HOMEBREW_PREFIX && ARGV.include?("--cleanup")
+ odie "cannot use --cleanup from HOMEBREW_PREFIX as it will delete all output."
end
if ARGV.include? "--email"
- File.open EMAIL_SUBJECT_FILE, 'w' do |file|
+ File.open EMAIL_SUBJECT_FILE, "w" do |file|
# The file should be written at the end but in case we don't get to that
# point ensure that we have something valid.
file.write "#{MacOS.version}: internal error."
end
end
- ENV['HOMEBREW_DEVELOPER'] = '1'
- ENV['HOMEBREW_NO_EMOJI'] = '1'
- if ARGV.include? '--ci-master' or ARGV.include? '--ci-pr' \
- or ARGV.include? '--ci-testing'
+ ENV["HOMEBREW_DEVELOPER"] = "1"
+ ENV["HOMEBREW_NO_EMOJI"] = "1"
+ if ARGV.include?("--ci-master") || ARGV.include?("--ci-pr") \
+ || ARGV.include?("--ci-testing")
ARGV << "--cleanup" if ENV["JENKINS_HOME"] || ENV["TRAVIS_COMMIT"]
ARGV << "--junit" << "--local"
end
- if ARGV.include? '--ci-master'
- ARGV << '--no-bottle' << '--email'
+ if ARGV.include? "--ci-master"
+ ARGV << "--no-bottle" << "--email"
end
- if ARGV.include? '--local'
- ENV['HOME'] = "#{Dir.pwd}/home"
- mkdir_p ENV['HOME']
- ENV['HOMEBREW_LOGS'] = "#{Dir.pwd}/logs"
+ if ARGV.include? "--local"
+ ENV["HOME"] = "#{Dir.pwd}/home"
+ mkdir_p ENV["HOME"]
+ ENV["HOMEBREW_LOGS"] = "#{Dir.pwd}/logs"
end
if ARGV.include? "--ci-reset-and-update"
@@ -733,10 +733,10 @@ module Homebrew
safe_system "brew", "tap", tap
end
- if ARGV.include? '--ci-upload'
- jenkins = ENV['JENKINS_HOME']
- job = ENV['UPSTREAM_JOB_NAME']
- id = ENV['UPSTREAM_BUILD_ID']
+ if ARGV.include? "--ci-upload"
+ jenkins = ENV["JENKINS_HOME"]
+ job = ENV["UPSTREAM_JOB_NAME"]
+ id = ENV["UPSTREAM_BUILD_ID"]
raise "Missing Jenkins variables!" if !jenkins || !job || !id
bintray_user = ENV["BINTRAY_USER"]
@@ -751,7 +751,7 @@ module Homebrew
ENV["JENKINS_SERVER_COOKIE"] = nil
ENV["HUDSON_COOKIE"] = nil
- ARGV << '--verbose'
+ ARGV << "--verbose"
bottles = Dir["#{jenkins}/jobs/#{job}/configurations/axis-version/*/builds/#{id}/archive/*.bottle*.*"]
return if bottles.empty?
@@ -762,8 +762,8 @@ module Homebrew
ENV["GIT_WORK_TREE"] = repository
ENV["GIT_DIR"] = "#{ENV["GIT_WORK_TREE"]}/.git"
- pr = ENV['UPSTREAM_PULL_REQUEST']
- number = ENV['UPSTREAM_BUILD_NUMBER']
+ pr = ENV["UPSTREAM_PULL_REQUEST"]
+ number = ENV["UPSTREAM_BUILD_NUMBER"]
system "git am --abort 2>/dev/null"
system "git rebase --abort 2>/dev/null"
@@ -839,7 +839,7 @@ module Homebrew
any_errors = false
if ARGV.named.empty?
# With no arguments just build the most recent commit.
- head_test = Test.new('HEAD', tap)
+ head_test = Test.new("HEAD", tap)
any_errors = !head_test.run
tests << head_test
else
@@ -913,12 +913,12 @@ module Homebrew
end
if failed_steps.empty?
- email_subject = ''
+ email_subject = ""
else
- email_subject = "#{MacOS.version}: #{failed_steps.join ', '}."
+ email_subject = "#{MacOS.version}: #{failed_steps.join ", "}."
end
- File.open EMAIL_SUBJECT_FILE, 'w' do |file|
+ File.open EMAIL_SUBJECT_FILE, "w" do |file|
file.write email_subject
end
end