Avoid warnings when HOMEBREW_PREFIX/bin is not in PATH.

This commit is contained in:
Markus Reiter 2017-02-25 09:01:24 +01:00
parent a2b4ee1ecd
commit ec0f2187a2
3 changed files with 17 additions and 12 deletions

View File

@ -19,7 +19,7 @@ describe "brew install", :integration_test do
expect { brew "install", "testball1" } expect { brew "install", "testball1" }
.to output(%r{#{HOMEBREW_CELLAR}/testball1/0\.1}).to_stdout .to output(%r{#{HOMEBREW_CELLAR}/testball1/0\.1}).to_stdout
.and output(/not in your PATH/).to_stderr .and not_to_output.to_stderr
.and be_a_success .and be_a_success
expect { brew "install", "testball1" } expect { brew "install", "testball1" }
@ -62,7 +62,7 @@ describe "brew install", :integration_test do
expect { brew "install", "testball1" } expect { brew "install", "testball1" }
.to output(%r{#{HOMEBREW_CELLAR}/testball1/1\.0}).to_stdout .to output(%r{#{HOMEBREW_CELLAR}/testball1/1\.0}).to_stdout
.and output(/not in your PATH/).to_stderr .and not_to_output.to_stderr
.and be_a_success .and be_a_success
FileUtils.rm path FileUtils.rm path
@ -88,7 +88,7 @@ describe "brew install", :integration_test do
expect { brew "install", "testball1", "--devel" } expect { brew "install", "testball1", "--devel" }
.to output(%r{#{HOMEBREW_CELLAR}/testball1/3\.0}).to_stdout .to output(%r{#{HOMEBREW_CELLAR}/testball1/3\.0}).to_stdout
.and output(/not in your PATH/).to_stderr .and not_to_output.to_stderr
.and be_a_success .and be_a_success
expect { brew "unlink", "testball1" } expect { brew "unlink", "testball1" }
@ -98,7 +98,7 @@ describe "brew install", :integration_test do
expect { brew "install", "testball1" } expect { brew "install", "testball1" }
.to output(%r{#{HOMEBREW_CELLAR}/testball1/2\.0}).to_stdout .to output(%r{#{HOMEBREW_CELLAR}/testball1/2\.0}).to_stdout
.and output(/not in your PATH/).to_stderr .and not_to_output.to_stderr
.and be_a_success .and be_a_success
shutup do shutup do
@ -181,7 +181,7 @@ describe "brew install", :integration_test do
# formula since we only have testball1 formula. # formula since we only have testball1 formula.
expect { brew "install", "testball1", "--HEAD", "--ignore-dependencies" } expect { brew "install", "testball1", "--HEAD", "--ignore-dependencies" }
.to output(%r{#{HOMEBREW_CELLAR}/testball1/HEAD\-d5eb689}).to_stdout .to output(%r{#{HOMEBREW_CELLAR}/testball1/HEAD\-d5eb689}).to_stdout
.and output(/not in your PATH/).to_stderr .and output(/Cloning into/).to_stderr
.and be_a_success .and be_a_success
expect { brew "install", "testball1", "--HEAD", "--ignore-dependencies" } expect { brew "install", "testball1", "--HEAD", "--ignore-dependencies" }
@ -196,7 +196,7 @@ describe "brew install", :integration_test do
expect { brew "install", "testball1" } expect { brew "install", "testball1" }
.to output(%r{#{HOMEBREW_CELLAR}/testball1/1\.0}).to_stdout .to output(%r{#{HOMEBREW_CELLAR}/testball1/1\.0}).to_stdout
.and output(/not in your PATH/).to_stderr .and not_to_output.to_stderr
.and be_a_success .and be_a_success
end end
@ -220,7 +220,7 @@ describe "brew install", :integration_test do
# FIXME: This should output to STDERR. # FIXME: This should output to STDERR.
expect { brew "install", "testball1" } expect { brew "install", "testball1" }
.to output(/NonFatalRequirement unsatisfied!/).to_stdout .to output(/NonFatalRequirement unsatisfied!/).to_stdout
.and output(/not in your PATH/).to_stderr .and not_to_output.to_stderr
.and be_a_success .and be_a_success
end end

View File

@ -1,9 +1,6 @@
require "extend/ENV" require "extend/ENV"
describe "brew reinstall", :integration_test do describe "brew reinstall", :integration_test do
let(:bin) { (HOMEBREW_PREFIX/"bin").realpath }
let(:path) { "#{bin}#{File::PATH_SEPARATOR}#{ENV["PATH"]}" }
before(:each) do before(:each) do
setup_test_formula "testball" setup_test_formula "testball"
@ -17,7 +14,7 @@ describe "brew reinstall", :integration_test do
expect(foo_dir).to exist expect(foo_dir).to exist
foo_dir.rmtree foo_dir.rmtree
expect { brew "reinstall", "testball", "PATH" => path } expect { brew "reinstall", "testball" }
.to output(/Reinstalling testball --with-foo/).to_stdout .to output(/Reinstalling testball --with-foo/).to_stdout
.and not_to_output.to_stderr .and not_to_output.to_stderr
.and be_a_success .and be_a_success
@ -26,7 +23,7 @@ describe "brew reinstall", :integration_test do
end end
it "reinstalls a Formula even when one of the options is invalid" do it "reinstalls a Formula even when one of the options is invalid" do
expect { brew "reinstall", "testball", "--with-fo", "PATH" => path } expect { brew "reinstall", "testball", "--with-fo" }
.to output(/Reinstalling testball --with-foo/).to_stdout .to output(/Reinstalling testball --with-foo/).to_stdout
.and output(/testball: this formula has no \-\-with-fo option so it will be ignored!/).to_stderr .and output(/testball: this formula has no \-\-with-fo option so it will be ignored!/).to_stderr
.and be_a_success .and be_a_success

View File

@ -63,7 +63,15 @@ RSpec.shared_context "integration test" do
def brew(*args) def brew(*args)
env = args.last.is_a?(Hash) ? args.pop : {} env = args.last.is_a?(Hash) ? args.pop : {}
# Avoid warnings when HOMEBREW_PREFIX/bin is not in PATH.
path = [
env["PATH"],
(HOMEBREW_PREFIX/"bin").realpath.to_s,
ENV["PATH"],
].compact.join(File::PATH_SEPARATOR)
env.merge!( env.merge!(
"PATH" => path,
"HOMEBREW_BREW_FILE" => HOMEBREW_PREFIX/"bin/brew", "HOMEBREW_BREW_FILE" => HOMEBREW_PREFIX/"bin/brew",
"HOMEBREW_INTEGRATION_TEST" => command_id_from_args(args), "HOMEBREW_INTEGRATION_TEST" => command_id_from_args(args),
"HOMEBREW_TEST_TMPDIR" => TEST_TMPDIR, "HOMEBREW_TEST_TMPDIR" => TEST_TMPDIR,