|
6 | 6 | RSpec.describe Homebrew::Cmd::InstallCmd do |
7 | 7 | include FileUtils |
8 | 8 |
|
9 | | - let(:testball1_rack) { HOMEBREW_CELLAR/"testball1" } |
10 | | - |
11 | 9 | it_behaves_like "parseable arguments" |
12 | 10 |
|
13 | | - it "installs a Formula", :integration_test do |
14 | | - setup_test_formula "testball1" |
15 | | - |
16 | | - expect { brew "install", "testball1" } |
17 | | - .to output(%r{#{HOMEBREW_CELLAR}/testball1/0\.1}o).to_stdout |
18 | | - .and output(/✔︎.*/m).to_stderr |
19 | | - .and be_a_success |
20 | | - expect(testball1_rack/"0.1/foo/test").not_to be_a_file |
21 | | - |
22 | | - uninstall_test_formula "testball1" |
23 | | - |
24 | | - expect { brew "install", "testball1", "--with-foo" } |
25 | | - .to output(%r{#{HOMEBREW_CELLAR}/testball1/0\.1}o).to_stdout |
26 | | - .and output(/✔︎.*/m).to_stderr |
27 | | - .and be_a_success |
28 | | - expect(testball1_rack/"0.1/foo/test").to be_a_file |
29 | | - |
30 | | - uninstall_test_formula "testball1" |
31 | | - |
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 |
39 | | - |
40 | | - uninstall_test_formula "testball1" |
41 | | - |
42 | | - expect { brew "install", "--ask", "testball1" } |
43 | | - .to output(/.*Formula\s*\(1\):\s*testball1.*/).to_stdout |
44 | | - .and output(/✔︎.*/m).to_stderr |
45 | | - .and be_a_success |
46 | | - expect(testball1_rack/"0.1/bin/test").to be_a_file |
47 | | - |
48 | | - uninstall_test_formula "testball1" |
| 11 | + context "when using a bottle" do |
| 12 | + let(:formula_name) { "testball_bottle" } |
| 13 | + let(:formula_prefix) { HOMEBREW_CELLAR/formula_name/"0.1" } |
| 14 | + let(:formula_prefix_regex) { /#{Regexp.escape(formula_prefix)}/o } |
| 15 | + let(:option_file) { formula_prefix/"foo/test" } |
| 16 | + let(:bottle_file) { formula_prefix/"bin/helloworld" } |
| 17 | + |
| 18 | + it "installs a Formula", :integration_test do |
| 19 | + setup_test_formula formula_name |
| 20 | + |
| 21 | + expect { brew "install", formula_name } |
| 22 | + .to output(formula_prefix_regex).to_stdout |
| 23 | + .and output(/✔︎.*/m).to_stderr |
| 24 | + .and be_a_success |
| 25 | + expect(option_file).not_to be_a_file |
| 26 | + expect(bottle_file).to be_a_file |
| 27 | + |
| 28 | + uninstall_test_formula formula_name |
| 29 | + |
| 30 | + expect { brew "install", "--ask", formula_name } |
| 31 | + .to output(/.*Formula\s*\(1\):\s*#{formula_name}.*/).to_stdout |
| 32 | + .and output(/✔︎.*/m).to_stderr |
| 33 | + .and be_a_success |
| 34 | + expect(option_file).not_to be_a_file |
| 35 | + expect(bottle_file).to be_a_file |
| 36 | + |
| 37 | + uninstall_test_formula formula_name |
| 38 | + |
| 39 | + expect { brew "install", formula_name, { "HOMEBREW_FORBIDDEN_FORMULAE" => formula_name } } |
| 40 | + .to not_to_output(formula_prefix_regex).to_stdout |
| 41 | + .and output(/#{formula_name} was forbidden/).to_stderr |
| 42 | + .and be_a_failure |
| 43 | + expect(formula_prefix).not_to exist |
| 44 | + end |
49 | 45 |
|
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 |
| 46 | + it "installs a keg-only Formula", :integration_test do |
| 47 | + setup_test_formula formula_name, <<~RUBY |
| 48 | + keg_only "test reason" |
| 49 | + RUBY |
| 50 | + |
| 51 | + expect { brew "install", formula_name } |
| 52 | + .to output(formula_prefix_regex).to_stdout |
| 53 | + .and output(/✔︎.*/m).to_stderr |
| 54 | + .and be_a_success |
| 55 | + expect(option_file).not_to be_a_file |
| 56 | + expect(bottle_file).to be_a_file |
| 57 | + expect(HOMEBREW_PREFIX/"bin/helloworld").not_to be_a_file |
| 58 | + end |
55 | 59 | end |
56 | 60 |
|
57 | | - it "installs a keg-only Formula", :integration_test do |
58 | | - setup_test_formula "testball1", <<~RUBY |
59 | | - version "1.0" |
60 | | -
|
61 | | - keg_only "test reason" |
62 | | - RUBY |
| 61 | + context "when building from source" do |
| 62 | + let(:formula_name) { "testball1" } |
| 63 | + |
| 64 | + it "installs a Formula", :integration_test do |
| 65 | + formula_prefix = HOMEBREW_CELLAR/formula_name/"0.1" |
| 66 | + formula_prefix_regex = /#{Regexp.escape(formula_prefix)}/o |
| 67 | + option_file = formula_prefix/"foo/test" |
| 68 | + always_built_file = formula_prefix/"bin/test" |
| 69 | + |
| 70 | + setup_test_formula formula_name |
| 71 | + |
| 72 | + expect { brew "install", formula_name, "--with-foo" } |
| 73 | + .to output(formula_prefix_regex).to_stdout |
| 74 | + .and output(/✔︎.*/m).to_stderr |
| 75 | + .and be_a_success |
| 76 | + expect(option_file).to be_a_file |
| 77 | + expect(always_built_file).to be_a_file |
| 78 | + |
| 79 | + uninstall_test_formula formula_name |
| 80 | + |
| 81 | + expect { brew "install", formula_name, "--debug-symbols", "--build-from-source" } |
| 82 | + .to output(formula_prefix_regex).to_stdout |
| 83 | + .and output(/✔︎.*/m).to_stderr |
| 84 | + .and be_a_success |
| 85 | + expect(option_file).not_to be_a_file |
| 86 | + expect(always_built_file).to be_a_file |
| 87 | + expect(formula_prefix/"bin/test.dSYM/Contents/Resources/DWARF/test").to be_a_file if OS.mac? |
| 88 | + expect(HOMEBREW_CACHE/"Sources/#{formula_name}").to be_a_directory |
| 89 | + end |
63 | 90 |
|
64 | | - expect { brew "install", "testball1" } |
65 | | - .to output(%r{#{testball1_rack}/1\.0}o).to_stdout |
66 | | - .and output(/✔︎.*/m).to_stderr |
67 | | - .and be_a_success |
68 | | - expect(testball1_rack/"1.0/foo/test").not_to be_a_file |
69 | | - end |
| 91 | + it "installs a HEAD Formula", :integration_test do |
| 92 | + testball1_prefix = HOMEBREW_CELLAR/"testball1/HEAD-d5eb689" |
| 93 | + repo_path = HOMEBREW_CACHE/"repo" |
| 94 | + (repo_path/"bin").mkpath |
| 95 | + |
| 96 | + repo_path.cd do |
| 97 | + system "git", "-c", "init.defaultBranch=master", "init" |
| 98 | + system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo" |
| 99 | + FileUtils.touch "bin/something.bin" |
| 100 | + FileUtils.touch "README" |
| 101 | + system "git", "add", "--all" |
| 102 | + system "git", "commit", "-m", "Initial repo commit" |
| 103 | + end |
70 | 104 |
|
71 | | - it "installs a HEAD Formula", :integration_test do |
72 | | - repo_path = HOMEBREW_CACHE/"repo" |
73 | | - (repo_path/"bin").mkpath |
74 | | - |
75 | | - repo_path.cd do |
76 | | - system "git", "-c", "init.defaultBranch=master", "init" |
77 | | - system "git", "remote", "add", "origin", "https://github.com/Homebrew/homebrew-foo" |
78 | | - FileUtils.touch "bin/something.bin" |
79 | | - FileUtils.touch "README" |
80 | | - system "git", "add", "--all" |
81 | | - system "git", "commit", "-m", "Initial repo commit" |
82 | | - end |
| 105 | + setup_test_formula "testball1", <<~RUBY |
| 106 | + version "1.0" |
83 | 107 |
|
84 | | - setup_test_formula "testball1", <<~RUBY |
85 | | - version "1.0" |
| 108 | + head "file://#{repo_path}", using: :git |
86 | 109 |
|
87 | | - head "file://#{repo_path}", :using => :git |
| 110 | + def install |
| 111 | + prefix.install Dir["*"] |
| 112 | + end |
| 113 | + RUBY |
88 | 114 |
|
89 | | - def install |
90 | | - prefix.install Dir["*"] |
91 | | - end |
92 | | - RUBY |
93 | | - |
94 | | - # Ignore dependencies, because we'll try to resolve requirements in build.rb |
95 | | - # and there will be the git requirement, but we cannot instantiate git |
96 | | - # formula since we only have testball1 formula. |
97 | | - expect { brew "install", "testball1", "--HEAD", "--ignore-dependencies", "HOMEBREW_DOWNLOAD_CONCURRENCY" => "1" } |
98 | | - .to output(%r{#{testball1_rack}/HEAD-d5eb689}o).to_stdout |
99 | | - .and output(/Cloning into/).to_stderr |
100 | | - .and be_a_success |
101 | | - expect(testball1_rack/"HEAD-d5eb689/foo/test").not_to be_a_file |
| 115 | + expect { brew "install", formula_name, "--HEAD", "HOMEBREW_DOWNLOAD_CONCURRENCY" => "1" } |
| 116 | + .to output(/#{Regexp.escape(testball1_prefix)}/o).to_stdout |
| 117 | + .and output(/Cloning into/).to_stderr |
| 118 | + .and be_a_success |
| 119 | + expect(testball1_prefix/"foo/test").not_to be_a_file |
| 120 | + expect(testball1_prefix/"bin/something.bin").to be_a_file |
| 121 | + end |
102 | 122 | end |
103 | 123 | end |
0 commit comments