From eadf17881d4210a593aaad3db4ea793c13ca66e6 Mon Sep 17 00:00:00 2001 From: Gautham Goli Date: Thu, 9 Jan 2020 21:26:42 +0530 Subject: [PATCH 1/3] Homebrew/test.rb: Reuse `test_args` method --- Library/Homebrew/dev-cmd/test.rb | 40 +++++++++++++++++--------------- Library/Homebrew/test.rb | 13 +++-------- 2 files changed, 24 insertions(+), 29 deletions(-) diff --git a/Library/Homebrew/dev-cmd/test.rb b/Library/Homebrew/dev-cmd/test.rb index 72b912789c..413ebe88ac 100644 --- a/Library/Homebrew/dev-cmd/test.rb +++ b/Library/Homebrew/dev-cmd/test.rb @@ -8,31 +8,33 @@ require "cli/parser" module Homebrew module_function - def test_args - Homebrew::CLI::Parser.new do - usage_banner <<~EOS - `test` [] + module Test + def self.args + Homebrew::CLI::Parser.new do + usage_banner <<~EOS + `test` [] - Run the test method provided by an installed formula. - There is no standard output or return code, but generally it should notify the - user if something is wrong with the 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 + user if something is wrong with the installed formula. - *Example:* `brew install jruby && brew test jruby` - EOS - switch "--devel", - description: "Test the development version of a formula." - switch "--HEAD", - description: "Test the head version of a formula." - switch "--keep-tmp", - description: "Retain the temporary files created for the test." - switch :verbose - switch :debug - conflicts "--devel", "--HEAD" + *Example:* `brew install jruby && brew test jruby` + EOS + switch "--devel", + description: "Test the development version of a formula." + switch "--HEAD", + description: "Test the head version of a formula." + switch "--keep-tmp", + description: "Retain the temporary files created for the test." + switch :verbose + switch :debug + conflicts "--devel", "--HEAD" + end end end def test - test_args.parse + Test.args.parse raise FormulaUnspecifiedError if ARGV.named.empty? diff --git a/Library/Homebrew/test.rb b/Library/Homebrew/test.rb index c4b6403e86..97600c259f 100644 --- a/Library/Homebrew/test.rb +++ b/Library/Homebrew/test.rb @@ -9,20 +9,13 @@ require "debrew" require "formula_assertions" require "fcntl" require "socket" -require "cli/parser" - -def test_args - Homebrew::CLI::Parser.new do - switch :force - switch :verbose - switch :debug - end -end +require "dev-cmd/test" TEST_TIMEOUT_SECONDS = 5 * 60 begin - test_args.parse + Homebrew::Test.args.parse + error_pipe = UNIXSocket.open(ENV["HOMEBREW_ERROR_PIPE"], &:recv_io) error_pipe.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) From a15ce054c8665578932513b54169ca49fb45e9e4 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 13 Jan 2020 14:56:59 +0000 Subject: [PATCH 2/3] test: revert renaming test_args method. --- Library/Homebrew/dev-cmd/test.rb | 40 +++++++++++++++----------------- Library/Homebrew/test.rb | 4 ++-- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/Library/Homebrew/dev-cmd/test.rb b/Library/Homebrew/dev-cmd/test.rb index 413ebe88ac..72b912789c 100644 --- a/Library/Homebrew/dev-cmd/test.rb +++ b/Library/Homebrew/dev-cmd/test.rb @@ -8,33 +8,31 @@ require "cli/parser" module Homebrew module_function - module Test - def self.args - Homebrew::CLI::Parser.new do - usage_banner <<~EOS - `test` [] + def test_args + Homebrew::CLI::Parser.new do + usage_banner <<~EOS + `test` [] - Run the test method provided by an installed formula. - There is no standard output or return code, but generally it should notify the - user if something is wrong with the 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 + user if something is wrong with the installed formula. - *Example:* `brew install jruby && brew test jruby` - EOS - switch "--devel", - description: "Test the development version of a formula." - switch "--HEAD", - description: "Test the head version of a formula." - switch "--keep-tmp", - description: "Retain the temporary files created for the test." - switch :verbose - switch :debug - conflicts "--devel", "--HEAD" - end + *Example:* `brew install jruby && brew test jruby` + EOS + switch "--devel", + description: "Test the development version of a formula." + switch "--HEAD", + description: "Test the head version of a formula." + switch "--keep-tmp", + description: "Retain the temporary files created for the test." + switch :verbose + switch :debug + conflicts "--devel", "--HEAD" end end def test - Test.args.parse + test_args.parse raise FormulaUnspecifiedError if ARGV.named.empty? diff --git a/Library/Homebrew/test.rb b/Library/Homebrew/test.rb index 97600c259f..095905ba67 100644 --- a/Library/Homebrew/test.rb +++ b/Library/Homebrew/test.rb @@ -9,13 +9,13 @@ require "debrew" require "formula_assertions" require "fcntl" require "socket" +require "cli/parser" require "dev-cmd/test" TEST_TIMEOUT_SECONDS = 5 * 60 begin - Homebrew::Test.args.parse - + Homebrew.test_args.parse error_pipe = UNIXSocket.open(ENV["HOMEBREW_ERROR_PIPE"], &:recv_io) error_pipe.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) From 4babdf2a0f620a8886caeec32704fe3a0e9703a4 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 13 Jan 2020 14:57:15 +0000 Subject: [PATCH 3/3] postinstall: use arguments from main command. --- Library/Homebrew/postinstall.rb | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/Library/Homebrew/postinstall.rb b/Library/Homebrew/postinstall.rb index 0eb610839d..d35e3b886c 100644 --- a/Library/Homebrew/postinstall.rb +++ b/Library/Homebrew/postinstall.rb @@ -7,17 +7,10 @@ require "debrew" require "fcntl" require "socket" require "cli/parser" - -def postinstall_args - Homebrew::CLI::Parser.new do - switch :force - switch :verbose - switch :debug - end -end +require "cmd/postinstall" begin - postinstall_args.parse + Homebrew.postinstall_args.parse error_pipe = UNIXSocket.open(ENV["HOMEBREW_ERROR_PIPE"], &:recv_io) error_pipe.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)