Tests for hw.model and brew.h.rb
This commit is contained in:
parent
74f2dd7d38
commit
f6743bbfd7
@ -3,12 +3,15 @@
|
|||||||
# support, and with no warranty, express or implied, as to its usefulness for
|
# support, and with no warranty, express or implied, as to its usefulness for
|
||||||
# any purpose.
|
# any purpose.
|
||||||
|
|
||||||
$:.unshift File.dirname(__FILE__)
|
ABS__FILE__=File.expand_path(__FILE__)
|
||||||
|
|
||||||
|
$:.unshift File.dirname(ABS__FILE__)
|
||||||
require 'pathname+yeast'
|
require 'pathname+yeast'
|
||||||
require 'formula'
|
require 'formula'
|
||||||
require 'download_strategy'
|
require 'download_strategy'
|
||||||
require 'keg'
|
require 'keg'
|
||||||
require 'utils'
|
require 'utils'
|
||||||
|
require 'brew.h'
|
||||||
|
|
||||||
# these are defined in bin/brew, but we don't want to break our actual
|
# these are defined in bin/brew, but we don't want to break our actual
|
||||||
# homebrew tree, and we do want to test everything :)
|
# homebrew tree, and we do want to test everything :)
|
||||||
@ -17,9 +20,10 @@ HOMEBREW_CACHE=HOMEBREW_PREFIX.parent+"cache"
|
|||||||
HOMEBREW_CELLAR=HOMEBREW_PREFIX.parent+"cellar"
|
HOMEBREW_CELLAR=HOMEBREW_PREFIX.parent+"cellar"
|
||||||
HOMEBREW_USER_AGENT="Homebrew"
|
HOMEBREW_USER_AGENT="Homebrew"
|
||||||
|
|
||||||
HOMEBREW_CELLAR.mkpath
|
(HOMEBREW_PREFIX+'Library'+'Formula').mkpath
|
||||||
raise "HOMEBREW_CELLAR couldn't be created!" unless HOMEBREW_CELLAR.directory?
|
Dir.chdir HOMEBREW_PREFIX
|
||||||
at_exit { HOMEBREW_PREFIX.parent.rmtree }
|
at_exit { HOMEBREW_PREFIX.parent.rmtree }
|
||||||
|
|
||||||
require 'test/unit' # must be after at_exit
|
require 'test/unit' # must be after at_exit
|
||||||
require 'ARGV+yeast' # needs to be after test/unit to avoid conflict with OptionsParser
|
require 'ARGV+yeast' # needs to be after test/unit to avoid conflict with OptionsParser
|
||||||
|
|
||||||
@ -37,7 +41,7 @@ end
|
|||||||
|
|
||||||
class TestBall <Formula
|
class TestBall <Formula
|
||||||
def initialize
|
def initialize
|
||||||
@url="file:///#{Pathname.new(__FILE__).parent.realpath}/testball-0.1.tbz"
|
@url="file:///#{Pathname.new(ABS__FILE__).parent.realpath}/testball-0.1.tbz"
|
||||||
super "testball"
|
super "testball"
|
||||||
end
|
end
|
||||||
def install
|
def install
|
||||||
@ -49,7 +53,7 @@ end
|
|||||||
class TestZip <Formula
|
class TestZip <Formula
|
||||||
def initialize
|
def initialize
|
||||||
zip=HOMEBREW_CACHE.parent+'test-0.1.zip'
|
zip=HOMEBREW_CACHE.parent+'test-0.1.zip'
|
||||||
Kernel.system 'zip', '-0', zip, __FILE__
|
Kernel.system 'zip', '-0', zip, ABS__FILE__
|
||||||
@url="file://#{zip}"
|
@url="file://#{zip}"
|
||||||
super 'testzip'
|
super 'testzip'
|
||||||
end
|
end
|
||||||
@ -76,7 +80,7 @@ class TestBallOverrideBrew <Formula
|
|||||||
end
|
end
|
||||||
|
|
||||||
class TestScriptFileFormula <ScriptFileFormula
|
class TestScriptFileFormula <ScriptFileFormula
|
||||||
@url="file:///#{Pathname.new(__FILE__).realpath}"
|
@url="file:///#{Pathname.new(ABS__FILE__).realpath}"
|
||||||
@version="1"
|
@version="1"
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@ -327,4 +331,24 @@ class BeerTasting <Test::Unit::TestCase
|
|||||||
f=MockFormula.new 'ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p243.tar.gz'
|
f=MockFormula.new 'ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p243.tar.gz'
|
||||||
assert_equal '1.9.1-p243', f.version
|
assert_equal '1.9.1-p243', f.version
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_hw_model
|
||||||
|
require 'hw.model.rb'
|
||||||
|
# this will raise if we don't recognise your mac, but that prolly
|
||||||
|
# indicates something went wrong rather than we don't know
|
||||||
|
assert %w[core1 core2 xeon ppc].include?(hw_model.to_s)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_brew_h
|
||||||
|
nostdout do
|
||||||
|
assert_nothing_raised do
|
||||||
|
f=TestBall.new
|
||||||
|
make 'http://example.com/testball-0.1.tbz'
|
||||||
|
info f.name
|
||||||
|
clean f
|
||||||
|
prune
|
||||||
|
#TODO test diy function too
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user