diff options
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/cli/style.rb | 4 | ||||
| -rw-r--r-- | Library/Homebrew/cask/spec/cask/cli/style_spec.rb | 16 | ||||
| -rw-r--r-- | Library/Homebrew/cmd/--prefix.rb | 4 | ||||
| -rw-r--r-- | Library/Homebrew/cmd/style.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/config.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/constants.rb | 3 | ||||
| -rw-r--r-- | Library/Homebrew/dev-cmd/formula.rb | 13 | ||||
| -rw-r--r-- | Library/Homebrew/test/formula_cmd_test.rb | 8 | ||||
| -rw-r--r-- | Library/Homebrew/test/support/lib/config.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/test/x11_requirement_spec.rb | 36 | ||||
| -rw-r--r-- | Library/Homebrew/test/x11_requirement_test.rb | 31 | ||||
| -rw-r--r-- | completions/zsh/_brew | 6 | ||||
| -rw-r--r-- | docs/brew.1.html | 1 | ||||
| -rw-r--r-- | manpages/brew.1 | 4 |
14 files changed, 96 insertions, 36 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/cli/style.rb b/Library/Homebrew/cask/lib/hbc/cli/style.rb index cdcc135b8..d3e44382d 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/style.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/style.rb @@ -23,12 +23,10 @@ module Hbc $CHILD_STATUS.success? end - RUBOCOP_CASK_VERSION = "~> 0.10.6".freeze - def install_rubocop Utils.capture_stderr do begin - Homebrew.install_gem_setup_path! "rubocop-cask", RUBOCOP_CASK_VERSION, "rubocop" + Homebrew.install_gem_setup_path! "rubocop-cask", HOMEBREW_RUBOCOP_CASK_VERSION, "rubocop" rescue SystemExit raise CaskError, Tty.strip_ansi($stderr.string).chomp.sub(/\AError: /, "") end diff --git a/Library/Homebrew/cask/spec/cask/cli/style_spec.rb b/Library/Homebrew/cask/spec/cask/cli/style_spec.rb index b0d34576a..106bfbb44 100644 --- a/Library/Homebrew/cask/spec/cask/cli/style_spec.rb +++ b/Library/Homebrew/cask/spec/cask/cli/style_spec.rb @@ -1,4 +1,6 @@ require "English" +require "open3" +require "rubygems" describe Hbc::CLI::Style do let(:args) { [] } @@ -77,6 +79,20 @@ describe Hbc::CLI::Style do expect { subject }.to raise_error(Hbc::CaskError) end end + + context "version" do + it "matches `HOMEBREW_RUBOCOP_VERSION`" do + stdout, status = Open3.capture2("gem", "dependency", "rubocop-cask", "--version", HOMEBREW_RUBOCOP_CASK_VERSION, "--pipe", "--remote") + + expect(status).to be_a_success + + requirement = Gem::Requirement.new(stdout.scan(/rubocop --version '(.*)'/).flatten.first) + version = Gem::Version.new(HOMEBREW_RUBOCOP_VERSION) + + expect(requirement).not_to be_none + expect(requirement).to be_satisfied_by(version) + end + end end describe "#cask_paths" do diff --git a/Library/Homebrew/cmd/--prefix.rb b/Library/Homebrew/cmd/--prefix.rb index f6e7d2ee2..956ab0403 100644 --- a/Library/Homebrew/cmd/--prefix.rb +++ b/Library/Homebrew/cmd/--prefix.rb @@ -11,7 +11,9 @@ module Homebrew if ARGV.named.empty? puts HOMEBREW_PREFIX else - puts ARGV.resolved_formulae.map(&:installed_prefix) + puts ARGV.resolved_formulae.map { |f| + f.opt_prefix.exist? ? f.opt_prefix : f.installed_prefix + } end end end diff --git a/Library/Homebrew/cmd/style.rb b/Library/Homebrew/cmd/style.rb index 586c6da6b..3d12561c1 100644 --- a/Library/Homebrew/cmd/style.rb +++ b/Library/Homebrew/cmd/style.rb @@ -47,7 +47,7 @@ module Homebrew def check_style_impl(files, output_type, options = {}) fix = options[:fix] - Homebrew.install_gem_setup_path! "rubocop", "0.47.1" + Homebrew.install_gem_setup_path! "rubocop", HOMEBREW_RUBOCOP_VERSION args = %w[ --force-exclusion diff --git a/Library/Homebrew/config.rb b/Library/Homebrew/config.rb index 38d7c8043..30b7bc6c9 100644 --- a/Library/Homebrew/config.rb +++ b/Library/Homebrew/config.rb @@ -2,6 +2,8 @@ unless ENV["HOMEBREW_BREW_FILE"] raise "HOMEBREW_BREW_FILE was not exported! Please call bin/brew directly!" end +require "constants" + # Path to `bin/brew` main executable in HOMEBREW_PREFIX HOMEBREW_BREW_FILE = Pathname.new(ENV["HOMEBREW_BREW_FILE"]) diff --git a/Library/Homebrew/constants.rb b/Library/Homebrew/constants.rb new file mode 100644 index 000000000..660cad7a3 --- /dev/null +++ b/Library/Homebrew/constants.rb @@ -0,0 +1,3 @@ +# RuboCop version used for `brew style` and `brew cask style` +HOMEBREW_RUBOCOP_VERSION = "0.47.1".freeze +HOMEBREW_RUBOCOP_CASK_VERSION = "~> 0.11.0".freeze # has to be updated when RuboCop version changes diff --git a/Library/Homebrew/dev-cmd/formula.rb b/Library/Homebrew/dev-cmd/formula.rb new file mode 100644 index 000000000..71687dfa7 --- /dev/null +++ b/Library/Homebrew/dev-cmd/formula.rb @@ -0,0 +1,13 @@ +#: * `formula` <formula>: +#: Display the path where <formula> is + +require "formula" + +module Homebrew + module_function + + def formula + raise FormulaUnspecifiedError if ARGV.named.empty? + ARGV.resolved_formulae.each { |f| puts f.path } + end +end diff --git a/Library/Homebrew/test/formula_cmd_test.rb b/Library/Homebrew/test/formula_cmd_test.rb new file mode 100644 index 000000000..abbe42d98 --- /dev/null +++ b/Library/Homebrew/test/formula_cmd_test.rb @@ -0,0 +1,8 @@ +require "testing_env" + +class IntegrationCommandTestFormula < IntegrationCommandTestCase + def test_formula + formula_file = setup_test_formula "testball" + assert_equal formula_file.to_s, cmd("formula", "testball") + end +end diff --git a/Library/Homebrew/test/support/lib/config.rb b/Library/Homebrew/test/support/lib/config.rb index fb5c210fe..3a0a76722 100644 --- a/Library/Homebrew/test/support/lib/config.rb +++ b/Library/Homebrew/test/support/lib/config.rb @@ -2,6 +2,8 @@ unless ENV["HOMEBREW_BREW_FILE"] raise "HOMEBREW_BREW_FILE was not exported! Please call bin/brew directly!" end +require "constants" + require "tmpdir" require "pathname" diff --git a/Library/Homebrew/test/x11_requirement_spec.rb b/Library/Homebrew/test/x11_requirement_spec.rb new file mode 100644 index 000000000..f60c8bffe --- /dev/null +++ b/Library/Homebrew/test/x11_requirement_spec.rb @@ -0,0 +1,36 @@ +require "requirements/x11_requirement" + +describe X11Requirement do + let(:default_name) { "x11" } + + describe "#name" do + it "defaults to x11" do + expect(subject.name).to eq(default_name) + end + end + + describe "#eql?" do + it "returns true if the names are equal" do + other = described_class.new(default_name) + expect(subject).to eql(other) + end + + it "and returns false if the names differ" do + other = described_class.new("foo") + expect(subject).not_to eql(other) + end + + it "returns false if the minimum version differs" do + other = described_class.new(default_name, ["2.5"]) + expect(subject).not_to eql(other) + end + end + + describe "#modify_build_environment" do + it "calls ENV#x11" do + allow(subject).to receive(:satisfied?).and_return(true) + expect(ENV).to receive(:x11) + subject.modify_build_environment + end + end +end diff --git a/Library/Homebrew/test/x11_requirement_test.rb b/Library/Homebrew/test/x11_requirement_test.rb deleted file mode 100644 index b82a59e53..000000000 --- a/Library/Homebrew/test/x11_requirement_test.rb +++ /dev/null @@ -1,31 +0,0 @@ -require "testing_env" -require "requirements/x11_requirement" - -class X11RequirementTests < Homebrew::TestCase - def test_eql_instances_are_eql - x = X11Requirement.new - y = X11Requirement.new - assert_eql x, y - assert_equal x.hash, y.hash - end - - def test_not_eql_when_hashes_differ - x = X11Requirement.new("foo") - y = X11Requirement.new - refute_eql x, y - refute_equal x.hash, y.hash - end - - def test_different_min_version - x = X11Requirement.new - y = X11Requirement.new("x11", %w[2.5]) - refute_eql x, y - end - - def test_x_env - x = X11Requirement.new - x.stubs(:satisfied?).returns(true) - ENV.expects(:x11) - x.modify_build_environment - end -end diff --git a/completions/zsh/_brew b/completions/zsh/_brew index 9f7b8ebe5..04cf56f70 100644 --- a/completions/zsh/_brew +++ b/completions/zsh/_brew @@ -88,6 +88,7 @@ __brew_common_commands() { 'doctor:audits your installation for common issues' 'edit:edit a formula' 'fetch:download formula resources to the cache' + 'formula:the path for a formula' 'gist-logs:generate a gist of the full build logs' 'home:visit the homepage of a formula or the brew project' 'info:information about a formula' @@ -366,6 +367,11 @@ _brew_fetch() { '*:formula:__brew_formulae' } +# brew formula formula: +_brew_formula() { + __brew_formulae +} + # brew gist-logs [--new-issue|-n] formula _brew_gist_logs() { _arguments \ diff --git a/docs/brew.1.html b/docs/brew.1.html index 6f2d1fb7b..e8b914281 100644 --- a/docs/brew.1.html +++ b/docs/brew.1.html @@ -540,6 +540,7 @@ you to explicitly set the name and version of the package you are creating.</p> the specified tap.</p></dd> <dt class="flush"><code>edit</code></dt><dd><p>Open all of Homebrew for editing.</p></dd> <dt><code>edit</code> <var>formula</var></dt><dd><p>Open <var>formula</var> in the editor.</p></dd> +<dt><code>formula</code> <var>formula</var></dt><dd><p>Display the path where <var>formula</var> is</p></dd> <dt><code>linkage</code> [<code>--test</code>] [<code>--reverse</code>] <var>formula-name</var></dt><dd><p>Checks the library links of an installed formula.</p> <p>Only works on installed formulae. An error is raised if it is run on diff --git a/manpages/brew.1 b/manpages/brew.1 index 8a9625798..7591cf4ea 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -731,6 +731,10 @@ Open all of Homebrew for editing\. Open \fIformula\fR in the editor\. . .TP +\fBformula\fR \fIformula\fR +Display the path where \fIformula\fR is +. +.TP \fBlinkage\fR [\fB\-\-test\fR] [\fB\-\-reverse\fR] \fIformula\-name\fR Checks the library links of an installed formula\. . |
