making tests more robust with bottles to verify the whole hierarchy oh dependencies and dependants is upgraded as expected
This commit is contained in:
parent
3f1341eb6a
commit
19134b3005
@ -97,10 +97,13 @@ RSpec.describe Homebrew::Cmd::InstallCmd do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "installs with asking for user prompts with installed dependent checks", :integration_test do
|
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
|
setup_test_formula "testball1", <<~RUBY
|
||||||
depends_on "testball5"
|
depends_on "testball5"
|
||||||
# should work as its not building but test doesnt pass if dependant
|
depends_on "testball-build" => :build
|
||||||
# depends_on "build" => :build
|
|
||||||
depends_on "installed"
|
depends_on "installed"
|
||||||
RUBY
|
RUBY
|
||||||
setup_test_formula "installed"
|
setup_test_formula "installed"
|
||||||
@ -109,7 +112,7 @@ RSpec.describe Homebrew::Cmd::InstallCmd do
|
|||||||
RUBY
|
RUBY
|
||||||
setup_test_formula "testball4", ""
|
setup_test_formula "testball4", ""
|
||||||
setup_test_formula "hiop"
|
setup_test_formula "hiop"
|
||||||
setup_test_formula "build"
|
setup_test_formula "testball-build", ""
|
||||||
|
|
||||||
# Mock `Formula#any_version_installed?` by creating the tab in a plausible keg directory
|
# Mock `Formula#any_version_installed?` by creating the tab in a plausible keg directory
|
||||||
keg_dir = HOMEBREW_CELLAR/"installed"/"1.0"
|
keg_dir = HOMEBREW_CELLAR/"installed"/"1.0"
|
||||||
|
|||||||
@ -29,11 +29,11 @@ RSpec.describe Homebrew::Cmd::UpgradeCmd do
|
|||||||
expect(HOMEBREW_CELLAR/"testball/0.0.1").not_to exist
|
expect(HOMEBREW_CELLAR/"testball/0.0.1").not_to exist
|
||||||
end
|
end
|
||||||
|
|
||||||
it "upgrades with asking for user prompts with dependants checks", :integration_test do
|
it "upgrades dependencies with asking for user prompts", :integration_test do
|
||||||
setup_test_formula "testball", <<~RUBY
|
setup_test_formula "testball", <<~RUBY
|
||||||
depends_on "testball5"
|
depends_on "testball5"
|
||||||
# should work as its not building but test doesnt pass if dependant
|
# should work as its not building but test doesnt pass if dependant
|
||||||
# depends_on "build" => :build
|
depends_on "testball-build" => :build
|
||||||
depends_on "installed"
|
depends_on "installed"
|
||||||
RUBY
|
RUBY
|
||||||
setup_test_formula "installed"
|
setup_test_formula "installed"
|
||||||
@ -42,7 +42,7 @@ RSpec.describe Homebrew::Cmd::UpgradeCmd do
|
|||||||
RUBY
|
RUBY
|
||||||
setup_test_formula "testball4"
|
setup_test_formula "testball4"
|
||||||
setup_test_formula "hiop"
|
setup_test_formula "hiop"
|
||||||
setup_test_formula "build"
|
setup_test_formula "testball-build"
|
||||||
|
|
||||||
(HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath
|
(HOMEBREW_CELLAR/"testball/0.0.1/foo").mkpath
|
||||||
(HOMEBREW_CELLAR/"testball5/0.0.1/foo").mkpath
|
(HOMEBREW_CELLAR/"testball5/0.0.1/foo").mkpath
|
||||||
@ -72,4 +72,82 @@ RSpec.describe Homebrew::Cmd::UpgradeCmd do
|
|||||||
expect(HOMEBREW_CELLAR/"testball4/0.1").to be_a_directory
|
expect(HOMEBREW_CELLAR/"testball4/0.1").to be_a_directory
|
||||||
expect(HOMEBREW_CELLAR/"testball4/0.0.1").not_to exist
|
expect(HOMEBREW_CELLAR/"testball4/0.0.1").not_to exist
|
||||||
end
|
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"
|
||||||
|
# should work as its not building but test doesnt pass if dependant
|
||||||
|
# depends_on "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 "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
|
||||||
|
|||||||
@ -130,33 +130,50 @@ RSpec.shared_context "integration test" do # rubocop:disable RSpec/ContextWordin
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def setup_test_formula(name, content = nil, tap: CoreTap.instance,
|
def setup_test_formula(name, content = nil, testball_bottle: false, tap: CoreTap.instance,
|
||||||
bottle_block: nil, tab_attributes: nil)
|
bottle_block: nil, tab_attributes: nil)
|
||||||
case name
|
case name
|
||||||
when /^testball/
|
when /^testball/
|
||||||
case name
|
name_to_prog = {
|
||||||
when "testball4", "testball5"
|
"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
|
prefix = name
|
||||||
program_name = name
|
program_name = prog
|
||||||
when "testball2"
|
|
||||||
prefix = name
|
|
||||||
program_name = "test"
|
|
||||||
else
|
else
|
||||||
prefix = "testball"
|
prefix = "testball"
|
||||||
program_name = "test"
|
program_name = "test"
|
||||||
end
|
end
|
||||||
|
|
||||||
tarball_name = "#{prefix}-0.1#{"-linux" if OS.linux?}.tbz"
|
tarball_name = "#{prefix}-0.1.tbz"
|
||||||
tarball = TEST_FIXTURE_DIR / "tarballs/#{tarball_name}"
|
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
|
||||||
|
<<~SHA_BLOCK
|
||||||
sha256 "#{tarball.sha256}"
|
sha256 "#{tarball.sha256}"
|
||||||
|
SHA_BLOCK
|
||||||
|
end }
|
||||||
option "with-foo", "Build with foo"
|
option "with-foo", "Build with foo"
|
||||||
#{bottle_block}
|
#{ 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}
|
||||||
def install
|
def install
|
||||||
(prefix/"foo"/"#{program_name}").write("#{program_name}") if build.with? "foo"
|
(prefix/"foo"/"#{program_name}").write("#{program_name}") if build.with? "foo"
|
||||||
prefix.install Dir["*"]
|
prefix.install Dir["*"]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user