diff options
| author | Jack Nagel | 2012-11-01 14:40:59 -0500 |
|---|---|---|
| committer | Jack Nagel | 2013-01-06 21:22:31 -0600 |
| commit | 1c99c685944a4f607697213f7ace25f386e420f6 (patch) | |
| tree | 396024f2f8178764e0bb5295c663ec6367269e18 /Library | |
| parent | 896f53d78bfdec504ffb11a6a5206179cb62caa1 (diff) | |
| download | brew-1c99c685944a4f607697213f7ace25f386e420f6.tar.bz2 | |
Allow tests to be specified in the DSL
Tests can now be specified as a block in the DSL. A temporary test
directory is set up automatically when calling Formula#test. The
semantics of the test remain the same: the block can either raise an
exception or return false to signal failure.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/formula.rb | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 3d3c23ec3..a150800ba 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -15,9 +15,9 @@ class Formula attr_reader :name, :path, :homepage, :downloader attr_reader :stable, :bottle, :devel, :head, :active_spec - # The build folder, usually in /tmp. - # Will only be non-nil during the stage method. - attr_reader :buildpath + # The current working directory during builds and tests. + # Will only be non-nil inside #stage and #test. + attr_reader :buildpath, :testpath # Homebrew determines the name def initialize name='__UNKNOWN__', path=nil @@ -586,6 +586,16 @@ public @active_spec.verify_download_integrity(fn) end + def test + ret = nil + mktemp do + @testpath = Pathname.pwd + ret = instance_eval(&self.class.test) + @testpath = nil + end + ret + end + private def stage @@ -777,6 +787,11 @@ private CompilerFailure.new(compiler) end end + + def test &block + return @test unless block_given? + @test = block + end end end |
