diff --git a/Library/Homebrew/cli_parser.rb b/Library/Homebrew/cli_parser.rb index 8e70352b52..0ea8af6a66 100644 --- a/Library/Homebrew/cli_parser.rb +++ b/Library/Homebrew/cli_parser.rb @@ -11,9 +11,9 @@ module Homebrew def initialize(&block) @parser = OptionParser.new - @parsed_args = OpenStruct.new + Homebrew.args = OpenStruct.new # undefine tap to allow --tap argument - @parsed_args.instance_eval { undef tap } + Homebrew.args.instance_eval { undef tap } @constraints = [] @conflicts = [] instance_eval(&block) @@ -24,20 +24,20 @@ module Homebrew global_switch = names.first.is_a?(Symbol) names, env = common_switch(*names) if global_switch @parser.on(*names, description) do - enable_switch(*names, global_switch) + enable_switch(*names) end - enable_switch(*names, global_switch) if !env.nil? && - !ENV["HOMEBREW_#{env.to_s.upcase}"].nil? names.each do |name| set_constraints(name, required_for: required_for, depends_on: depends_on) end + + enable_switch(*names) if !env.nil? && !ENV["HOMEBREW_#{env.to_s.upcase}"].nil? end def comma_array(name, description: nil) description = option_to_description(name) if description.nil? @parser.on(name, OptionParser::REQUIRED_ARGUMENT, Array, description) do |list| - @parsed_args[option_to_name(name)] = list + Homebrew.args[option_to_name(name)] = list end end @@ -50,7 +50,7 @@ module Homebrew end description = option_to_description(name) if description.nil? @parser.on(name, description, required) do |option_value| - @parsed_args[option_to_name(name)] = option_value + Homebrew.args[option_to_name(name)] = option_value end set_constraints(name, required_for: required_for, depends_on: depends_on) @@ -71,18 +71,13 @@ module Homebrew def parse(cmdline_args = ARGV) @parser.parse(cmdline_args) check_constraint_violations - @parsed_args end private - def enable_switch(*names, global_switch) + def enable_switch(*names) names.each do |name| - if global_switch - Homebrew.args["#{option_to_name(name)}?"] = true - next - end - @parsed_args["#{option_to_name(name)}?"] = true + Homebrew.args["#{option_to_name(name)}?"] = true end end @@ -98,7 +93,7 @@ module Homebrew end def option_passed?(name) - @parsed_args.respond_to?(name) || @parsed_args.respond_to?("#{name}?") + Homebrew.args.respond_to?(name) || Homebrew.args.respond_to?("#{name}?") end def set_constraints(name, depends_on:, required_for:) diff --git a/Library/Homebrew/cmd/list.rb b/Library/Homebrew/cmd/list.rb index f276836d32..260f1cc078 100644 --- a/Library/Homebrew/cmd/list.rb +++ b/Library/Homebrew/cmd/list.rb @@ -26,7 +26,7 @@ module Homebrew module_function def list - @args = CLI::Parser.parse do + Homebrew::CLI::Parser.parse do switch "--unbrewed" switch "--pinned" switch "--versions" @@ -41,7 +41,7 @@ module Homebrew end # Use of exec means we don't explicitly exit - list_unbrewed if @args.unbrewed? + list_unbrewed if args.unbrewed? # Unbrewed uses the PREFIX, which will exist # Things below use the CELLAR, which doesn't until the first formula is installed. @@ -50,10 +50,10 @@ module Homebrew return end - if @args.pinned? || @args.versions? + if args.pinned? || args.versions? filtered_list elsif ARGV.named.empty? - if @args.full_name? + if args.full_name? full_names = Formula.installed.map(&:full_name).sort(&tap_and_name_comparison) return if full_names.empty? puts Formatter.columns(full_names) @@ -61,7 +61,7 @@ module Homebrew ENV["CLICOLOR"] = nil exec "ls", *ARGV.options_only << HOMEBREW_CELLAR end - elsif Homebrew.args.verbose? || !$stdout.tty? + elsif args.verbose? || !$stdout.tty? exec "find", *ARGV.kegs.map(&:to_s) + %w[-not -type d -print] else ARGV.kegs.each { |keg| PrettyListing.new keg } @@ -121,7 +121,7 @@ module Homebrew rack.exist? end end - if @args.pinned? + if args.pinned? pinned_versions = {} names.sort.each do |d| keg_pin = (HOMEBREW_PINNED_KEGS/d.basename.to_s) @@ -130,12 +130,12 @@ module Homebrew end end pinned_versions.each do |d, version| - puts d.basename.to_s.concat(@args.versions? ? " #{version}" : "") + puts d.basename.to_s.concat(args.versions? ? " #{version}" : "") end else # --versions without --pinned names.sort.each do |d| versions = d.subdirs.map { |pn| pn.basename.to_s } - next if @args.multiple? && versions.length < 2 + next if args.multiple? && versions.length < 2 puts "#{d.basename} #{versions * " "}" end end diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 1ffe0d54ad..743599ee23 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -53,7 +53,7 @@ module Homebrew module_function def audit - args = Homebrew::CLI::Parser.parse do + Homebrew::CLI::Parser.parse do switch "--strict" switch "--online" switch "--new-formula" diff --git a/Library/Homebrew/dev-cmd/bottle.rb b/Library/Homebrew/dev-cmd/bottle.rb index ab222b8832..c15d403fc7 100644 --- a/Library/Homebrew/dev-cmd/bottle.rb +++ b/Library/Homebrew/dev-cmd/bottle.rb @@ -71,7 +71,7 @@ module Homebrew module_function def bottle - @args = Homebrew::CLI::Parser.parse do + Homebrew::CLI::Parser.parse do switch "--merge" switch "--skip-relocation" switch "--force-core-tap" @@ -86,7 +86,7 @@ module Homebrew flag "--root-url" end - return merge if @args.merge? + return merge if args.merge? ARGV.resolved_formulae.each do |f| bottle_formula f end @@ -117,7 +117,7 @@ module Homebrew linked_libraries = Keg.file_linked_libraries(file, string) result ||= !linked_libraries.empty? - if Homebrew.args.verbose? + if args.verbose? print_filename.call(string, file) unless linked_libraries.empty? linked_libraries.each do |lib| puts " #{Tty.bold}-->#{Tty.reset} links to #{lib}" @@ -140,7 +140,7 @@ module Homebrew end end - next unless Homebrew.args.verbose? && !text_matches.empty? + next unless args.verbose? && !text_matches.empty? print_filename.call(string, file) text_matches.first(MAXIMUM_STRING_MATCHES).each do |match, offset| puts " #{Tty.bold}-->#{Tty.reset} match '#{match}' at offset #{Tty.bold}0x#{offset}#{Tty.reset}" @@ -161,7 +161,7 @@ module Homebrew absolute_symlinks_start_with_string << pn if link.to_s.start_with?(string) end - if Homebrew.args.verbose? + if args.verbose? unless absolute_symlinks_start_with_string.empty? opoo "Absolute symlink starting with #{string}:" absolute_symlinks_start_with_string.each do |pn| @@ -184,7 +184,7 @@ module Homebrew end unless tap = f.tap - unless @args.force_core_tap? + unless args.force_core_tap? return ofail "Formula not from core or any taps: #{f.full_name}" end @@ -203,9 +203,9 @@ module Homebrew return ofail "Formula has no stable version: #{f.full_name}" unless f.stable - if @args.no_rebuild? || !f.tap + if args.no_rebuild? || !f.tap rebuild = 0 - elsif @args.keep_old? + elsif args.keep_old? rebuild = f.bottle_specification.rebuild else ohai "Determining #{f.full_name} bottle rebuild..." @@ -238,7 +238,7 @@ module Homebrew begin keg.delete_pyc_files! - unless @args.skip_relocation? + unless args.skip_relocation? changed_files = keg.replace_locations_with_placeholders end @@ -289,7 +289,7 @@ module Homebrew end relocatable = true - if @args.skip_relocation? + if args.skip_relocation? skip_relocation = true else relocatable = false if keg_contain?(prefix_check, keg, ignores) @@ -302,21 +302,21 @@ module Homebrew end skip_relocation = relocatable && !keg.require_relocation? end - puts if !relocatable && Homebrew.args.verbose? + puts if !relocatable && args.verbose? rescue Interrupt ignore_interrupts { bottle_path.unlink if bottle_path.exist? } raise ensure ignore_interrupts do original_tab&.write - unless @args.skip_relocation? + unless args.skip_relocation? keg.replace_placeholders_with_locations changed_files end end end end - root_url = @args.root_url + root_url = args.root_url bottle = BottleSpecification.new bottle.tap = tap @@ -336,7 +336,7 @@ module Homebrew bottle.sha256 sha256 => Utils::Bottles.tag old_spec = f.bottle_specification - if @args.keep_old? && !old_spec.checksums.empty? + if args.keep_old? && !old_spec.checksums.empty? mismatches = [:root_url, :prefix, :cellar, :rebuild].reject do |key| old_spec.send(key) == bottle.send(key) end @@ -362,9 +362,9 @@ module Homebrew puts "./#{filename}" puts output - return unless @args.json? + return unless args.json? tag = Utils::Bottles.tag.to_s - tag += "_or_later" if @args.or_later? + tag += "_or_later" if args.or_later? json = { f.full_name => { "formula" => { @@ -395,7 +395,7 @@ module Homebrew end def merge - write = @args.write? + write = args.write? bottles_hash = ARGV.named.reduce({}) do |hash, json_file| deep_merge_hashes hash, JSON.parse(IO.read(json_file)) @@ -424,7 +424,7 @@ module Homebrew Utils::Inreplace.inreplace(path) do |s| if s.include? "bottle do" update_or_add = "update" - if @args.keep_old? + if args.keep_old? mismatches = [] bottle_block_contents = s[/ bottle do(.+?)end\n/m, 1] bottle_block_contents.lines.each do |line| @@ -467,7 +467,7 @@ module Homebrew string = s.sub!(/ bottle do.+?end\n/m, output) odie "Bottle block update failed!" unless string else - if @args.keep_old? + if args.keep_old? odie "--keep-old was passed but there was no existing bottle block!" end puts output @@ -496,7 +496,7 @@ module Homebrew end end - unless @args.no_commit? + unless args.no_commit? if ENV["HOMEBREW_GIT_NAME"] ENV["GIT_AUTHOR_NAME"] = ENV["GIT_COMMITTER_NAME"] = diff --git a/Library/Homebrew/dev-cmd/bump-formula-pr.rb b/Library/Homebrew/dev-cmd/bump-formula-pr.rb index aaaa158ab3..c83b407368 100644 --- a/Library/Homebrew/dev-cmd/bump-formula-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-formula-pr.rb @@ -48,7 +48,7 @@ module Homebrew module_function def bump_formula_pr - @bump_args = Homebrew::CLI::Parser.parse do + Homebrew::CLI::Parser.parse do switch "--devel" switch "-n", "--dry-run" switch "--write" @@ -93,7 +93,7 @@ module Homebrew checked_for_duplicates = true end - new_url = @bump_args.url + new_url = args.url if new_url && !formula # Split the new URL on / and find any formulae that have the same URL # except for the last component, but don't try to match any more than the @@ -104,7 +104,7 @@ module Homebrew components_to_match = [new_url_split.count - 1, maximum_url_components_to_match].min base_url = new_url_split.first(components_to_match).join("/") base_url = /#{Regexp.escape(base_url)}/ - is_devel = @bump_args.devel? + is_devel = args.devel? guesses = [] Formula.each do |f| if is_devel && f.devel && f.devel.url && f.devel.url.match(base_url) @@ -123,7 +123,7 @@ module Homebrew check_for_duplicate_pull_requests(formula) unless checked_for_duplicates - requested_spec, formula_spec = if @bump_args.devel? + requested_spec, formula_spec = if args.devel? devel_message = " (devel)" [:devel, formula.devel] else @@ -135,11 +135,11 @@ module Homebrew [checksum.hash_type, checksum.hexdigest] end - new_hash = @bump_args[hash_type] if hash_type - new_tag = @bump_args.tag - new_revision = @bump_args.revision - new_mirror = @bump_args.mirror - forced_version = @bump_args.version + new_hash = args[hash_type] if hash_type + new_tag = args.tag + new_revision = args.revision + new_mirror = args.mirror + forced_version = args.version new_url_hash = if new_url && new_hash true elsif new_tag && new_revision @@ -176,7 +176,7 @@ module Homebrew end end - if @bump_args.dry_run? + if args.dry_run? ohai "brew update" else safe_system "brew", "update" @@ -205,7 +205,7 @@ module Homebrew ] end - backup_file = File.read(formula.path) unless @bump_args.dry_run? + backup_file = File.read(formula.path) unless args.dry_run? if new_mirror replacement_pairs << [/^( +)(url \"#{Regexp.escape(new_url)}\"\n)/m, "\\1\\2\\1mirror \"#{new_mirror}\"\n"] @@ -235,31 +235,31 @@ module Homebrew new_formula_version = formula_version(formula, requested_spec, new_contents) if new_formula_version < old_formula_version - formula.path.atomic_write(backup_file) unless @bump_args.dry_run? + formula.path.atomic_write(backup_file) unless args.dry_run? odie <<~EOS You probably need to bump this formula manually since changing the version from #{old_formula_version} to #{new_formula_version} would be a downgrade. EOS elsif new_formula_version == old_formula_version - formula.path.atomic_write(backup_file) unless @bump_args.dry_run? + formula.path.atomic_write(backup_file) unless args.dry_run? odie <<~EOS You probably need to bump this formula manually since the new version and old version are both #{new_formula_version}. EOS end - if @bump_args.dry_run? - if @bump_args.strict? + if args.dry_run? + if args.strict? ohai "brew audit --strict #{formula.path.basename}" - elsif @bump_args.audit? + elsif args.audit? ohai "brew audit #{formula.path.basename}" end else failed_audit = false - if @bump_args.strict? + if args.strict? system HOMEBREW_BREW_FILE, "audit", "--strict", formula.path failed_audit = !$CHILD_STATUS.success? - elsif @bump_args.audit? + elsif args.audit? system HOMEBREW_BREW_FILE, "audit", formula.path failed_audit = !$CHILD_STATUS.success? end @@ -274,7 +274,7 @@ module Homebrew git_dir = Utils.popen_read("git rev-parse --git-dir").chomp shallow = !git_dir.empty? && File.exist?("#{git_dir}/shallow") - if @bump_args.dry_run? + if args.dry_run? ohai "fork repository with GitHub API" ohai "git fetch --unshallow origin" if shallow ohai "git checkout --no-track -b #{branch} origin/master" @@ -306,7 +306,7 @@ module Homebrew pr_message = <<~EOS Created with `brew bump-formula-pr`. EOS - user_message = @bump_args.message + user_message = args.message if user_message pr_message += "\n" + <<~EOS --- @@ -319,7 +319,7 @@ module Homebrew begin url = GitHub.create_pull_request(formula.tap.full_name, pr_title, "#{username}:#{branch}", "master", pr_message)["html_url"] - if @bump_args.no_browse? + if args.no_browse? puts url else exec_browser url @@ -332,7 +332,7 @@ module Homebrew end def inreplace_pairs(path, replacement_pairs) - if @bump_args.dry_run? + if args.dry_run? contents = path.open("r") { |f| Formulary.ensure_utf8_encoding(f).read } contents.extend(StringInreplaceExtension) replacement_pairs.each do |old, new| @@ -344,7 +344,7 @@ module Homebrew unless contents.errors.empty? raise Utils::InreplaceError, path => contents.errors end - path.atomic_write(contents) if @bump_args.write? + path.atomic_write(contents) if args.write? contents else Utils::Inreplace.inreplace(path) do |s| diff --git a/Library/Homebrew/dev-cmd/edit.rb b/Library/Homebrew/dev-cmd/edit.rb index bcbf5b7d5d..3830bb13a7 100644 --- a/Library/Homebrew/dev-cmd/edit.rb +++ b/Library/Homebrew/dev-cmd/edit.rb @@ -43,7 +43,7 @@ module Homebrew paths = ARGV.named.map do |name| path = Formulary.path(name) - raise FormulaUnavailableError, name unless path.file? || Homebrew.args.force? + raise FormulaUnavailableError, name unless path.file? || args.force? path end diff --git a/Library/Homebrew/dev-cmd/irb.rb b/Library/Homebrew/dev-cmd/irb.rb index 1d6b0a5142..2c5afe5a1e 100644 --- a/Library/Homebrew/dev-cmd/irb.rb +++ b/Library/Homebrew/dev-cmd/irb.rb @@ -23,7 +23,7 @@ module Homebrew module_function def irb - args = Homebrew::CLI::Parser.parse do + Homebrew::CLI::Parser.parse do switch "--examples" switch "--pry", env: :pry end diff --git a/Library/Homebrew/dev-cmd/man.rb b/Library/Homebrew/dev-cmd/man.rb index a54ab89e3c..a813555f17 100644 --- a/Library/Homebrew/dev-cmd/man.rb +++ b/Library/Homebrew/dev-cmd/man.rb @@ -20,14 +20,14 @@ module Homebrew TARGET_DOC_PATH = HOMEBREW_REPOSITORY/"docs" def man - @args = Homebrew::CLI::Parser.parse do + Homebrew::CLI::Parser.parse do switch "--fail-if-changed" switch "--link" end raise UsageError unless ARGV.named.empty? - if @args.link? + if args.link? odie "`brew man --link` is now done automatically by `brew update`." end @@ -35,7 +35,7 @@ module Homebrew if system "git", "-C", HOMEBREW_REPOSITORY, "diff", "--quiet", "docs/Manpage.md", "manpages" puts "No changes to manpage output detected." - elsif @args.fail_if_changed? + elsif args.fail_if_changed? Homebrew.failed = true end end @@ -94,7 +94,7 @@ module Homebrew # Set the manpage date to the existing one if we're checking for changes. # This avoids the only change being e.g. a new date. - date = if @args.fail_if_changed? && + date = if args.fail_if_changed? && target.extname == ".1" && target.exist? /"(\d{1,2})" "([A-Z][a-z]+) (\d{4})" "#{organisation}" "#{manual}"/ =~ target.read Date.parse("#{Regexp.last_match(1)} #{Regexp.last_match(2)} #{Regexp.last_match(3)}") diff --git a/Library/Homebrew/dev-cmd/pull.rb b/Library/Homebrew/dev-cmd/pull.rb index e497792106..c457e199d6 100644 --- a/Library/Homebrew/dev-cmd/pull.rb +++ b/Library/Homebrew/dev-cmd/pull.rb @@ -74,7 +74,7 @@ module Homebrew def pull odie "You meant `git pull --rebase`." if ARGV[0] == "--rebase" - @args = Homebrew::CLI::Parser.parse do + Homebrew::CLI::Parser.parse do switch "--bottle" switch "--bump" switch "--clean" @@ -116,7 +116,7 @@ module Homebrew end end - do_bump = @args.bump? && !@args.clean? + do_bump = args.bump? && !args.clean? # Formulae with affected bottles that were published bintray_published_formulae = [] @@ -135,7 +135,7 @@ module Homebrew end _, testing_job = *testing_match url = "https://github.com/Homebrew/homebrew-#{tap.repo}/compare/master...BrewTestBot:testing-#{testing_job}" - odie "Testing URLs require `--bottle`!" unless @args.bottle? + odie "Testing URLs require `--bottle`!" unless args.bottle? elsif (api_match = arg.match HOMEBREW_PULL_API_REGEX) _, user, repo, issue = *api_match url = "https://github.com/#{user}/#{repo}/pull/#{issue}" @@ -147,7 +147,7 @@ module Homebrew odie "Not a GitHub pull request or commit: #{arg}" end - if !testing_job && @args.bottle? && issue.nil? + if !testing_job && args.bottle? && issue.nil? odie "No pull request detected!" end @@ -165,11 +165,11 @@ module Homebrew orig_revision = `git rev-parse --short HEAD`.strip branch = `git symbolic-ref --short HEAD`.strip - unless branch == "master" || @args.clean? || @args.branch_okay? + unless branch == "master" || args.clean? || args.branch_okay? opoo "Current branch is #{branch}: do you need to pull inside master?" end - patch_puller = PatchPuller.new(url, @args) + patch_puller = PatchPuller.new(url, args) patch_puller.fetch_patch patch_changes = files_changed_in_patch(patch_puller.patchpath, tap) @@ -217,7 +217,7 @@ module Homebrew end end - if @args.bottle? + if args.bottle? if f.bottle_unneeded? ohai "#{f}: skipping unneeded bottle." elsif f.bottle_disabled? @@ -232,7 +232,7 @@ module Homebrew end orig_message = message = `git log HEAD^.. --format=%B` - if issue && !@args.clean? + if issue && !args.clean? ohai "Patch closes issue ##{issue}" close_message = "Closes ##{issue}." # If this is a pull request, append a close message. @@ -244,7 +244,7 @@ module Homebrew is_bumpable = false end - is_bumpable = false if @args.clean? + is_bumpable = false if args.clean? is_bumpable = false if ENV["HOMEBREW_DISABLE_LOAD_FORMULA"] if is_bumpable @@ -256,7 +256,7 @@ module Homebrew odie "No version changes found for #{formula.name}" if bump_subject.nil? unless orig_subject == bump_subject ohai "New bump commit subject: #{bump_subject}" - pbcopy bump_subject unless @args.no_pbcopy? + pbcopy bump_subject unless args.no_pbcopy? message = "#{bump_subject}\n\n#{message}" end elsif bump_subject != orig_subject && !bump_subject.nil? @@ -265,7 +265,7 @@ module Homebrew end end - if message != orig_message && !@args.clean? + if message != orig_message && !args.clean? safe_system "git", "commit", "--amend", "--signoff", "--allow-empty", "-q", "-m", message end @@ -276,7 +276,7 @@ module Homebrew url else bottle_branch = "pull-bottle-#{issue}" - bot_username = GitHub.test_bot_user(user, @args.test_bot_user) + bot_username = GitHub.test_bot_user(user, args.test_bot_user) "https://github.com/#{bot_username}/homebrew-#{tap.repo}/compare/#{user}:master...pr-#{issue}" end @@ -290,7 +290,7 @@ module Homebrew safe_system "git", "branch", "--quiet", "-D", bottle_branch # Publish bottles on Bintray - unless @args.no_publish? + unless args.no_publish? published = publish_changed_formula_bottles(tap, changed_formulae_names) bintray_published_formulae.concat(published) end @@ -320,7 +320,7 @@ module Homebrew changed_formulae_names.each do |name| f = Formula[name] next if f.bottle_unneeded? || f.bottle_disabled? - bintray_org = @args.bintray_org || tap.user.downcase + bintray_org = args.bintray_org || tap.user.downcase next unless publish_bottle_file_on_bintray(f, bintray_org, bintray_creds) published << f.full_name end @@ -331,7 +331,7 @@ module Homebrew end def pull_patch(url, description = nil) - PatchPuller.new(url, @args, description).pull_patch + PatchPuller.new(url, args, description).pull_patch end class PatchPuller diff --git a/Library/Homebrew/dev-cmd/release-notes.rb b/Library/Homebrew/dev-cmd/release-notes.rb index a930aad23f..d66d969292 100644 --- a/Library/Homebrew/dev-cmd/release-notes.rb +++ b/Library/Homebrew/dev-cmd/release-notes.rb @@ -11,7 +11,7 @@ module Homebrew module_function def release_notes - args = Homebrew::CLI::Parser.parse do + Homebrew::CLI::Parser.parse do switch "--markdown" end diff --git a/Library/Homebrew/dev-cmd/tests.rb b/Library/Homebrew/dev-cmd/tests.rb index c544b36104..8eabbf4558 100644 --- a/Library/Homebrew/dev-cmd/tests.rb +++ b/Library/Homebrew/dev-cmd/tests.rb @@ -22,7 +22,7 @@ module Homebrew module_function def tests - args = Homebrew::CLI::Parser.parse do + Homebrew::CLI::Parser.parse do switch "--no-compat" switch "--generic" switch "--coverage" @@ -98,8 +98,8 @@ module Homebrew # seeds being output when running parallel tests. seed = args.seed ? args.seed : rand(0xFFFF).to_i - args = ["-I", HOMEBREW_LIBRARY_PATH/"test"] - args += %W[ + bundle_args = ["-I", HOMEBREW_LIBRARY_PATH/"test"] + bundle_args += %W[ --seed #{seed} --color --require spec_helper @@ -109,21 +109,21 @@ module Homebrew ] unless OS.mac? - args << "--tag" << "~needs_macos" + bundle_args << "--tag" << "~needs_macos" files = files.reject { |p| p =~ %r{^test/(os/mac|cask)(/.*|_spec\.rb)$} } end unless OS.linux? - args << "--tag" << "~needs_linux" + bundle_args << "--tag" << "~needs_linux" files = files.reject { |p| p =~ %r{^test/os/linux(/.*|_spec\.rb)$} } end puts "Randomized with seed #{seed}" if parallel - system "bundle", "exec", "parallel_rspec", *opts, "--", *args, "--", *files + system "bundle", "exec", "parallel_rspec", *opts, "--", *bundle_args, "--", *files else - system "bundle", "exec", "rspec", *args, "--", *files + system "bundle", "exec", "rspec", *bundle_args, "--", *files end return if $CHILD_STATUS.success? diff --git a/Library/Homebrew/dev-cmd/update-test.rb b/Library/Homebrew/dev-cmd/update-test.rb index d72e12b249..685fa3abdd 100644 --- a/Library/Homebrew/dev-cmd/update-test.rb +++ b/Library/Homebrew/dev-cmd/update-test.rb @@ -20,7 +20,7 @@ module Homebrew module_function def update_test - args = Homebrew::CLI::Parser.parse do + Homebrew::CLI::Parser.parse do switch "--to-tag" switch "--keep-tmp" switch :verbose diff --git a/Library/Homebrew/test/cli_parser_spec.rb b/Library/Homebrew/test/cli_parser_spec.rb index 0d4cdcb4b2..205eb8f154 100644 --- a/Library/Homebrew/test/cli_parser_spec.rb +++ b/Library/Homebrew/test/cli_parser_spec.rb @@ -33,9 +33,9 @@ describe Homebrew::CLI::Parser do end it "parses a single option and checks other options to be nil" do - args = parser.parse(["--verbose"]) + parser.parse(["--verbose"]) expect(Homebrew.args).to be_verbose - expect(args.more_verbose?).to be nil + expect(Homebrew.args.more_verbose?).to be nil end it "raises an exception when an invalid option is passed" do @@ -43,8 +43,8 @@ describe Homebrew::CLI::Parser do end it "maps environment var to an option" do - args = parser.parse([]) - expect(args.pry?).to be true + parser.parse([]) + expect(Homebrew.args.pry?).to be true end end @@ -57,8 +57,8 @@ describe Homebrew::CLI::Parser do } it "parses a long flag option with its argument" do - args = parser.parse(["--filename=random.txt"]) - expect(args.filename).to eq "random.txt" + parser.parse(["--filename=random.txt"]) + expect(Homebrew.args.filename).to eq "random.txt" end it "raises an exception when a flag's required value is not passed" do @@ -66,8 +66,8 @@ describe Homebrew::CLI::Parser do end it "parses a comma array flag option" do - args = parser.parse(["--files=random1.txt,random2.txt"]) - expect(args.files).to eq %w[random1.txt random2.txt] + parser.parse(["--files=random1.txt,random2.txt"]) + expect(Homebrew.args.files).to eq %w[random1.txt random2.txt] end end @@ -96,14 +96,14 @@ describe Homebrew::CLI::Parser do end it "raises no exception" do - args = parser.parse(["--flag1=flag1", "--flag2=flag2"]) - expect(args.flag1).to eq "flag1" - expect(args.flag2).to eq "flag2" + parser.parse(["--flag1=flag1", "--flag2=flag2"]) + expect(Homebrew.args.flag1).to eq "flag1" + expect(Homebrew.args.flag2).to eq "flag2" end it "raises no exception for optional dependency" do - args = parser.parse(["--flag3=flag3"]) - expect(args.flag3).to eq "flag3" + parser.parse(["--flag3=flag3"]) + expect(Homebrew.args.flag3).to eq "flag3" end end @@ -146,14 +146,14 @@ describe Homebrew::CLI::Parser do end it "raises no exception" do - args = parser.parse(["--switch-a", "--switch-c"]) - expect(args.switch_a?).to be true - expect(args.switch_c?).to be true + parser.parse(["--switch-a", "--switch-c"]) + expect(Homebrew.args.switch_a?).to be true + expect(Homebrew.args.switch_c?).to be true end it "raises no exception for optional dependency" do - args = parser.parse(["--switch-b"]) - expect(args.switch_b?).to be true + parser.parse(["--switch-b"]) + expect(Homebrew.args.switch_b?).to be true end end end