Homebrew/test.rb: Reuse test_args method

This commit is contained in:
Gautham Goli 2020-01-09 21:26:42 +05:30 committed by Mike McQuaid
parent 1640d96855
commit eadf17881d
No known key found for this signature in database
GPG Key ID: 48A898132FD8EE70
2 changed files with 24 additions and 29 deletions

View File

@ -8,31 +8,33 @@ require "cli/parser"
module Homebrew module Homebrew
module_function module_function
def test_args module Test
Homebrew::CLI::Parser.new do def self.args
usage_banner <<~EOS Homebrew::CLI::Parser.new do
`test` [<options>] <formula> usage_banner <<~EOS
`test` [<options>] <formula>
Run the test method provided by an installed formula. Run the test method provided by an installed formula.
There is no standard output or return code, but generally it should notify the There is no standard output or return code, but generally it should notify the
user if something is wrong with the installed formula. user if something is wrong with the installed formula.
*Example:* `brew install jruby && brew test jruby` *Example:* `brew install jruby && brew test jruby`
EOS EOS
switch "--devel", switch "--devel",
description: "Test the development version of a formula." description: "Test the development version of a formula."
switch "--HEAD", switch "--HEAD",
description: "Test the head version of a formula." description: "Test the head version of a formula."
switch "--keep-tmp", switch "--keep-tmp",
description: "Retain the temporary files created for the test." description: "Retain the temporary files created for the test."
switch :verbose switch :verbose
switch :debug switch :debug
conflicts "--devel", "--HEAD" conflicts "--devel", "--HEAD"
end
end end
end end
def test def test
test_args.parse Test.args.parse
raise FormulaUnspecifiedError if ARGV.named.empty? raise FormulaUnspecifiedError if ARGV.named.empty?

View File

@ -9,20 +9,13 @@ require "debrew"
require "formula_assertions" require "formula_assertions"
require "fcntl" require "fcntl"
require "socket" require "socket"
require "cli/parser" require "dev-cmd/test"
def test_args
Homebrew::CLI::Parser.new do
switch :force
switch :verbose
switch :debug
end
end
TEST_TIMEOUT_SECONDS = 5 * 60 TEST_TIMEOUT_SECONDS = 5 * 60
begin begin
test_args.parse Homebrew::Test.args.parse
error_pipe = UNIXSocket.open(ENV["HOMEBREW_ERROR_PIPE"], &:recv_io) error_pipe = UNIXSocket.open(ENV["HOMEBREW_ERROR_PIPE"], &:recv_io)
error_pipe.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) error_pipe.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)