Skip to content

Commit

Permalink
Merge pull request #1026 from Homebrew/rubocop_default_hash_syntax
Browse files Browse the repository at this point in the history
Use RuboCop default hash syntax.
  • Loading branch information
MikeMcQuaid committed Mar 7, 2024
2 parents 28f024e + 520f9c9 commit 74699c2
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 74 deletions.
4 changes: 2 additions & 2 deletions lib/step.rb
Expand Up @@ -88,7 +88,7 @@ def puts_github_actions_annotation(message, title, file, line)
:error
end

annotation = GitHub::Actions::Annotation.new(type, message, title: title, file: file, line: line)
annotation = GitHub::Actions::Annotation.new(type, message, title:, file:, line:)
puts annotation
end

Expand Down Expand Up @@ -151,7 +151,7 @@ def run(dry_run: false, fail_fast: false)

executable, *args = command

result = system_command executable, args: args,
result = system_command executable, args:,
print_stdout: @verbose,
print_stderr: @verbose,
env: @env
Expand Down
8 changes: 4 additions & 4 deletions lib/test.rb
Expand Up @@ -44,10 +44,10 @@ def info_header(text)
def test(*arguments, named_args: nil, env: {}, verbose: @verbose, ignore_failures: false)
step = Step.new(
arguments,
named_args: named_args,
env: env,
verbose: verbose,
ignore_failures: ignore_failures,
named_args:,
env:,
verbose:,
ignore_failures:,
repository: @repository,
)
step.run(dry_run: @dry_run, fail_fast: @fail_fast)
Expand Down
2 changes: 1 addition & 1 deletion lib/test_bot.rb
Expand Up @@ -134,7 +134,7 @@ def run!(args)
ENV["HOMEBREW_GIT_EMAIL"] = args.git_email ||
"[email protected]"

Homebrew.failed = !TestRunner.run!(tap, git: GIT, args: args)
Homebrew.failed = !TestRunner.run!(tap, git: GIT, args:)
end
end
end
16 changes: 8 additions & 8 deletions lib/test_formulae.rb
Expand Up @@ -123,12 +123,12 @@ def download_artifact_from_previous_run!(artifact_name, dry_run:)
return if pr_labels.include?("CI-no-bottle-cache") || pr_labels.include?("workflows")

variables = {
owner: owner,
repo: repo,
owner:,
repo:,
commit: sha,
}

response = GitHub::API.open_graphql(GRAPHQL_QUERY, variables: variables)
response = GitHub::API.open_graphql(GRAPHQL_QUERY, variables:)
check_suite_nodes = response.dig("repository", "object", "checkSuites", "nodes")
return if check_suite_nodes.blank?

Expand Down Expand Up @@ -163,7 +163,7 @@ def download_artifact_from_previous_run!(artifact_name, dry_run:)

# If we made it here, then we downloaded an `event_payload` artifact.
# We can now use this `event_payload` artifact to attempt to download the artifact we wanted.
download_artifact_from_previous_run!(artifact_name, dry_run: dry_run)
download_artifact_from_previous_run!(artifact_name, dry_run:)
rescue GitHub::API::AuthenticationFailedError => e
opoo e
end
Expand Down Expand Up @@ -224,7 +224,7 @@ def install_formula_from_bottle(formula_name, testing_formulae_dependents:, dry_
install_step = steps.last

if !dry_run && !testing_formulae_dependents && install_step.passed?
bottle_hash = local_bottle_hash(formula_name, bottle_dir: bottle_dir)
bottle_hash = local_bottle_hash(formula_name, bottle_dir:)
bottle_revision = bottle_hash.dig(formula_name, "formula", "tap_git_revision")
bottle_header = "Installed previously built bottle for #{formula_name} from:"
bottle_message = if @fetched_refs&.include?(bottle_revision)
Expand Down Expand Up @@ -258,14 +258,14 @@ def bottled?(formula, no_older_versions: false)
# up the dep tree when we encounter an `:all` bottle because
# a formula is not bottled unless its dependencies are.
if formula.bottle_specification.tag?(Utils::Bottles.tag(:all))
formula.deps.all? { |dep| bottled?(dep.to_formula, no_older_versions: no_older_versions) }
formula.deps.all? { |dep| bottled?(dep.to_formula, no_older_versions:) }
else
formula.bottle_specification.tag?(Utils::Bottles.tag, no_older_versions: no_older_versions)
formula.bottle_specification.tag?(Utils::Bottles.tag, no_older_versions:)
end
end

def bottled_or_built?(formula, built_formulae, no_older_versions: false)
bottled?(formula, no_older_versions: no_older_versions) || built_formulae.include?(formula.full_name)
bottled?(formula, no_older_versions:) || built_formulae.include?(formula.full_name)
end

def downloads_using_homebrew_curl?(formula)
Expand Down
58 changes: 29 additions & 29 deletions lib/test_runner.rb
Expand Up @@ -53,17 +53,17 @@ def run!(tap, git:, args:)

test_bot_args.each do |argument|
skip_cleanup_after = argument != test_bot_args.last
current_tests = build_tests(argument, tap: tap,
git: git,
output_paths: output_paths,
skip_setup: skip_setup,
skip_cleanup_before: skip_cleanup_before,
skip_cleanup_after: skip_cleanup_after,
args: args)
current_tests = build_tests(argument, tap:,
git:,
output_paths:,
skip_setup:,
skip_cleanup_before:,
skip_cleanup_after:,
args:)
skip_setup = true
skip_cleanup_before = true
tests += current_tests.values
run_tests(current_tests, args: args)
run_tests(current_tests, args:)
end

failed_steps = tests.map(&:failed_steps)
Expand Down Expand Up @@ -140,51 +140,51 @@ def build_tests(argument, tap:, git:, output_paths:, skip_setup:,
args.added_formulae.nil? &&
args.deleted_formulae.nil?
if no_formulae_flags && (no_only_args || args.only_formulae? || args.only_formulae_detect?)
tests[:formulae_detect] = Tests::FormulaeDetect.new(argument, tap: tap,
git: git,
tests[:formulae_detect] = Tests::FormulaeDetect.new(argument, tap:,
git:,
dry_run: args.dry_run?,
fail_fast: args.fail_fast?,
verbose: args.verbose?)
end

if no_only_args || args.only_formulae?
tests[:formulae] = Tests::Formulae.new(tap: tap,
git: git,
tests[:formulae] = Tests::Formulae.new(tap:,
git:,
dry_run: args.dry_run?,
fail_fast: args.fail_fast?,
verbose: args.verbose?,
output_paths: output_paths)
output_paths:)
end

if !args.skip_dependents? && (no_only_args || args.only_formulae? || args.only_formulae_dependents?)
tests[:formulae_dependents] = Tests::FormulaeDependents.new(tap: tap,
git: git,
tests[:formulae_dependents] = Tests::FormulaeDependents.new(tap:,
git:,
dry_run: args.dry_run?,
fail_fast: args.fail_fast?,
verbose: args.verbose?)
end

if args.cleanup?
if !skip_cleanup_before && (no_only_args || args.only_cleanup_before?)
tests[:cleanup_before] = Tests::CleanupBefore.new(tap: tap,
git: git,
tests[:cleanup_before] = Tests::CleanupBefore.new(tap:,
git:,
dry_run: args.dry_run?,
fail_fast: args.fail_fast?,
verbose: args.verbose?)
end

if !skip_cleanup_after && (no_only_args || args.only_cleanup_after?)
tests[:cleanup_after] = Tests::CleanupAfter.new(tap: tap,
git: git,
tests[:cleanup_after] = Tests::CleanupAfter.new(tap:,
git:,
dry_run: args.dry_run?,
fail_fast: args.fail_fast?,
verbose: args.verbose?)
end
end

if args.only_bottles_fetch?
tests[:bottles_fetch] = Tests::BottlesFetch.new(tap: tap,
git: git,
tests[:bottles_fetch] = Tests::BottlesFetch.new(tap:,
git:,
dry_run: args.dry_run?,
fail_fast: args.fail_fast?,
verbose: args.verbose?)
Expand All @@ -194,13 +194,13 @@ def build_tests(argument, tap:, git:, output_paths:, skip_setup:,
end

def run_tests(tests, args:)
tests[:cleanup_before]&.run!(args: args)
tests[:cleanup_before]&.run!(args:)
begin
tests[:setup]&.run!(args: args)
tests[:tap_syntax]&.run!(args: args)
tests[:setup]&.run!(args:)
tests[:tap_syntax]&.run!(args:)

testing_formulae, added_formulae, deleted_formulae = if (detect_test = tests[:formulae_detect])
detect_test.run!(args: args)
detect_test.run!(args:)

[
detect_test.testing_formulae,
Expand All @@ -220,7 +220,7 @@ def run_tests(tests, args:)
formulae_test.added_formulae = added_formulae
formulae_test.deleted_formulae = deleted_formulae

formulae_test.run!(args: args)
formulae_test.run!(args:)

formulae_test.skipped_or_failed_formulae
elsif args.skipped_or_failed_formulae.present?
Expand All @@ -235,16 +235,16 @@ def run_tests(tests, args:)
dependents_test.testing_formulae = testing_formulae
dependents_test.skipped_or_failed_formulae = skipped_or_failed_formulae

dependents_test.run!(args: args)
dependents_test.run!(args:)
end

if (fetch_test = tests[:bottles_fetch])
fetch_test.testing_formulae = testing_formulae

fetch_test.run!(args: args)
fetch_test.run!(args:)
end
ensure
tests[:cleanup_after]&.run!(args: args)
tests[:cleanup_after]&.run!(args:)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/tests/bottles_fetch.rb
Expand Up @@ -11,7 +11,7 @@ def run!(args:)
puts

testing_formulae.each do |formula_name|
fetch_bottles!(formula_name, args: args)
fetch_bottles!(formula_name, args:)
puts
end
end
Expand All @@ -25,7 +25,7 @@ def fetch_bottles!(formula_name, args:)
tags = formula.bottle_specification.collector.tags

tags.each do |tag|
cleanup_during!(args: args)
cleanup_during!(args:)
test "brew", "fetch", "--retry", "--formulae", "--bottle-tag=#{tag}", formula_name
end
end
Expand Down
28 changes: 14 additions & 14 deletions lib/tests/formulae.rb
Expand Up @@ -6,7 +6,7 @@ class Formulae < TestFormulae
attr_writer :testing_formulae, :added_formulae, :deleted_formulae

def initialize(tap:, git:, dry_run:, fail_fast:, verbose:, output_paths:)
super(tap: tap, git: git, dry_run: dry_run, fail_fast: fail_fast, verbose: verbose)
super(tap:, git:, dry_run:, fail_fast:, verbose:)

@built_formulae = []
@bottle_checksums = {}
Expand All @@ -33,7 +33,7 @@ def run!(args:)
@testing_formulae_count = @testing_formulae.count

sorted_formulae.each do |f|
formula!(f, args: args)
formula!(f, args:)
verify_local_bottles
puts
end
Expand Down Expand Up @@ -156,12 +156,12 @@ def setup_formulae_deps_instances(formula, formula_name, args:)
# checksum problems. We have to install all `changed_dependencies`
# in one `brew install` command to make sure they are installed in
# the right order.
test "brew", "install", "--build-from-source",
test("brew", "install", "--build-from-source",
named_args: changed_dependencies,
ignore_failures: ignore_failures
ignore_failures:)
# Run postinstall on them because the tested formula might depend on
# this step
test "brew", "postinstall", named_args: changed_dependencies, ignore_failures: ignore_failures
test "brew", "postinstall", named_args: changed_dependencies, ignore_failures:
end

runtime_or_test_dependencies =
Expand Down Expand Up @@ -228,7 +228,7 @@ def verify_local_bottles
end

def bottle_reinstall_formula(formula, new_formula, args:)
unless build_bottle?(formula, args: args)
unless build_bottle?(formula, args:)
@bottle_filename = nil
return
end
Expand Down Expand Up @@ -366,7 +366,7 @@ def livecheck(formula)
end

def formula!(formula_name, args:)
cleanup_during!(@testing_formulae, args: args)
cleanup_during!(@testing_formulae, args:)

test_header(:Formulae, method: "formula!(#{formula_name})")

Expand Down Expand Up @@ -399,7 +399,7 @@ def formula!(formula_name, args:)
deps = []
reqs = []

build_flag = if build_bottle?(formula, args: args)
build_flag = if build_bottle?(formula, args:)
"--build-bottle"
else
if ENV["GITHUB_ACTIONS"].present?
Expand Down Expand Up @@ -465,7 +465,7 @@ def formula!(formula_name, args:)
install_curl_if_needed(formula)
install_mercurial_if_needed(deps, reqs)
install_subversion_if_needed(deps, reqs)
setup_formulae_deps_instances(formula, formula_name, args: args)
setup_formulae_deps_instances(formula, formula_name, args:)

test "brew", "uninstall", "--force", formula_name if formula.latest_version_installed?

Expand Down Expand Up @@ -499,10 +499,10 @@ def formula!(formula_name, args:)
dry_run: args.dry_run?)

install_step_passed ||= begin
test "brew", "install", *install_args,
test("brew", "install", *install_args,
named_args: formula_name,
env: env.merge({ "HOMEBREW_DEVELOPER" => nil }),
ignore_failures: ignore_failures
ignore_failures:)
steps.last.passed?
end

Expand Down Expand Up @@ -530,10 +530,10 @@ def formula!(formula_name, args:)
@bottle_checksums.delete(old_location)
end
else
bottle_reinstall_formula(formula, new_formula, args: args)
bottle_reinstall_formula(formula, new_formula, args:)
end
@built_formulae << formula.full_name
test "brew", "linkage", "--test", named_args: formula_name, ignore_failures: ignore_failures
test("brew", "linkage", "--test", named_args: formula_name, ignore_failures:)
failed_linkage_or_test_messages ||= []
failed_linkage_or_test_messages << "linkage failed" unless steps.last.passed?

Expand All @@ -560,7 +560,7 @@ def formula!(formula_name, args:)

# Intentionally not passing --retry here to avoid papering over
# flaky tests when a formula isn't being pulled in as a dependent.
test "brew", "test", "--verbose", named_args: formula_name, env: env, ignore_failures: ignore_failures
test("brew", "test", "--verbose", named_args: formula_name, env:, ignore_failures:)
failed_linkage_or_test_messages << "test failed" unless steps.last.passed?
end

Expand Down

0 comments on commit 74699c2

Please sign in to comment.