diff --git a/Library/Contributions/manpages/brew.1.md b/Library/Contributions/manpages/brew.1.md index 38b8644098..533fbfa01e 100644 --- a/Library/Contributions/manpages/brew.1.md +++ b/Library/Contributions/manpages/brew.1.md @@ -179,8 +179,7 @@ Note that these flags should only appear after a command. several different ways. See [SPECIFYING FORMULAE][]. If `--debug` is passed and brewing fails, open an interactive debugging - session with access to IRB, ruby-debug, or a shell inside the temporary - build directory. + session with access to IRB or a shell inside the temporary build directory. If `--env=std` is passed, use the standard build environment instead of superenv. @@ -332,14 +331,17 @@ Note that these flags should only appear after a command. Ensures all tapped formula are symlinked into Library/Formula and prunes dead formula from Library/Formula. - * `test` [--devel|--HEAD] : + * `test` [--devel|--HEAD] [--debug] : A few formulae provide a test method. `brew test ` runs this test method. There is no standard output or return code, but it should generally indicate to the user if something is wrong with the installed formula. - To test the development or head version of a formula, `--devel` or - `--HEAD` must be passed., + To test the development or head version of a formula, use `--devel` or + `--HEAD`. + + If `--debug` is passed and the test fails, an interactive debugger will be + launched with access to IRB or a shell inside the temporary test directory. Example: `brew install jruby && brew test jruby` diff --git a/Library/Homebrew/cmd/test.rb b/Library/Homebrew/cmd/test.rb index b47a85ed47..6304507440 100644 --- a/Library/Homebrew/cmd/test.rb +++ b/Library/Homebrew/cmd/test.rb @@ -1,5 +1,6 @@ require "extend/ENV" require "timeout" +require "debrew" module Homebrew TEST_TIMEOUT_SECONDS = 5*60 @@ -50,11 +51,12 @@ module Homebrew f.extend(Test::Unit::Assertions) f.extend(Homebrew::Assertions) + f.extend(Debrew::Formula) if ARGV.debug? begin # tests can also return false to indicate failure Timeout::timeout TEST_TIMEOUT_SECONDS do - raise if f.test == false + raise if f.run_test == false end rescue FailedAssertion => e ofail "#{f.name}: failed" diff --git a/Library/Homebrew/debrew.rb b/Library/Homebrew/debrew.rb index fbddadbd53..f3d3dffa3d 100644 --- a/Library/Homebrew/debrew.rb +++ b/Library/Homebrew/debrew.rb @@ -21,6 +21,10 @@ module Debrew def install Debrew.debrew { super } end + + def test + Debrew.debrew { super } + end end module Resource diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 23087ada61..261d3c5a0d 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -473,21 +473,23 @@ class Formula active_spec.verify_download_integrity(fn) end - def test + def run_test self.build = Tab.for_formula(self) - ret = nil mktemp do @testpath = Pathname.pwd - ret = instance_eval(&self.class.test) - @testpath = nil + test end - ret + ensure + @testpath = nil end def test_defined? false end + def test + end + protected # Pretty titles the command and buffers stdout/stderr @@ -769,9 +771,8 @@ class Formula end def test &block - return @test unless block_given? define_method(:test_defined?) { true } - @test = block + define_method(:test, &block) end end end diff --git a/share/man/man1/brew.1 b/share/man/man1/brew.1 index e13b970132..d432311f7e 100644 --- a/share/man/man1/brew.1 +++ b/share/man/man1/brew.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "BREW" "1" "July 2014" "Homebrew" "brew" +.TH "BREW" "1" "September 2014" "Homebrew" "brew" . .SH "NAME" \fBbrew\fR \- The missing package manager for OS X @@ -197,7 +197,7 @@ Install \fIformula\fR\. \fIformula\fR is usually the name of the formula to install, but it can be specified several different ways\. See \fISPECIFYING FORMULAE\fR\. . .IP -If \fB\-\-debug\fR is passed and brewing fails, open an interactive debugging session with access to IRB, ruby\-debug, or a shell inside the temporary build directory\. +If \fB\-\-debug\fR is passed and brewing fails, open an interactive debugging session with access to IRB or a shell inside the temporary build directory\. . .IP If \fB\-\-env=std\fR is passed, use the standard build environment instead of superenv\. @@ -353,11 +353,14 @@ Tap a new formula repository from GitHub, or list existing taps\. Ensures all tapped formula are symlinked into Library/Formula and prunes dead formula from Library/Formula\. . .TP -\fBtest\fR [\-\-devel|\-\-HEAD] \fIformula\fR +\fBtest\fR [\-\-devel|\-\-HEAD] [\-\-debug] \fIformula\fR A few formulae provide a test method\. \fBbrew test \fR runs this test method\. There is no standard output or return code, but it should generally indicate to the user if something is wrong with the installed formula\. . .IP -To test the development or head version of a formula, \fB\-\-devel\fR or \fB\-\-HEAD\fR must be passed\., +To test the development or head version of a formula, use \fB\-\-devel\fR or \fB\-\-HEAD\fR\. +. +.IP +If \fB\-\-debug\fR is passed and the test fails, an interactive debugger will be launched with access to IRB or a shell inside the temporary test directory\. . .IP Example: \fBbrew install jruby && brew test jruby\fR