Skip to content

Commit 2d71360

Browse files
authored
Merge pull request #21174 from Homebrew/test-setup_test_formula
test: replace some install_test_formula with setup_test_formula
2 parents 0530b45 + dfdef32 commit 2d71360

File tree

7 files changed

+17
-20
lines changed

7 files changed

+17
-20
lines changed

Library/Homebrew/test/cmd/autoremove_spec.rb

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,12 @@
1212

1313
before do
1414
# Make testball1 poured from a bottle
15-
install_test_formula "testball1"
16-
tab = Tab.for_name("testball1")
17-
tab.poured_from_bottle = true
18-
tab.write
15+
tab_attributes = { poured_from_bottle: true, installed_on_request: true, installed_as_dependency: false }
16+
setup_test_formula("testball1", tab_attributes:)
1917

2018
# Make testball2 poured from a bottle and an unused dependency
21-
install_test_formula "testball2"
22-
tab = Tab.for_name("testball2")
23-
tab.installed_on_request = false
24-
tab.installed_as_dependency = true
25-
tab.poured_from_bottle = true
26-
tab.write
19+
tab_attributes = { poured_from_bottle: true, installed_on_request: false, installed_as_dependency: true }
20+
setup_test_formula("testball2", tab_attributes:)
2721
end
2822

2923
it "only removes unused dependencies", :integration_test do

Library/Homebrew/test/cmd/link_spec.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@
77
it_behaves_like "parseable arguments"
88

99
it "links a given Formula", :integration_test do
10-
install_test_formula "testball"
10+
setup_test_formula "testball", tab_attributes: { installed_on_request: true }
1111
Formula["testball"].any_installed_keg.unlink
12+
Formula["testball"].bin.mkpath
13+
FileUtils.touch Formula["testball"].bin/"testfile"
1214

1315
expect { brew "link", "testball" }
1416
.to output(/Linking/).to_stdout
1517
.and not_to_output.to_stderr
1618
.and be_a_success
19+
expect(HOMEBREW_PREFIX/"bin/testfile").to be_a_file
1720
end
1821
end

Library/Homebrew/test/cmd/pin_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
it_behaves_like "parseable arguments"
88

99
it "pins a Formula's version", :integration_test do
10-
install_test_formula "testball"
10+
setup_test_formula "testball", tab_attributes: { installed_on_request: true }
1111

1212
expect { brew "pin", "testball" }.to be_a_success
1313
end

Library/Homebrew/test/cmd/reinstall_spec.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@
88
it_behaves_like "parseable arguments"
99

1010
it "reinstalls a Formula", :aggregate_failures, :integration_test do
11-
install_test_formula "testball"
11+
setup_test_formula "testball", tab_attributes: { installed_on_request: true }
1212

1313
testball_bin = HOMEBREW_CELLAR/"testball/0.1/bin"
14-
expect(testball_bin).to exist
15-
FileUtils.rm_r(testball_bin)
14+
expect(testball_bin).not_to exist
1615

1716
expect { brew "reinstall", "testball" }
1817
.to output(/Reinstalling testball/).to_stdout

Library/Homebrew/test/cmd/uninstall_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77
it_behaves_like "parseable arguments"
88

99
it "uninstalls a given Formula", :integration_test do
10-
install_test_formula "testball"
10+
setup_test_formula "testball", tab_attributes: { installed_on_request: true }
1111

12+
expect(HOMEBREW_CELLAR/"testball").to exist
1213
expect { brew "uninstall", "--force", "testball" }
1314
.to output(/Uninstalling testball/).to_stdout
1415
.and not_to_output.to_stderr
1516
.and be_a_success
17+
expect(HOMEBREW_CELLAR/"testball").not_to exist
1618
end
1719
end

Library/Homebrew/test/cmd/unpin_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
it_behaves_like "parseable arguments"
88

99
it "unpins a Formula's version", :integration_test do
10-
install_test_formula "testball"
10+
setup_test_formula "testball", tab_attributes: { installed_on_request: true }
1111
Formula["testball"].pin
1212

1313
expect { brew "unpin", "testball" }.to be_a_success

Library/Homebrew/test/formula_info_spec.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44

55
RSpec.describe FormulaInfo, :integration_test do
66
it "tests the FormulaInfo class" do
7-
install_test_formula "testball"
8-
9-
info = described_class.lookup(Formula["testball"].path)
7+
formula_path = setup_test_formula "testball"
8+
info = described_class.lookup(formula_path)
109
expect(info).not_to be_nil
1110
expect(info.revision).to eq(0)
1211
expect(info.bottle_tags).to eq([])

0 commit comments

Comments
 (0)