mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
removing longer tests and putting back integration_test.rb
This commit is contained in:
parent
971a8b40e6
commit
fc18956eeb
@ -95,46 +95,4 @@ RSpec.describe Homebrew::Cmd::InstallCmd do
|
|||||||
|
|
||||||
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 "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
|
end
|
||||||
|
@ -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.1").to be_a_directory
|
||||||
expect(HOMEBREW_CELLAR/"testball/0.0.1").not_to exist
|
expect(HOMEBREW_CELLAR/"testball/0.0.1").not_to exist
|
||||||
end
|
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
|
end
|
||||||
|
@ -131,57 +131,34 @@ RSpec.shared_context "integration test" do # rubocop:disable RSpec/ContextWordin
|
|||||||
end
|
end
|
||||||
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)
|
bottle_block: nil, tab_attributes: nil)
|
||||||
case name
|
case name
|
||||||
when /^testball/
|
when /^testball/
|
||||||
name_to_prog = {
|
# Use a different tarball for testball2 to avoid lock errors when writing concurrency tests
|
||||||
"testball4" => "testball4",
|
prefix = (name == "testball2") ? "testball2" : "testball"
|
||||||
"testball5" => "testball5",
|
tarball = if OS.linux?
|
||||||
"testball-build" => "testball-build",
|
TEST_FIXTURE_DIR/"tarballs/testball-0.1-linux.tbz"
|
||||||
"testball-parent" => "testball-parent",
|
TEST_FIXTURE_DIR/"tarballs/#{prefix}-0.1-linux.tbz"
|
||||||
"testball-parent-parent" => "testball-parent-parent",
|
else
|
||||||
"testball2" => "test",
|
TEST_FIXTURE_DIR/"tarballs/testball-0.1.tbz"
|
||||||
}
|
TEST_FIXTURE_DIR/"tarballs/#{prefix}-0.1.tbz"
|
||||||
|
end
|
||||||
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}"
|
|
||||||
|
|
||||||
content = <<~RUBY
|
content = <<~RUBY
|
||||||
desc "Some test"
|
desc "Some test"
|
||||||
homepage "https://brew.sh/#{name}"
|
homepage "https://brew.sh/#{name}"
|
||||||
url "file://#{tarball}"
|
url "file://#{tarball}"
|
||||||
#{ unless testball_bottle
|
sha256 "#{tarball.sha256}"
|
||||||
<<~SHA_BLOCK
|
|
||||||
sha256 "#{tarball.sha256}"
|
|
||||||
SHA_BLOCK
|
|
||||||
end }
|
|
||||||
option "with-foo", "Build with foo"
|
option "with-foo", "Build with foo"
|
||||||
#{ if testball_bottle
|
#{bottle_block}
|
||||||
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}
|
|
||||||
def install
|
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["*"]
|
prefix.install Dir["*"]
|
||||||
(buildpath/"#{program_name}.c").write \
|
(buildpath/"test.c").write \
|
||||||
"#include <stdio.h>\\nint main(){printf(\\"#{program_name}\\");return 0;}"
|
"#include <stdio.h>\\nint main(){printf(\\"test\\");return 0;}"
|
||||||
bin.mkpath
|
bin.mkpath
|
||||||
system ENV.cc, "#{program_name}.c", "-o", bin/"#{program_name}"
|
system ENV.cc, "test.c", "-o", bin/"test"
|
||||||
end
|
end
|
||||||
|
|
||||||
#{content}
|
#{content}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user