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
|
||||
# any purpose.
|
||||
|
||||
$:.unshift File.dirname(__FILE__)
|
||||
ABS__FILE__=File.expand_path(__FILE__)
|
||||
|
||||
$:.unshift File.dirname(ABS__FILE__)
|
||||
require 'pathname+yeast'
|
||||
require 'formula'
|
||||
require 'download_strategy'
|
||||
require 'keg'
|
||||
require 'utils'
|
||||
require 'brew.h'
|
||||
|
||||
# these are defined in bin/brew, but we don't want to break our actual
|
||||
# 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_USER_AGENT="Homebrew"
|
||||
|
||||
HOMEBREW_CELLAR.mkpath
|
||||
raise "HOMEBREW_CELLAR couldn't be created!" unless HOMEBREW_CELLAR.directory?
|
||||
(HOMEBREW_PREFIX+'Library'+'Formula').mkpath
|
||||
Dir.chdir HOMEBREW_PREFIX
|
||||
at_exit { HOMEBREW_PREFIX.parent.rmtree }
|
||||
|
||||
require 'test/unit' # must be after at_exit
|
||||
require 'ARGV+yeast' # needs to be after test/unit to avoid conflict with OptionsParser
|
||||
|
||||
@ -37,7 +41,7 @@ end
|
||||
|
||||
class TestBall <Formula
|
||||
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"
|
||||
end
|
||||
def install
|
||||
@ -49,7 +53,7 @@ end
|
||||
class TestZip <Formula
|
||||
def initialize
|
||||
zip=HOMEBREW_CACHE.parent+'test-0.1.zip'
|
||||
Kernel.system 'zip', '-0', zip, __FILE__
|
||||
Kernel.system 'zip', '-0', zip, ABS__FILE__
|
||||
@url="file://#{zip}"
|
||||
super 'testzip'
|
||||
end
|
||||
@ -76,7 +80,7 @@ class TestBallOverrideBrew <Formula
|
||||
end
|
||||
|
||||
class TestScriptFileFormula <ScriptFileFormula
|
||||
@url="file:///#{Pathname.new(__FILE__).realpath}"
|
||||
@url="file:///#{Pathname.new(ABS__FILE__).realpath}"
|
||||
@version="1"
|
||||
|
||||
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'
|
||||
assert_equal '1.9.1-p243', f.version
|
||||
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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user