From 665fbc382d22be139d83355b55a835d611e35255 Mon Sep 17 00:00:00 2001 From: thibhero Date: Wed, 5 Mar 2025 17:38:55 -0500 Subject: [PATCH] second test for install with dependencies --- Library/Homebrew/test/cmd/install_spec.rb | 47 ++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/test/cmd/install_spec.rb b/Library/Homebrew/test/cmd/install_spec.rb index 11eb405c78..e9744e71d2 100644 --- a/Library/Homebrew/test/cmd/install_spec.rb +++ b/Library/Homebrew/test/cmd/install_spec.rb @@ -4,6 +4,7 @@ require "cmd/install" require "cmd/shared_examples/args_parse" RSpec.describe Homebrew::Cmd::InstallCmd do + include FileUtils it_behaves_like "parseable arguments" it "installs formulae", :integration_test do @@ -90,9 +91,53 @@ RSpec.describe Homebrew::Cmd::InstallCmd do expect { 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 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