Merge pull request #20079 from Homebrew/fix-tests-only-files

Filter `brew tests` spec files appropriately for each OS
This commit is contained in:
Rylan Polster 2025-06-12 00:15:21 +00:00 committed by GitHub
commit 5831783a85
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 36 additions and 15 deletions

View File

@ -4,6 +4,7 @@
require "formula_installer"
require "unpack_strategy"
require "utils/topological_hash"
require "utils/analytics"
require "cask/config"
require "cask/download"

View File

@ -127,8 +127,8 @@ module Homebrew
bundle_args << "--tag" << "~needs_network" unless args.online?
bundle_args << "--tag" << "~needs_ci" unless ENV["CI"]
bundle_args = os_bundle_args(bundle_args)
files = os_files(files)
bundle_args = os_bundle_args(bundle_args, generic: args.generic?)
files = os_files(files, generic: args.generic?)
puts "Randomized with seed #{seed}"
@ -156,11 +156,12 @@ module Homebrew
private
sig { params(bundle_args: T::Array[String]).returns(T::Array[String]) }
def os_bundle_args(bundle_args)
sig { params(bundle_args: T::Array[String], generic: T::Boolean).returns(T::Array[String]) }
def os_bundle_args(bundle_args, generic:)
# for generic tests, remove macOS or Linux specific tests
non_linux_bundle_args(non_macos_bundle_args(bundle_args))
end
alias generic_os_bundle_args os_bundle_args
sig { params(bundle_args: T::Array[String]).returns(T::Array[String]) }
def non_macos_bundle_args(bundle_args)
@ -175,11 +176,12 @@ module Homebrew
bundle_args << "--tag" << "~needs_linux" << "--tag" << "~needs_systemd"
end
sig { params(files: T::Array[String]).returns(T::Array[String]) }
def os_files(files)
sig { params(files: T::Array[String], generic: T::Boolean).returns(T::Array[String]) }
def os_files(files, generic:)
# for generic tests, remove macOS or Linux specific files
non_linux_files(non_macos_files(files))
end
alias generic_os_files os_files
sig { params(files: T::Array[String]).returns(T::Array[String]) }
def non_macos_files(files)

View File

@ -11,10 +11,19 @@ module OS
private
sig { params(bundle_args: T::Array[String]).returns(T::Array[String]) }
def os_bundle_args(bundle_args)
sig { params(bundle_args: T::Array[String], generic: T::Boolean).returns(T::Array[String]) }
def os_bundle_args(bundle_args, generic:)
return generic_os_bundle_args(bundle_args, generic:) if generic
non_macos_bundle_args(bundle_args)
end
sig { params(files: T::Array[String], generic: T::Boolean).returns(T::Array[String]) }
def os_files(files, generic:)
return generic_os_files(files, generic:) if generic
non_macos_files(files)
end
end
end
end

View File

@ -11,10 +11,19 @@ module OS
private
sig { params(bundle_args: T::Array[String]).returns(T::Array[String]) }
def os_bundle_args(bundle_args)
sig { params(bundle_args: T::Array[String], generic: T::Boolean).returns(T::Array[String]) }
def os_bundle_args(bundle_args, generic:)
return generic_os_bundle_args(bundle_args, generic:) if generic
non_linux_bundle_args(bundle_args)
end
sig { params(files: T::Array[String], generic: T::Boolean).returns(T::Array[String]) }
def os_files(files, generic:)
return generic_os_files(files, generic:) if generic
non_linux_files(files)
end
end
end
end

View File

@ -19,7 +19,7 @@ RSpec.describe Cask::Artifact::Artifact, :cask do
end
context "without target" do
it "fails to load" do
it "fails to load", :no_api do
expect do
Cask::CaskLoader.load("invalid-generic-artifact-no-target")
end.to raise_error(Cask::CaskInvalidError, /Generic Artifact.*requires.*target/)

View File

@ -6,7 +6,7 @@ RSpec.describe Cask::Artifact::Manpage, :cask do
context "without section" do
let(:cask_token) { "invalid-manpage-no-section" }
it "fails to load a cask without section" do
it "fails to load a cask without section", :no_api do
expect { cask }.to raise_error(Cask::CaskInvalidError, /is not a valid man page name/)
end
end

View File

@ -503,7 +503,7 @@ RSpec.describe Cask::Audit, :cask do
end
end
describe "livecheck should be skipped" do
describe "livecheck should be skipped", :no_api do
let(:only) { ["livecheck_version"] }
let(:online) { true }
let(:message) { /Version '[^']*' differs from '[^']*' retrieved by livecheck\./ }

View File

@ -24,7 +24,7 @@ RSpec.describe Cask::CaskLoader::FromTapLoader do
expect { described_class.new("foo/bar/baz").load(config: nil) }.to raise_error(Cask::CaskUnavailableError)
end
context "with sharded Cask directory" do
context "with sharded Cask directory", :no_api do
let(:cask_path) { tap.cask_dir/cask_name[0]/"#{cask_name}.rb" }
it "returns a Cask" do

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true
RSpec.describe Cask::DSL, :cask do
RSpec.describe Cask::DSL, :cask, :no_api do
let(:cask) { Cask::CaskLoader.load(token) }
let(:token) { "basic-cask" }