checking other tests functions

This commit is contained in:
thibhero 2025-03-05 23:57:58 -05:00
parent 0f919e8397
commit 885b7c6f4f
2 changed files with 48 additions and 78 deletions

View File

@ -86,45 +86,45 @@ RSpec.describe Homebrew::Cmd::InstallCmd do
expect(HOMEBREW_CACHE/"Sources/testball1").to be_a_directory expect(HOMEBREW_CACHE/"Sources/testball1").to be_a_directory
end end
it "installs with asking for user prompts without installed dependent checks", :integration_test do # it "installs with asking for user prompts without installed dependent checks", :integration_test do
setup_test_formula "testball1" # setup_test_formula "testball1"
#
expect { # expect {
brew "install", "--ask", "testball1" # brew "install", "--ask", "testball1"
}.to output(/.*Formula\s*\(1\):\s*testball1.*/ # }.to output(/.*Formula\s*\(1\):\s*testball1.*/
).to_stdout.and not_to_output.to_stderr # ).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 # it "installs with asking for user prompts with installed dependent checks", :integration_test do
setup_test_formula "testball1", <<~RUBY # setup_test_formula "testball1", <<~RUBY
depends_on "testball3" # 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 "build" => :build
depends_on "installed" # depends_on "installed"
RUBY # RUBY
setup_test_formula "installed" # setup_test_formula "installed"
setup_test_formula "testball3", <<~RUBY # setup_test_formula "testball5", <<~RUBY
depends_on "testball4" # depends_on "testball4"
RUBY # RUBY
setup_test_formula "testball4", <<~RUBY # setup_test_formula "testball4", <<~RUBY
RUBY # RUBY
setup_test_formula "hiop" # setup_test_formula "hiop"
setup_test_formula "build" # setup_test_formula "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"
keg_dir.mkpath # keg_dir.mkpath
touch keg_dir/AbstractTab::FILENAME # touch keg_dir/AbstractTab::FILENAME
#
expect { # expect {
brew "install", "--ask", "testball1" # brew "install", "--ask", "testball1"
}.to output(/.*Formulae\s*\(3\):\s*testball1\s*,?\s*testball3\s*,?\s*testball4.*/ # }.to output(/.*Formulae\s*\(3\):\s*testball1\s*,?\s*testball5\s*,?\s*testball4.*/
).to_stdout.and not_to_output.to_stderr # ).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
expect(HOMEBREW_CELLAR/"testball4/0.1/bin/testball4").to be_a_file # expect(HOMEBREW_CELLAR/"testball4/0.1/bin/testball4").to be_a_file
expect(HOMEBREW_CELLAR/"testball3/0.1/bin/testball3").to be_a_file # expect(HOMEBREW_CELLAR/"testball5/0.1/bin/testball5").to be_a_file
end # end
end end

View File

@ -135,43 +135,14 @@ RSpec.shared_context "integration test" do # rubocop:disable RSpec/ContextWordin
case name case name
when /^testball/ when /^testball/
# Use a different tarball for testball2 to avoid lock errors when writing concurrency tests # Use a different tarball for testball2 to avoid lock errors when writing concurrency tests
if name == "testball3" || name == "testball4" prefix = (name == "testball2") ? "testball2" : "testball"
tarball = if OS.linux? tarball = if OS.linux?
TEST_FIXTURE_DIR/"tarballs/#{name}-0.1-linux.tbz" TEST_FIXTURE_DIR/"tarballs/#{prefix}-0.1-linux.tbz"
else else
TEST_FIXTURE_DIR/"tarballs/#{name}-0.1.tbz" TEST_FIXTURE_DIR/"tarballs/#{prefix}-0.1.tbz"
end end
content = <<~RUBY
desc "Some test"
homepage "https://brew.sh/#{name}"
url "file://#{tarball}"
sha256 "#{tarball.sha256}"
option "with-foo", "Build with foo" content = <<~RUBY
#{bottle_block}
def install
STDERR.puts prefix
(prefix/"foo"/"#{name}").write("#{name}") if build.with? "foo"
prefix.install Dir["*"]
(buildpath/"#{name}.c").write \
"#include <stdio.h>\\nint main(){printf(\\"#{name}\\");return 0;}"
bin.mkpath
system ENV.cc, "#{name}.c", "-o", bin/"#{name}"
end
#{content}
# something here
RUBY
else
prefix = (name == "testball2") ? "testball2" : "testball"
tarball = if OS.linux?
TEST_FIXTURE_DIR/"tarballs/#{prefix}-0.1-linux.tbz"
else
TEST_FIXTURE_DIR/"tarballs/#{prefix}-0.1.tbz"
end
content = <<~RUBY
desc "Some test" desc "Some test"
homepage "https://brew.sh/#{name}" homepage "https://brew.sh/#{name}"
url "file://#{tarball}" url "file://#{tarball}"
@ -192,7 +163,6 @@ RSpec.shared_context "integration test" do # rubocop:disable RSpec/ContextWordin
# something here # something here
RUBY RUBY
end
when "bar" when "bar"
content = <<~RUBY content = <<~RUBY
url "https://brew.sh/#{name}-1.0" url "https://brew.sh/#{name}-1.0"