aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test
diff options
context:
space:
mode:
Diffstat (limited to 'Library/Homebrew/test')
-rw-r--r--Library/Homebrew/test/cask/dsl_spec.rb2
-rw-r--r--Library/Homebrew/test/cleanup_spec.rb33
-rw-r--r--Library/Homebrew/test/cmd/link_spec.rb6
-rw-r--r--Library/Homebrew/test/cmd/outdated_spec.rb92
-rw-r--r--Library/Homebrew/test/formula_installer_spec.rb7
-rw-r--r--Library/Homebrew/test/formula_spec.rb28
-rw-r--r--Library/Homebrew/test/missing_formula_spec.rb8
-rw-r--r--Library/Homebrew/test/tab_spec.rb2
8 files changed, 157 insertions, 21 deletions
diff --git a/Library/Homebrew/test/cask/dsl_spec.rb b/Library/Homebrew/test/cask/dsl_spec.rb
index 7872b42a6..7eeabcf49 100644
--- a/Library/Homebrew/test/cask/dsl_spec.rb
+++ b/Library/Homebrew/test/cask/dsl_spec.rb
@@ -26,8 +26,6 @@ describe Hbc::DSL, :cask do
.*
Unexpected method 'future_feature' called on Cask unexpected-method-cask\\.
.*
- https://github.com/caskroom/homebrew-cask/blob/master/doc/reporting_bugs/pre_bug_report.md
- .*
https://github.com/caskroom/homebrew-cask#reporting-bugs
EOS
diff --git a/Library/Homebrew/test/cleanup_spec.rb b/Library/Homebrew/test/cleanup_spec.rb
index b0e824767..2c3eddb8c 100644
--- a/Library/Homebrew/test/cleanup_spec.rb
+++ b/Library/Homebrew/test/cleanup_spec.rb
@@ -34,6 +34,39 @@ describe Homebrew::Cleanup do
expect(ds_store).to exist
end
+
+ context "when it can't remove a keg" do
+ let(:f1) { Class.new(Testball) { version "0.1" }.new }
+ let(:f2) { Class.new(Testball) { version "0.2" }.new }
+ let(:unremovable_kegs) { [] }
+
+ before(:each) do
+ described_class.instance_variable_set(:@unremovable_kegs, [])
+ shutup do
+ [f1, f2].each do |f|
+ f.brew do
+ f.install
+ end
+
+ Tab.create(f, DevelopmentTools.default_compiler, :libcxx).write
+ end
+ end
+
+ allow_any_instance_of(Keg)
+ .to receive(:uninstall)
+ .and_raise(Errno::EACCES)
+ end
+
+ it "doesn't remove any kegs" do
+ shutup { described_class.cleanup_formula f2 }
+ expect(f1.installed_kegs.size).to eq(2)
+ end
+
+ it "lists the unremovable kegs" do
+ shutup { described_class.cleanup_formula f2 }
+ expect(described_class.unremovable_kegs).to contain_exactly(f1.installed_kegs[0])
+ end
+ end
end
specify "::cleanup_formula" do
diff --git a/Library/Homebrew/test/cmd/link_spec.rb b/Library/Homebrew/test/cmd/link_spec.rb
index 7b85c96dc..59ab86cc4 100644
--- a/Library/Homebrew/test/cmd/link_spec.rb
+++ b/Library/Homebrew/test/cmd/link_spec.rb
@@ -48,9 +48,11 @@ describe "brew link", :integration_test do
expect { brew "install", "testball1" }.to be_a_success
end
- expect { brew "link", "testball1" }
+ expect { brew "link", "testball1", "SHELL" => "/bin/zsh" }
.to output(/testball1 is keg-only/).to_stderr
- .and output(/Note that doing so can interfere with building software\./).to_stdout
+ .and output(a_string_matching(/Note that doing so can interfere with building software\./)
+ .and(matching("If you need to have this software first in your PATH instead consider running:")
+ .and(including("echo 'export PATH=\"#{HOMEBREW_PREFIX}/opt/testball1/bin:$PATH\"' >> ~/.zshrc")))).to_stdout
.and be_a_success
end
end
diff --git a/Library/Homebrew/test/cmd/outdated_spec.rb b/Library/Homebrew/test/cmd/outdated_spec.rb
index 2ce0825e8..65cce27c3 100644
--- a/Library/Homebrew/test/cmd/outdated_spec.rb
+++ b/Library/Homebrew/test/cmd/outdated_spec.rb
@@ -1,11 +1,87 @@
describe "brew outdated", :integration_test do
- it "prints outdated Formulae" do
- setup_test_formula "testball"
- (HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath
-
- expect { brew "outdated" }
- .to output("testball\n").to_stdout
- .and not_to_output.to_stderr
- .and be_a_success
+ context "quiet output" do
+ it "prints outdated Formulae" do
+ setup_test_formula "testball"
+ (HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath
+
+ expect { brew "outdated" }
+ .to output("testball\n").to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+ end
+ end
+
+ context "verbose output" do
+ it "prints out the installed and newer versions" do
+ setup_test_formula "testball"
+ (HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath
+
+ expect { brew "outdated", "--verbose" }
+ .to output("testball (0.0.1) < 0.1\n").to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+ end
+ end
+
+ context "pinned formula, verbose output" do
+ it "prints out the pinned version" do
+ setup_test_formula "testball"
+ (HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath
+
+ shutup do
+ expect { brew "pin", "testball" }.to be_a_success
+ end
+
+ expect { brew "outdated", "--verbose" }
+ .to output("testball (0.0.1) < 0.1 [pinned at 0.0.1]\n").to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+ end
+ end
+
+ context "json output" do
+ it "includes pinned version in the json output" do
+ setup_test_formula "testball"
+ (HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath
+
+ shutup do
+ expect { brew "pin", "testball" }.to be_a_success
+ end
+
+ expected_json = [
+ {
+ name: "testball",
+ installed_versions: ["0.0.1"],
+ current_version: "0.1",
+ pinned: true,
+ pinned_version: "0.0.1",
+ },
+ ].to_json
+
+ expect { brew "outdated", "--json=v1" }
+ .to output(expected_json + "\n").to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+ end
+
+ it "has no pinned version when the formula isn't pinned" do
+ setup_test_formula "testball"
+ (HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath
+
+ expected_json = [
+ {
+ name: "testball",
+ installed_versions: ["0.0.1"],
+ current_version: "0.1",
+ pinned: false,
+ pinned_version: nil,
+ },
+ ].to_json
+
+ expect { brew "outdated", "--json=v1" }
+ .to output(expected_json + "\n").to_stdout
+ .and not_to_output.to_stderr
+ .and be_a_success
+ end
end
end
diff --git a/Library/Homebrew/test/formula_installer_spec.rb b/Library/Homebrew/test/formula_installer_spec.rb
index f5218db73..efe2bf5a2 100644
--- a/Library/Homebrew/test/formula_installer_spec.rb
+++ b/Library/Homebrew/test/formula_installer_spec.rb
@@ -159,6 +159,13 @@ describe FormulaInstaller do
it { is_expected.to be false }
end
+ context "it returns false when requirement is satisfied but default formula is installed" do
+ let(:satisfied?) { true }
+ let(:satisfied_by_formula?) { false }
+ let(:installed?) { true }
+ it { is_expected.to be false }
+ end
+
context "it returns true when requirement isn't satisfied" do
let(:satisfied?) { false }
let(:satisfied_by_formula?) { false }
diff --git a/Library/Homebrew/test/formula_spec.rb b/Library/Homebrew/test/formula_spec.rb
index 1e064912f..2309c36fb 100644
--- a/Library/Homebrew/test/formula_spec.rb
+++ b/Library/Homebrew/test/formula_spec.rb
@@ -129,6 +129,8 @@ describe Formula do
alias_name = "bar"
alias_path = "#{CoreTap.instance.alias_dir}/#{alias_name}"
+ CoreTap.instance.alias_dir.mkpath
+ FileUtils.ln_sf f.path, alias_path
f.build = Tab.new(source: { "path" => alias_path })
@@ -160,6 +162,8 @@ describe Formula do
alias_name = "bar"
full_alias_name = "#{tap.user}/#{tap.repo}/#{alias_name}"
alias_path = "#{tap.alias_dir}/#{alias_name}"
+ tap.alias_dir.mkpath
+ FileUtils.ln_sf f.path, alias_path
f.build = Tab.new(source: { "path" => alias_path })
@@ -168,6 +172,8 @@ describe Formula do
expect(f.full_installed_alias_name).to eq(full_alias_name)
expect(f.installed_specified_name).to eq(alias_name)
expect(f.full_installed_specified_name).to eq(full_alias_name)
+
+ FileUtils.rm_rf HOMEBREW_LIBRARY/"Taps/user"
end
specify "#prefix" do
@@ -402,6 +408,8 @@ describe Formula do
url "foo-1.0"
end
f.build = Tab.new(source: { "path" => source_path.to_s })
+ CoreTap.instance.alias_dir.mkpath
+ FileUtils.ln_sf f.path, source_path
expect(f.alias_path).to eq(alias_path)
expect(f.installed_alias_path).to eq(source_path.to_s)
@@ -443,6 +451,9 @@ describe Formula do
allow(described_class).to receive(:installed).and_return(formulae)
+ CoreTap.instance.alias_dir.mkpath
+ FileUtils.ln_sf formula_with_alias.path, alias_path
+
expect(described_class.installed_with_alias_path(alias_path))
.to eq([formula_with_alias])
end
@@ -940,6 +951,9 @@ describe Formula do
tab.source["path"] = alias_path
stub_formula_loader(f, alias_path)
+ CoreTap.instance.alias_dir.mkpath
+ FileUtils.ln_sf f.path, alias_path
+
expect(f.current_installed_alias_target).to eq(f)
expect(f.latest_formula).to eq(f)
expect(f).not_to have_changed_installed_alias_target
@@ -952,6 +966,9 @@ describe Formula do
tab.source["path"] = alias_path
stub_formula_loader(new_formula, alias_path)
+ CoreTap.instance.alias_dir.mkpath
+ FileUtils.ln_sf new_formula.path, alias_path
+
expect(f.current_installed_alias_target).to eq(new_formula)
expect(f.latest_formula).to eq(new_formula)
expect(f).to have_changed_installed_alias_target
@@ -964,6 +981,9 @@ describe Formula do
tab.source["path"] = alias_path
stub_formula_loader(new_formula, alias_path)
+ CoreTap.instance.alias_dir.mkpath
+ FileUtils.ln_sf new_formula.path, alias_path
+
expect(new_formula.current_installed_alias_target).to eq(new_formula)
expect(new_formula.latest_formula).to eq(new_formula)
expect(new_formula).not_to have_changed_installed_alias_target
@@ -1050,6 +1070,10 @@ describe Formula do
f.follow_installed_alias = true
f.build = setup_tab_for_prefix(same_prefix, path: alias_path)
stub_formula_loader(new_formula, alias_path)
+
+ CoreTap.instance.alias_dir.mkpath
+ FileUtils.ln_sf new_formula.path, alias_path
+
expect(f.outdated_kegs).not_to be_empty
end
@@ -1088,6 +1112,10 @@ describe Formula do
tab = setup_tab_for_prefix(old_alias_target_prefix, path: alias_path)
old_formula.build = tab
allow(described_class).to receive(:installed).and_return([old_formula])
+
+ CoreTap.instance.alias_dir.mkpath
+ FileUtils.ln_sf f.path, alias_path
+
expect(f.outdated_kegs).not_to be_empty
end
diff --git a/Library/Homebrew/test/missing_formula_spec.rb b/Library/Homebrew/test/missing_formula_spec.rb
index f395965a6..215cf17f7 100644
--- a/Library/Homebrew/test/missing_formula_spec.rb
+++ b/Library/Homebrew/test/missing_formula_spec.rb
@@ -88,14 +88,6 @@ describe Homebrew::MissingFormula do
it { is_expected.to be_blacklisted }
end
- context "osmium" do
- %w[osmium Osmium].each do |s|
- subject { s }
-
- it { is_expected.to be_blacklisted }
- end
- end
-
context "gfortran" do
subject { "gfortran" }
diff --git a/Library/Homebrew/test/tab_spec.rb b/Library/Homebrew/test/tab_spec.rb
index fec390c28..1b0836c93 100644
--- a/Library/Homebrew/test/tab_spec.rb
+++ b/Library/Homebrew/test/tab_spec.rb
@@ -258,7 +258,7 @@ describe Tab do
it "can create a Tab for a non-existant Keg" do
f.prefix.mkpath
- expect(subject.tabfile).to be nil
+ expect(subject.tabfile).to eq(f_tab_path)
end
end