From 5a047c7c27685a8576fb0f8c420700d2dc564bfc Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Mon, 12 Jun 2017 19:07:52 +0200 Subject: [PATCH 1/3] Fix `--language` option. --- Library/Homebrew/cask/lib/hbc/cli.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/cask/lib/hbc/cli.rb b/Library/Homebrew/cask/lib/hbc/cli.rb index eec2788ec9..8503c339a1 100644 --- a/Library/Homebrew/cask/lib/hbc/cli.rb +++ b/Library/Homebrew/cask/lib/hbc/cli.rb @@ -66,7 +66,7 @@ module Hbc option "--help", :help, false # handled in OS::Mac - option "--language a,b,c", ->(*) { raise OptionParser::InvalidOption } + option "--language a,b,c", ->(*) {} # override default handling of --version option "--version", ->(*) { raise OptionParser::InvalidOption } From 599a618273a64db1852f4bb80e21ee0c410a3285 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 14 Jun 2017 12:51:36 +0200 Subject: [PATCH 2/3] Move `require?` to `utils`. --- Library/Homebrew/brew.rb | 8 -------- Library/Homebrew/utils.rb | 8 ++++++++ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Library/Homebrew/brew.rb b/Library/Homebrew/brew.rb index 4a72c7e552..11ea8df672 100644 --- a/Library/Homebrew/brew.rb +++ b/Library/Homebrew/brew.rb @@ -21,14 +21,6 @@ if ARGV == %w[--version] || ARGV == %w[-v] exit 0 end -def require?(path) - return false if path.nil? - require path -rescue LoadError => e - # we should raise on syntax errors but not if the file doesn't exist. - raise unless e.message.include?(path) -end - begin trap("INT", std_trap) # restore default CTRL-C handler diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index 85305c01ae..529f3492d1 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -15,6 +15,14 @@ require "utils/svn" require "utils/tty" require "time" +def require?(path) + return false if path.nil? + require path +rescue LoadError => e + # we should raise on syntax errors but not if the file doesn't exist. + raise unless e.message.include?(path) +end + def ohai(title, *sput) title = Tty.truncate(title) if $stdout.tty? && !ARGV.verbose? puts Formatter.headline(title, color: :blue) From dcb85571ca468a573c5ac4f76752ec7e732d9e82 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 14 Jun 2017 13:23:16 +0200 Subject: [PATCH 3/3] Add test for `--language` option. --- Library/Homebrew/test/cask/cli_spec.rb | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/Library/Homebrew/test/cask/cli_spec.rb b/Library/Homebrew/test/cask/cli_spec.rb index caa17b0319..51258c5807 100644 --- a/Library/Homebrew/test/cask/cli_spec.rb +++ b/Library/Homebrew/test/cask/cli_spec.rb @@ -1,10 +1,10 @@ describe Hbc::CLI, :cask do it "lists the taps for Casks that show up in two taps" do - listing = Hbc::CLI.nice_listing(%w[ - caskroom/cask/adium - caskroom/cask/google-chrome - passcod/homebrew-cask/adium - ]) + listing = described_class.nice_listing(%w[ + caskroom/cask/adium + caskroom/cask/google-chrome + passcod/homebrew-cask/adium + ]) expect(listing).to eq(%w[ caskroom/cask/adium @@ -13,6 +13,13 @@ describe Hbc::CLI, :cask do ]) end + it "ignores the `--language` option, which is handled in `OS::Mac`" do + cli = described_class.new("--language=en") + expect(cli).to receive(:detect_command_and_arguments).with(no_args) + expect(cli).to receive(:exit).with(1) + shutup { cli.run } + end + context "when no option is specified" do it "--binaries is true by default" do command = Hbc::CLI::Install.new("some-cask") @@ -41,7 +48,7 @@ describe Hbc::CLI, :cask do end it "prints help output when subcommand receives `--help` flag" do - command = Hbc::CLI.new("noop", "--help") + command = described_class.new("noop", "--help") expect(described_class).to receive(:run_command).with("help", "noop") command.run expect(command.help?).to eq(true) @@ -56,7 +63,7 @@ describe Hbc::CLI, :cask do it "exits with a status of 1 when something goes wrong" do allow(described_class).to receive(:lookup_command).and_raise(Hbc::CaskError) - command = Hbc::CLI.new("noop") + command = described_class.new("noop") expect(command).to receive(:exit).with(1) command.run end