WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 3386050

Browse files
committed
test/cmd: use bottle pour for faster test run
1 parent 2d71360 commit 3386050

File tree

6 files changed

+94
-64
lines changed

6 files changed

+94
-64
lines changed

Library/Homebrew/test/cmd/install_spec.rb

Lines changed: 45 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,48 +10,66 @@
1010

1111
it_behaves_like "parseable arguments"
1212

13-
it "installs a Formula", :integration_test do
14-
setup_test_formula "testball1"
13+
it "installs a Formula from bottle", :integration_test do
14+
formula_name = "testball_bottle"
15+
formula_prefix = HOMEBREW_CELLAR/formula_name/"0.1"
16+
formula_prefix_regex = /#{Regexp.escape(formula_prefix)}/
17+
option_file = formula_prefix/"foo/test"
18+
bottle_file = formula_prefix/"bin/helloworld"
1519

16-
expect { brew "install", "testball1" }
17-
.to output(%r{#{HOMEBREW_CELLAR}/testball1/0\.1}o).to_stdout
20+
setup_test_formula formula_name
21+
22+
expect { brew "install", formula_name }
23+
.to output(formula_prefix_regex).to_stdout
1824
.and output(/✔︎.*/m).to_stderr
1925
.and be_a_success
20-
expect(testball1_rack/"0.1/foo/test").not_to be_a_file
26+
expect(option_file).not_to be_a_file
27+
expect(bottle_file).to be_a_file
2128

22-
uninstall_test_formula "testball1"
29+
uninstall_test_formula formula_name
2330

24-
expect { brew "install", "testball1", "--with-foo" }
25-
.to output(%r{#{HOMEBREW_CELLAR}/testball1/0\.1}o).to_stdout
31+
expect { brew "install", "--ask", formula_name }
32+
.to output(/.*Formula\s*\(1\):\s*#{formula_name}.*/).to_stdout
2633
.and output(/✔︎.*/m).to_stderr
2734
.and be_a_success
28-
expect(testball1_rack/"0.1/foo/test").to be_a_file
35+
expect(option_file).not_to be_a_file
36+
expect(bottle_file).to be_a_file
2937

30-
uninstall_test_formula "testball1"
38+
uninstall_test_formula formula_name
3139

32-
expect { brew "install", "testball1", "--debug-symbols", "--build-from-source" }
33-
.to output(%r{#{HOMEBREW_CELLAR}/testball1/0\.1}o).to_stdout
34-
.and output(/✔︎.*/m).to_stderr
35-
.and be_a_success
36-
expect(testball1_rack/"0.1/bin/test").to be_a_file
37-
expect(testball1_rack/"0.1/bin/test.dSYM/Contents/Resources/DWARF/test").to be_a_file if OS.mac?
38-
expect(HOMEBREW_CACHE/"Sources/testball1").to be_a_directory
40+
expect { brew "install", formula_name, { "HOMEBREW_FORBIDDEN_FORMULAE" => formula_name } }
41+
.to not_to_output(formula_prefix_regex).to_stdout
42+
.and output(/#{formula_name} was forbidden/).to_stderr
43+
.and be_a_failure
44+
expect(formula_prefix).not_to exist
45+
end
46+
47+
it "installs a Formula from source", :integration_test do
48+
formula_name = "testball2"
49+
formula_prefix = HOMEBREW_CELLAR/formula_name/"0.1"
50+
formula_prefix_regex = /#{Regexp.escape(formula_prefix)}/
51+
option_file = formula_prefix/"foo/test"
52+
always_built_file = formula_prefix/"bin/test"
3953

40-
uninstall_test_formula "testball1"
54+
setup_test_formula formula_name
4155

42-
expect { brew "install", "--ask", "testball1" }
43-
.to output(/.*Formula\s*\(1\):\s*testball1.*/).to_stdout
56+
expect { brew "install", formula_name, "--with-foo" }
57+
.to output(formula_prefix_regex).to_stdout
4458
.and output(/✔︎.*/m).to_stderr
4559
.and be_a_success
46-
expect(testball1_rack/"0.1/bin/test").to be_a_file
60+
expect(option_file).to be_a_file
61+
expect(always_built_file).to be_a_file
4762

48-
uninstall_test_formula "testball1"
63+
uninstall_test_formula formula_name
4964

50-
expect { brew "install", "testball1", { "HOMEBREW_FORBIDDEN_FORMULAE" => "testball1" } }
51-
.to not_to_output(%r{#{HOMEBREW_CELLAR}/testball1/0\.1}o).to_stdout
52-
.and output(/testball1 was forbidden/).to_stderr
53-
.and be_a_failure
54-
expect(testball1_rack).not_to exist
65+
expect { brew "install", formula_name, "--debug-symbols", "--build-from-source" }
66+
.to output(formula_prefix_regex).to_stdout
67+
.and output(/✔︎.*/m).to_stderr
68+
.and be_a_success
69+
expect(option_file).not_to be_a_file
70+
expect(always_built_file).to be_a_file
71+
expect(formula_prefix/"bin/test.dSYM/Contents/Resources/DWARF/test").to be_a_file if OS.mac?
72+
expect(HOMEBREW_CACHE/"Sources/#{formula_name}").to be_a_directory
5573
end
5674

5775
it "installs a keg-only Formula", :integration_test do

Library/Homebrew/test/cmd/reinstall_spec.rb

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,35 @@
88
it_behaves_like "parseable arguments"
99

1010
it "reinstalls a Formula", :aggregate_failures, :integration_test do
11-
setup_test_formula "testball", tab_attributes: { installed_on_request: true }
11+
formula_name = "testball_bottle"
12+
formula_prefix = HOMEBREW_CELLAR/formula_name/"0.1"
13+
formula_bin = formula_prefix/"bin"
1214

13-
testball_bin = HOMEBREW_CELLAR/"testball/0.1/bin"
14-
expect(testball_bin).not_to exist
15+
setup_test_formula formula_name, tab_attributes: { installed_on_request: true }
16+
Keg.new(formula_prefix).link
1517

16-
expect { brew "reinstall", "testball" }
17-
.to output(/Reinstalling testball/).to_stdout
18+
expect(formula_bin).not_to exist
19+
20+
expect { brew "reinstall", "--verbose", formula_name }
21+
.to output(/Reinstalling #{formula_name}/).to_stdout
1822
.and output(/✔︎.*/m).to_stderr
1923
.and be_a_success
20-
expect(testball_bin).to exist
24+
expect(formula_bin).to exist
2125

22-
FileUtils.rm_r(testball_bin)
26+
FileUtils.rm_r(formula_bin)
2327

24-
expect { brew "reinstall", "--ask", "testball" }
25-
.to output(/.*Formula\s*\(1\):\s*testball.*/).to_stdout
28+
expect { brew "reinstall", "--ask", formula_name }
29+
.to output(/.*Formula\s*\(1\):\s*#{formula_name}.*/).to_stdout
2630
.and output(/✔︎.*/m).to_stderr
2731
.and be_a_success
28-
expect(testball_bin).to exist
32+
expect(formula_bin).to exist
2933

30-
FileUtils.rm_r(testball_bin)
34+
FileUtils.rm_r(formula_bin)
3135

32-
expect { brew "reinstall", "testball", { "HOMEBREW_FORBIDDEN_FORMULAE" => "testball" } }
33-
.to not_to_output(%r{#{HOMEBREW_CELLAR}/testball/0\.1}o).to_stdout
34-
.and output(/testball was forbidden/).to_stderr
36+
expect { brew "reinstall", formula_name, { "HOMEBREW_FORBIDDEN_FORMULAE" => formula_name } }
37+
.to not_to_output(/#{Regexp.escape(formula_prefix)}/o).to_stdout
38+
.and output(/#{formula_name} was forbidden/).to_stderr
3539
.and be_a_failure
36-
37-
expect(testball_bin).not_to exist
40+
expect(formula_bin).not_to exist
3841
end
3942
end

Library/Homebrew/test/cmd/upgrade_spec.rb

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,50 +10,51 @@
1010
it_behaves_like "parseable arguments"
1111

1212
it "upgrades a Formula", :integration_test do
13-
setup_test_formula "testball"
13+
formula_name = "testball_bottle"
14+
formula_rack = HOMEBREW_CELLAR/formula_name
1415

15-
testball_rack = HOMEBREW_CELLAR/"testball"
16+
setup_test_formula formula_name
1617

17-
(testball_rack/"0.0.1/foo").mkpath
18+
(formula_rack/"0.0.1/foo").mkpath
1819

1920
expect { brew "upgrade" }.to be_a_success
2021

21-
expect(testball_rack/"0.1").to be_a_directory
22-
expect(testball_rack/"0.0.1").not_to exist
22+
expect(formula_rack/"0.1").to be_a_directory
23+
expect(formula_rack/"0.0.1").not_to exist
2324

24-
uninstall_test_formula "testball"
25+
uninstall_test_formula formula_name
2526

2627
# links newer version when upgrade was interrupted
27-
(testball_rack/"0.1/foo").mkpath
28+
(formula_rack/"0.1/foo").mkpath
2829

2930
expect { brew "upgrade" }.to be_a_success
3031

31-
expect(testball_rack/"0.1").to be_a_directory
32-
expect(HOMEBREW_PREFIX/"opt/testball").to be_a_symlink
33-
expect(HOMEBREW_PREFIX/"var/homebrew/linked/testball").to be_a_symlink
32+
expect(formula_rack/"0.1").to be_a_directory
33+
expect(HOMEBREW_PREFIX/"opt/#{formula_name}").to be_a_symlink
34+
expect(HOMEBREW_PREFIX/"var/homebrew/linked/#{formula_name}").to be_a_symlink
3435

35-
uninstall_test_formula "testball"
36+
uninstall_test_formula formula_name
3637

3738
# upgrades with asking for user prompts
38-
(testball_rack/"0.0.1/foo").mkpath
39+
(formula_rack/"0.0.1/foo").mkpath
3940

4041
expect { brew "upgrade", "--ask" }
41-
.to output(/.*Formula\s*\(1\):\s*testball.*/).to_stdout
42+
.to output(/.*Formula\s*\(1\):\s*#{formula_name}.*/).to_stdout
4243
.and output(/✔︎.*/m).to_stderr
4344

44-
expect(testball_rack/"0.1").to be_a_directory
45-
expect(testball_rack/"0.0.1").not_to exist
45+
expect(formula_rack/"0.1").to be_a_directory
46+
expect(formula_rack/"0.0.1").not_to exist
4647

47-
uninstall_test_formula "testball"
48+
uninstall_test_formula formula_name
4849

4950
# refuses to upgrade a forbidden formula
50-
(testball_rack/"0.0.1/foo").mkpath
51+
(formula_rack/"0.0.1/foo").mkpath
5152

52-
expect { brew "upgrade", "testball", { "HOMEBREW_FORBIDDEN_FORMULAE" => "testball" } }
53-
.to not_to_output(%r{#{HOMEBREW_CELLAR}/testball/0\.1}o).to_stdout
54-
.and output(/testball was forbidden/).to_stderr
53+
expect { brew "upgrade", formula_name, { "HOMEBREW_FORBIDDEN_FORMULAE" => formula_name } }
54+
.to not_to_output(%r{#{formula_rack}/0\.1}o).to_stdout
55+
.and output(/#{formula_name} was forbidden/).to_stderr
5556
.and be_a_failure
56-
expect(testball_rack/"0.1").not_to exist
57+
expect(formula_rack/"0.1").not_to exist
5758
end
5859

5960
it_behaves_like "reinstall_pkgconf_if_needed"

Library/Homebrew/test/spec_helper.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
HOMEBREW_LOCKS,
6767
HOMEBREW_LOGS,
6868
HOMEBREW_TEMP,
69+
HOMEBREW_TEMP_CELLAR,
6970
HOMEBREW_ALIASES,
7071
].freeze
7172

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
testball_bottle-0.1.yosemite.bottle.tar.gz

Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ def setup_test_formula(name, content = nil, tap: CoreTap.instance,
144144
else
145145
TEST_FIXTURE_DIR/"tarballs/#{prefix}-0.1.tbz"
146146
end
147+
bottle_block ||= <<~RUBY if name == "testball_bottle"
148+
bottle do
149+
root_url "file://#{TEST_FIXTURE_DIR}/bottles"
150+
sha256 cellar: :any_skip_relocation, all: "d7b9f4e8bf83608b71fe958a99f19f2e5e68bb2582965d32e41759c24f1aef97"
151+
end
152+
RUBY
147153
content = <<~RUBY
148154
desc "Some test"
149155
homepage "https://brew.sh/#{name}"

0 commit comments

Comments
 (0)