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>
This commit is contained in:
parent
896f53d78b
commit
1c99c68594
@ -15,9 +15,9 @@ class Formula
|
|||||||
attr_reader :name, :path, :homepage, :downloader
|
attr_reader :name, :path, :homepage, :downloader
|
||||||
attr_reader :stable, :bottle, :devel, :head, :active_spec
|
attr_reader :stable, :bottle, :devel, :head, :active_spec
|
||||||
|
|
||||||
# The build folder, usually in /tmp.
|
# The current working directory during builds and tests.
|
||||||
# Will only be non-nil during the stage method.
|
# Will only be non-nil inside #stage and #test.
|
||||||
attr_reader :buildpath
|
attr_reader :buildpath, :testpath
|
||||||
|
|
||||||
# Homebrew determines the name
|
# Homebrew determines the name
|
||||||
def initialize name='__UNKNOWN__', path=nil
|
def initialize name='__UNKNOWN__', path=nil
|
||||||
@ -586,6 +586,16 @@ public
|
|||||||
@active_spec.verify_download_integrity(fn)
|
@active_spec.verify_download_integrity(fn)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test
|
||||||
|
ret = nil
|
||||||
|
mktemp do
|
||||||
|
@testpath = Pathname.pwd
|
||||||
|
ret = instance_eval(&self.class.test)
|
||||||
|
@testpath = nil
|
||||||
|
end
|
||||||
|
ret
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def stage
|
def stage
|
||||||
@ -777,6 +787,11 @@ private
|
|||||||
CompilerFailure.new(compiler)
|
CompilerFailure.new(compiler)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test &block
|
||||||
|
return @test unless block_given?
|
||||||
|
@test = block
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user