second test for install with dependencies

This commit is contained in:
thibhero 2025-03-05 17:38:55 -05:00
parent 0b53e54bfa
commit 665fbc382d

View File

@ -4,6 +4,7 @@ require "cmd/install"
require "cmd/shared_examples/args_parse" require "cmd/shared_examples/args_parse"
RSpec.describe Homebrew::Cmd::InstallCmd do RSpec.describe Homebrew::Cmd::InstallCmd do
include FileUtils
it_behaves_like "parseable arguments" it_behaves_like "parseable arguments"
it "installs formulae", :integration_test do it "installs formulae", :integration_test do
@ -90,9 +91,53 @@ RSpec.describe Homebrew::Cmd::InstallCmd do
expect { expect {
brew "install", "--ask", "testball1" brew "install", "--ask", "testball1"
}.to output(/Formulae:\s*testball1/).to_stdout.and not_to_output.to_stderr }.to output(/.*Formula\s*\(1\):\s*testball1.*/
).to_stdout.and not_to_output.to_stderr
expect(HOMEBREW_CELLAR/"testball1/0.1/bin/test").to be_a_file expect(HOMEBREW_CELLAR/"testball1/0.1/bin/test").to be_a_file
end end
it "installs with asking for user prompts with installed dependent checks", :integration_test do
setup_test_formula "testball1", <<~RUBY
url "https://brew.sh/testball1-1.0"
depends_on "testball3"
depends_on "build" => :build
depends_on "installed"
RUBY
setup_test_formula "installed"
setup_test_formula "testball3", <<~RUBY
url "https://brew.sh/testball3-1.0"
depends_on "testball4"
RUBY
setup_test_formula "testball4", <<~RUBY
url "https://brew.sh/testball4-1.0"
RUBY
setup_test_formula "hiop"
setup_test_formula "build"
expect {
brew "info", "testball1"
}.to be_a_failure
expect {
brew "info", "testball4"
}.to be_a_failure
# Mock `Formula#any_version_installed?` by creating the tab in a plausible keg directory
keg_dir = HOMEBREW_CELLAR/"installed"/"1.0"
keg_dir.mkpath
touch keg_dir/AbstractTab::FILENAME
#
# expect { brew "deps", "baz", "--include-test", "--missing", "--skip-recommended" }
# .to be_a_success
# .and output("bar\nfoo\ntest\n").to_stdout
# .and not_to_output.to_stderr
expect {
brew "install", "--ask", "testball1"
}.to output(/.*Formula\s*\(3\):\s*testball1\s*,?\s*testball3\s*,?\s*testball4.*/
).to_stdout.and not_to_output.to_stderr
expect(HOMEBREW_CELLAR/"testball1/0.1/bin/test").to be_a_file
end
end end