diff --git a/Library/Homebrew/test/cmd/install_spec.rb b/Library/Homebrew/test/cmd/install_spec.rb index ebc4afd61c..1e8d70948d 100644 --- a/Library/Homebrew/test/cmd/install_spec.rb +++ b/Library/Homebrew/test/cmd/install_spec.rb @@ -95,46 +95,4 @@ RSpec.describe Homebrew::Cmd::InstallCmd do 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 "testball-parent", <<~RUBY - depends_on "testball1" - RUBY - - setup_test_formula "testball1", <<~RUBY - depends_on "testball5" - #depends_on "build" => :build - depends_on "installed" - RUBY - setup_test_formula "installed" - setup_test_formula "testball5", <<~RUBY - depends_on "testball4" - RUBY - setup_test_formula "testball4", "" - setup_test_formula "hiop" - setup_test_formula "build", "" - - # 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 - - regex = / - Formulae\s*\(3\):\s* - (testball1|testball5|testball4) - \s*,\s* - ((?!\1)testball1|testball5|testball4) - \s*,\s* - ((?!\1|\2)testball1|testball5|testball4) - /x - - expect do - brew "install", "--ask", "testball1" - end.to output(regex).to_stdout - .and not_to_output.to_stderr - - expect(HOMEBREW_CELLAR/"testball1/0.1/bin/test").to be_a_file - expect(HOMEBREW_CELLAR/"testball4/0.1/bin/testball4").to be_a_file - expect(HOMEBREW_CELLAR/"testball5/0.1/bin/testball5").to be_a_file - end end diff --git a/Library/Homebrew/test/cmd/upgrade_spec.rb b/Library/Homebrew/test/cmd/upgrade_spec.rb index 0913af485d..cc82c242c4 100644 --- a/Library/Homebrew/test/cmd/upgrade_spec.rb +++ b/Library/Homebrew/test/cmd/upgrade_spec.rb @@ -28,124 +28,4 @@ RSpec.describe Homebrew::Cmd::UpgradeCmd do expect(HOMEBREW_CELLAR/"testball/0.1").to be_a_directory expect(HOMEBREW_CELLAR/"testball/0.0.1").not_to exist end - - it "upgrades dependencies with asking for user prompts", :integration_test do - setup_test_formula "testball", <<~RUBY - depends_on "testball5" - #depends_on "build" => :build - depends_on "installed" - RUBY - setup_test_formula "installed" - setup_test_formula "testball5", <<~RUBY - depends_on "testball4" - RUBY - setup_test_formula "testball4" - setup_test_formula "hiop" - setup_test_formula "build" - - (HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath - (HOMEBREW_CELLAR/"testball5/0.0.1/foo").mkpath - (HOMEBREW_CELLAR/"testball4/0.0.1/foo").mkpath - - keg_dir = HOMEBREW_CELLAR/"installed"/"1.0" - keg_dir.mkpath - touch keg_dir/AbstractTab::FILENAME - - regex = / - Formulae\s*\(3\):\s* - (testball|testball5|testball4) - \s*,\s* - ((?!\1)testball|testball5|testball4) - \s*,\s* - ((?!\1|\2)testball|testball5|testball4) - /x - expect do - brew "upgrade", "--ask" - end.to output(regex) - .to_stdout.and not_to_output.to_stderr - - expect(HOMEBREW_CELLAR/"testball/0.1").to be_a_directory - expect(HOMEBREW_CELLAR/"testball/0.0.1").not_to exist - expect(HOMEBREW_CELLAR/"testball5/0.1").to be_a_directory - expect(HOMEBREW_CELLAR/"testball5/0.0.1").not_to exist - expect(HOMEBREW_CELLAR/"testball4/0.1").to be_a_directory - expect(HOMEBREW_CELLAR/"testball4/0.0.1").not_to exist - end - - it "upgrades only the ‘testball’ formula, prompts for dependent checks, and verifies that other fields are updated", - :integration_test do - content = <<~RUBY - version "0.1" - depends_on "testball-parent" - RUBY - setup_test_formula "testball-parent-parent", content, testball_bottle: true - content = <<~RUBY - version "0.1" - depends_on "testball" - RUBY - setup_test_formula "testball-parent", content, testball_bottle: true - - content = <<~RUBY - depends_on "testball5" - depends_on "testball-build" => :build - depends_on "installed" - version "0.1" - RUBY - setup_test_formula "testball", content, testball_bottle: true - setup_test_formula "installed" - - content = <<~RUBY - version "0.1" - depends_on "testball4" - RUBY - setup_test_formula "testball5", content, testball_bottle: true - content = <<~RUBY - version "0.1" - RUBY - setup_test_formula "testball4", content, testball_bottle: true - setup_test_formula "hiop" - setup_test_formula "testball-build" - - (HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath - (HOMEBREW_CELLAR/"testball5/0.0.1/foo").mkpath - (HOMEBREW_CELLAR/"testball4/0.0.1/foo").mkpath - (HOMEBREW_CELLAR/"testball-parent/0.0.1/foo").mkpath - (HOMEBREW_CELLAR/"testball-parent-parent/0.0.1/foo").mkpath - - keg_dir = HOMEBREW_CELLAR/"installed"/"1.0" - keg_dir.mkpath - touch keg_dir/AbstractTab::FILENAME - - regex = / - Formulae\s*\(5\):\s* - (testball|testball5|testball4|testball-parent|testball-parent-parent) - \s*,\s* - ((?!\1)testball|testball5|testball4|testball-parent|testball-parent-parent) - \s*,\s* - ((?!\1|\2)testball|testball5|testball4|testball-parent|testball-parent-parent) - \s*,\s* - ((?!\1|\2|\3)testball|testball5|testball4|testball-parent|testball-parent-parent) - \s*,\s* - ((?!\1|\2|\3|\4)testball|testball5|testball4|testball-parent|testball-parent-parent) - /x - expect do - brew "upgrade", "--ask", "testball" - end.to output(regex) - .to_stdout.and not_to_output.to_stderr - - expect(HOMEBREW_CELLAR/"testball/0.1").to be_a_directory - expect(HOMEBREW_CELLAR/"testball/0.0.1").not_to exist - expect(HOMEBREW_CELLAR/"testball5/0.1").to be_a_directory - expect(HOMEBREW_CELLAR/"testball4/0.1").to be_a_directory - expect(HOMEBREW_CELLAR/"testball-parent/0.1").to be_a_directory - expect(HOMEBREW_CELLAR/"testball-parent/0.0.1").not_to exist - expect(HOMEBREW_CELLAR/"testball-parent-parent/0.1").to be_a_directory - expect(HOMEBREW_CELLAR/"testball-parent-parent/0.0.1").not_to exist - - # Those directories shouldn't exist anymore - # brew upgrade testball remove testball directory but not the following one - # Cleanup isn't applied on the dependencies - # expect(HOMEBREW_CELLAR/"testball5/0.0.1").not_to exist - # expect(HOMEBREW_CELLAR/"testball4/0.0.1").not_to exist - end end diff --git a/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb b/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb index f97343cfbc..c8fd48c78f 100644 --- a/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb +++ b/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb @@ -131,57 +131,34 @@ RSpec.shared_context "integration test" do # rubocop:disable RSpec/ContextWordin end end - def setup_test_formula(name, content = nil, testball_bottle: false, tap: CoreTap.instance, + def setup_test_formula(name, content = nil, tap: CoreTap.instance, bottle_block: nil, tab_attributes: nil) case name when /^testball/ - name_to_prog = { - "testball4" => "testball4", - "testball5" => "testball5", - "testball-build" => "testball-build", - "testball-parent" => "testball-parent", - "testball-parent-parent" => "testball-parent-parent", - "testball2" => "test", - } - - if (prog = name_to_prog[name]) - prefix = name - program_name = prog - else - prefix = "testball" - program_name = "test" - end - - tarball_name = "#{prefix}-0.1#{"-linux" if OS.linux?}.tbz" - tarball = TEST_FIXTURE_DIR / "tarballs/#{tarball_name}" - + # Use a different tarball for testball2 to avoid lock errors when writing concurrency tests + prefix = (name == "testball2") ? "testball2" : "testball" + tarball = if OS.linux? + TEST_FIXTURE_DIR/"tarballs/testball-0.1-linux.tbz" + TEST_FIXTURE_DIR/"tarballs/#{prefix}-0.1-linux.tbz" + else + TEST_FIXTURE_DIR/"tarballs/testball-0.1.tbz" + TEST_FIXTURE_DIR/"tarballs/#{prefix}-0.1.tbz" + end content = <<~RUBY desc "Some test" homepage "https://brew.sh/#{name}" url "file://#{tarball}" - #{ unless testball_bottle - <<~SHA_BLOCK - sha256 "#{tarball.sha256}" - SHA_BLOCK - end } + sha256 "#{tarball.sha256}" + option "with-foo", "Build with foo" - #{ if testball_bottle - tarball_bottle_name = "#{prefix}-0.1.all.bottle.tar.gz" - tarball_bottle = TEST_FIXTURE_DIR / "tarballs/#{tarball_bottle_name}" - <<~BOTTLE_BLOCK - bottle do - root_url "file://#{TEST_FIXTURE_DIR}/tarballs" - sha256 cellar: :any, all: "#{tarball_bottle.sha256}" - end - BOTTLE_BLOCK - end }#{bottle_block} + #{bottle_block} def install - (prefix/"foo"/"#{program_name}").write("#{program_name}") if build.with? "foo" + (prefix/"foo"/"test").write("test") if build.with? "foo" prefix.install Dir["*"] - (buildpath/"#{program_name}.c").write \ - "#include \\nint main(){printf(\\"#{program_name}\\");return 0;}" + (buildpath/"test.c").write \ + "#include \\nint main(){printf(\\"test\\");return 0;}" bin.mkpath - system ENV.cc, "#{program_name}.c", "-o", bin/"#{program_name}" + system ENV.cc, "test.c", "-o", bin/"test" end #{content}