diff options
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/formula.rb | 27 | ||||
| -rw-r--r-- | Library/Homebrew/test/test_bucket.rb | 9 | ||||
| -rw-r--r-- | Library/Homebrew/test/test_checksums.rb | 34 | ||||
| -rw-r--r-- | Library/Homebrew/test/test_cleaner.rb | 6 | ||||
| -rw-r--r-- | Library/Homebrew/test/test_formula.rb | 32 | ||||
| -rw-r--r-- | Library/Homebrew/test/test_versions.rb | 9 | ||||
| -rw-r--r-- | Library/Homebrew/test/testball.rb | 29 | ||||
| -rw-r--r-- | Library/Homebrew/test/testing_env.rb | 1 |
8 files changed, 40 insertions, 107 deletions
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 99a61daff..9cf1660dd 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -29,9 +29,6 @@ class Formula @name = name validate_variable :name - # Legacy formulae can set specs via class ivars - ensure_specs_set if @stable.nil? - # If a checksum or version was set in the DSL, but no stable URL # was defined, make @stable nil and save callers some trouble @stable = nil if @stable and @stable.url.nil? @@ -64,30 +61,6 @@ class Formula options.each {|o| self.class.build.add(o[0], o[1]) } end - # Derive specs from class ivars - def ensure_specs_set - set_instance_variable :url - set_instance_variable :version - set_instance_variable :md5 - set_instance_variable :sha1 - set_instance_variable :sha256 - - unless @url.nil? - @stable = SoftwareSpec.new - @stable.url(@url) - @stable.version(@version) - @stable.md5(@md5) - @stable.sha1(@sha1) - @stable.sha256(@sha256) - end - - if @head.kind_of? String - url = @head - @head = HeadSoftwareSpec.new - @head.url(url, self.class.instance_variable_get("@specs")) - end - end - def url; @active_spec.url; end def version; @active_spec.version; end def specs; @active_spec.specs; end diff --git a/Library/Homebrew/test/test_bucket.rb b/Library/Homebrew/test/test_bucket.rb index ace2c1096..0758d2623 100644 --- a/Library/Homebrew/test/test_bucket.rb +++ b/Library/Homebrew/test/test_bucket.rb @@ -3,18 +3,17 @@ require 'test/testball' class MockFormula < Formula def initialize url - @url=url - @homepage = 'http://example.com/' + @stable = SoftwareSpec.new(url) super 'test' end end class TestZip < Formula def initialize + @homepage = 'http://example.com/' zip=HOMEBREW_CACHE.parent+'test-0.1.zip' Kernel.system '/usr/bin/zip', '-q', '-0', zip, ABS__FILE__ - @url="file://#{zip}" - @homepage = 'http://example.com/' + @stable = SoftwareSpec.new "file://#{zip}" super 'testzip' end end @@ -49,7 +48,7 @@ class BeerTasting < Test::Unit::TestCase f << %{ require 'formula' class #{classname} < Formula - @url='' + url '' def initialize(*args) @homepage = 'http://example.com/' super diff --git a/Library/Homebrew/test/test_checksums.rb b/Library/Homebrew/test/test_checksums.rb index 10ac8787c..880796281 100644 --- a/Library/Homebrew/test/test_checksums.rb +++ b/Library/Homebrew/test/test_checksums.rb @@ -3,58 +3,64 @@ require 'test/testball' class ChecksumTests < Test::Unit::TestCase def good_checksum f - assert_nothing_raised { nostdout { f.new.brew {} } } + assert_nothing_raised { nostdout { f.brew {} } } end def bad_checksum f assert_raises ChecksumMismatchError do - nostdout { f.new.brew {} } + nostdout { f.brew {} } end end def test_md5 - valid_md5 = Class.new(TestBall) do - @md5='060844753f2a3b36ecfc3192d307dab2' + valid_md5 = TestBall.new + valid_md5.stable.instance_eval do + md5 '060844753f2a3b36ecfc3192d307dab2' end good_checksum valid_md5 end def test_badmd5 - invalid_md5 = Class.new(TestBall) do - @md5='61aa838a9e4050d1876a295a9e62cbe6' + invalid_md5 = TestBall.new + invalid_md5.stable.instance_eval do + md5 '61aa838a9e4050d1876a295a9e62cbe6' end bad_checksum invalid_md5 end def test_sha1 - valid_sha1 = Class.new(TestBall) do - @sha1='482e737739d946b7c8cbaf127d9ee9c148b999f5' + valid_sha1 = TestBall.new + valid_sha1.stable.instance_eval do + sha1 '482e737739d946b7c8cbaf127d9ee9c148b999f5' end good_checksum valid_sha1 end def test_badsha1 - invalid_sha1 = Class.new(TestBall) do - @sha1='7ea8a98acb8f918df723c2ae73fe67d5664bfd7e' + invalid_sha1 = TestBall.new + invalid_sha1.stable.instance_eval do + sha1 '7ea8a98acb8f918df723c2ae73fe67d5664bfd7e' end bad_checksum invalid_sha1 end def test_sha256 - valid_sha256 = Class.new(TestBall) do - @sha256='1dfb13ce0f6143fe675b525fc9e168adb2215c5d5965c9f57306bb993170914f' + valid_sha256 = TestBall.new + valid_sha256.stable.instance_eval do + sha256 '1dfb13ce0f6143fe675b525fc9e168adb2215c5d5965c9f57306bb993170914f' end good_checksum valid_sha256 end def test_badsha256 - invalid_sha256 = Class.new(TestBall) do - @sha256='dcbf5f44743b74add648c7e35e414076632fa3b24463d68d1f6afc5be77024f8' + invalid_sha256 = TestBall.new + invalid_sha256.stable.instance_eval do + sha256 'dcbf5f44743b74add648c7e35e414076632fa3b24463d68d1f6afc5be77024f8' end bad_checksum invalid_sha256 diff --git a/Library/Homebrew/test/test_cleaner.rb b/Library/Homebrew/test/test_cleaner.rb index 81c2e27d4..ff3012ac5 100644 --- a/Library/Homebrew/test/test_cleaner.rb +++ b/Library/Homebrew/test/test_cleaner.rb @@ -2,11 +2,7 @@ require 'testing_env' require 'cleaner' class CleanerTestBall < Formula - def initialize name=nil - @url="file:///#{TEST_FOLDER}/tarballs/testball-0.1.tbz" - @homepage = 'http://example.com/' - super "cleanertestball" - end + url "file:///#{TEST_FOLDER}/tarballs/testball-0.1.tbz" def install TEST_FOLDER.cd do diff --git a/Library/Homebrew/test/test_formula.rb b/Library/Homebrew/test/test_formula.rb index 6161de275..686d8b0f0 100644 --- a/Library/Homebrew/test/test_formula.rb +++ b/Library/Homebrew/test/test_formula.rb @@ -6,8 +6,7 @@ class AbstractDownloadStrategy end class MostlyAbstractFormula < Formula - @url='' - @homepage = 'http://example.com/' + url '' end class FormulaTests < Test::Unit::TestCase @@ -132,35 +131,6 @@ class FormulaTests < Test::Unit::TestCase assert_equal 0, f.bottle.revision end - def test_ancient_formula_specs - f = AncientSpecTestBall.new - - assert_equal 'http://example.com', f.homepage - assert_equal 'file:///foo.com/testball-0.1.tbz', f.url - assert_equal '0.1', f.version - assert_equal f.stable, f.active_spec - assert_equal CurlDownloadStrategy, f.download_strategy - assert_instance_of CurlDownloadStrategy, f.downloader - - assert_instance_of SoftwareSpec, f.stable - assert_instance_of HeadSoftwareSpec, f.head - - assert_equal 'file:///foo.com/testball-0.1.tbz', f.stable.url - assert_equal 'https://github.com/mxcl/homebrew.git', f.head.url - - assert_nil f.stable.specs - assert_equal({ :tag => 'foo' }, f.head.specs) - - assert_instance_of Checksum, f.stable.checksum - assert_nil f.head.checksum - assert_equal :md5, f.stable.checksum.hash_type - assert_match /[0-9a-fA-F]{32}/, f.stable.checksum.hexdigest - - assert !f.stable.explicit_version? - assert_equal '0.1', f.stable.version - assert_equal 'HEAD', f.head.version - end - def test_devel_active_spec ARGV.push '--devel' f = SpecTestBall.new diff --git a/Library/Homebrew/test/test_versions.rb b/Library/Homebrew/test/test_versions.rb index 95f68e0b7..76af7b8fb 100644 --- a/Library/Homebrew/test/test_versions.rb +++ b/Library/Homebrew/test/test_versions.rb @@ -4,14 +4,17 @@ require 'test/testball' class MockFormula < Formula def initialize url - @url=url - @homepage = 'http://example.com/' + @stable = SoftwareSpec.new(url) super 'test' end end class TestBadVersion < TestBall - @version="versions can't have spaces" + def initialize name=nil + @stable = SoftwareSpec.new + @stable.version "versions can't have spaces" + super 'testbadversion' + end end diff --git a/Library/Homebrew/test/testball.rb b/Library/Homebrew/test/testball.rb index 66036d927..c7118d3ee 100644 --- a/Library/Homebrew/test/testball.rb +++ b/Library/Homebrew/test/testball.rb @@ -3,8 +3,9 @@ require 'formula' class TestBall < Formula # name parameter required for some Formula::factory def initialize name=nil - @url="file:///#{TEST_FOLDER}/tarballs/testball-0.1.tbz" @homepage = 'http://example.com/' + @stable ||= SoftwareSpec.new + @stable.url "file:///#{TEST_FOLDER}/tarballs/testball-0.1.tbz" super "testball" end def install @@ -21,24 +22,21 @@ class TestBallWithRealPath < TestBall end class TestBallWithMirror < Formula - # `url` is bogus---curl should fail to download it. The mirror is fine - # though. url "file:///#{TEST_FOLDER}/bad_url/testball-0.1.tbz" mirror "file:///#{TEST_FOLDER}/tarballs/testball-0.1.tbz" def initialize name=nil - @homepage = 'http://example.com/' super "testballwithmirror" end end class ConfigureFails < Formula # name parameter required for some Formula::factory + url "file:///#{TEST_FOLDER}/tarballs/configure_fails.tar.gz" + version '1.0.0' + md5 '9385e1b68ab8af68ac2c35423443159b' + def initialize name=nil - @url="file:///#{TEST_FOLDER}/tarballs/configure_fails.tar.gz" - @homepage = 'http://example.com/' - @version = '1.0.0' - @md5 = '9385e1b68ab8af68ac2c35423443159b' super "configurefails" end @@ -49,8 +47,7 @@ end class TestCompilerFailures < Formula def initialize name=nil - @url="file:///#{TEST_FOLDER}/tarballs/testball-0.1.tbz" - @homepage = 'http://example.com/' + @stable = SoftwareSpec.new "file:///#{TEST_FOLDER}/tarballs/testball-0.1.tbz" super "compilerfailures" end end @@ -120,18 +117,6 @@ class SpecTestBall < Formula end end -class AncientSpecTestBall < Formula - @homepage='http://example.com' - @url='file:///foo.com/testball-0.1.tbz' - @md5='060844753f2a3b36ecfc3192d307dab2' - @head='https://github.com/mxcl/homebrew.git' - @specs={ :tag => 'foo' } - - def initialize name=nil - super "ancientspectestball" - end -end - class ExplicitVersionSpecTestBall < Formula homepage 'http://example.com' url 'file:///foo.com/testball-stable.tbz' diff --git a/Library/Homebrew/test/testing_env.rb b/Library/Homebrew/test/testing_env.rb index 40e715632..0d0291566 100644 --- a/Library/Homebrew/test/testing_env.rb +++ b/Library/Homebrew/test/testing_env.rb @@ -10,6 +10,7 @@ $:.push(File.expand_path(__FILE__+'/../..')) require 'extend/pathname' require 'exceptions' require 'utils' +require 'extend/string' # these are defined in global.rb, but we don't want to break our actual # homebrew tree, and we do want to test everything :) |
