|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +require "test_bot" |
| 4 | + |
| 5 | +RSpec.describe Homebrew::TestBot::Formulae do |
| 6 | + describe "#testing_portable_ruby?" do |
| 7 | + it "returns false (not nil) when tap is nil" do |
| 8 | + # Regression test: without `!!`, tap&.core_tap? returns nil when tap is nil, |
| 9 | + # and `nil && ...` evaluates to nil, violating the T::Boolean return type. |
| 10 | + Dir.mktmpdir do |tmpdir| |
| 11 | + output_paths = { |
| 12 | + bottle: Pathname.new("#{tmpdir}/bottle.txt"), |
| 13 | + linkage: Pathname.new("#{tmpdir}/linkage.txt"), |
| 14 | + skipped_or_failed_formulae: Pathname.new("#{tmpdir}/skipped.txt"), |
| 15 | + } |
| 16 | + formulae = described_class.new( |
| 17 | + tap: nil, git: "git", dry_run: true, fail_fast: false, verbose: false, |
| 18 | + output_paths: |
| 19 | + ) |
| 20 | + |
| 21 | + result = formulae.send(:testing_portable_ruby?) |
| 22 | + expect(result).to be(false) |
| 23 | + end |
| 24 | + end |
| 25 | + end |
| 26 | + |
| 27 | + describe "#verify_local_bottles" do |
| 28 | + it "returns false (not nil) when testing portable ruby" do |
| 29 | + # Regression test: the early return for portable ruby must be `return false`, |
| 30 | + # not bare `return` (which returns nil), to satisfy the T::Boolean return type. |
| 31 | + Dir.mktmpdir do |tmpdir| |
| 32 | + output_paths = { |
| 33 | + bottle: Pathname.new("#{tmpdir}/bottle.txt"), |
| 34 | + linkage: Pathname.new("#{tmpdir}/linkage.txt"), |
| 35 | + skipped_or_failed_formulae: Pathname.new("#{tmpdir}/skipped.txt"), |
| 36 | + } |
| 37 | + formulae = described_class.new( |
| 38 | + tap: CoreTap.instance, git: "git", dry_run: true, fail_fast: false, verbose: false, |
| 39 | + output_paths: |
| 40 | + ) |
| 41 | + formulae.testing_formulae = ["portable-ruby"] |
| 42 | + |
| 43 | + result = formulae.send(:verify_local_bottles) |
| 44 | + expect(result).to be(false) |
| 45 | + end |
| 46 | + end |
| 47 | + end |
| 48 | +end |
0 commit comments