Port Homebrew::DevCmd::Test

This commit is contained in:
Douglas Eichelberger 2024-03-21 21:52:32 -07:00
parent e0519d736a
commit 827e943803
3 changed files with 102 additions and 100 deletions

View File

@ -1,17 +1,16 @@
# typed: true
# frozen_string_literal: true
require "abstract_command"
require "extend/ENV"
require "sandbox"
require "timeout"
require "cli/parser"
module Homebrew
module_function
sig { returns(CLI::Parser) }
def test_args
Homebrew::CLI::Parser.new do
module DevCmd
class Test < AbstractCommand
cmd_args do
description <<~EOS
Run the test method provided by an installed formula.
There is no standard output or return code, but generally it should notify the
@ -30,11 +29,9 @@ module Homebrew
named_args :installed_formula, min: 1, without_api: true
end
end
def test
args = test_args.parse
sig { override.void }
def run
Homebrew.install_bundler_gems!(groups: ["formula_test"], setup_path: false)
require "formula_assertions"
@ -111,6 +108,8 @@ module Homebrew
end
end
private
def retry_test?(formula, args:)
@test_failed ||= Set.new
if args.retry? && @test_failed.add?(formula)
@ -124,3 +123,5 @@ module Homebrew
end
end
end
end
end

View File

@ -18,7 +18,7 @@ require "dev-cmd/test"
TEST_TIMEOUT_SECONDS = 5 * 60
begin
args = Homebrew.test_args.parse
args = Homebrew::DevCmd::Test.new.args
Context.current = args.context
error_pipe = UNIXSocket.open(ENV.fetch("HOMEBREW_ERROR_PIPE"), &:recv_io)

View File

@ -1,8 +1,9 @@
# frozen_string_literal: true
require "cmd/shared_examples/args_parse"
require "dev-cmd/test"
RSpec.describe "brew test" do
RSpec.describe Homebrew::DevCmd::Test do
it_behaves_like "parseable arguments"
it "tests a given Formula", :integration_test do