diff options
| author | Jack Nagel | 2012-03-18 13:58:13 -0500 |
|---|---|---|
| committer | Jack Nagel | 2012-04-01 12:39:59 -0500 |
| commit | b36f59dd3c8a3bf95eeb715e3fdd05bce2ccdc75 (patch) | |
| tree | ba3f6961363bfd11839976ce295b7967a275f208 /Library/Homebrew/test | |
| parent | be829c72c3255e0d1682a1e796b91cb644109372 (diff) | |
| download | homebrew-b36f59dd3c8a3bf95eeb715e3fdd05bce2ccdc75.tar.bz2 | |
New fails_with infrastructure
- Formulae can now declare failures on any compiler.
- FailsWithLLVM and associated formula elements have been moved to
compat.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Diffstat (limited to 'Library/Homebrew/test')
| -rw-r--r-- | Library/Homebrew/test/test_formula.rb | 69 | ||||
| -rw-r--r-- | Library/Homebrew/test/testball.rb | 82 | ||||
| -rw-r--r-- | Library/Homebrew/test/testing_env.rb | 1 |
3 files changed, 151 insertions, 1 deletions
diff --git a/Library/Homebrew/test/test_formula.rb b/Library/Homebrew/test/test_formula.rb index a819e5751..0735d55d6 100644 --- a/Library/Homebrew/test/test_formula.rb +++ b/Library/Homebrew/test/test_formula.rb @@ -3,8 +3,12 @@ require 'testing_env' require 'extend/ARGV' # needs to be after test/unit to avoid conflict with OptionsParser ARGV.extend(HomebrewArgvExtension) +require 'extend/ENV' +ENV.extend(HomebrewEnvExtension) + require 'test/testball' -require 'utils' + +require 'hardware' class AbstractDownloadStrategy attr_reader :url @@ -62,4 +66,67 @@ class FormulaTests < Test::Unit::TestCase assert_equal f.url, "file:///#{TEST_FOLDER}/bad_url/testball-0.1.tbz" assert_equal downloader.url, "file:///#{TEST_FOLDER}/tarballs/testball-0.1.tbz" end + + def test_compiler_selection + %W{HOMEBREW_USE_CLANG HOMEBEW_USE_LLVM HOMEBREW_USE_GCC}.each { |e| ENV.delete(e) } + + f = TestAllCompilerFailures.new + assert f.fails_with? :clang + assert f.fails_with? :llvm + assert f.fails_with? :gcc + cs = CompilerSelector.new(f) + cs.select_compiler + assert_equal MacOS.default_compiler, ENV.compiler + + f = TestNoCompilerFailures.new + assert !(f.fails_with? :clang) + assert !(f.fails_with? :llvm) + assert !(f.fails_with? :gcc) + cs = CompilerSelector.new(f) + cs.select_compiler + assert_equal MacOS.default_compiler, ENV.compiler + + f = TestLLVMFailure.new + assert !(f.fails_with? :clang) + assert f.fails_with? :llvm + assert !(f.fails_with? :gcc) + cs = CompilerSelector.new(f) + cs.select_compiler + assert ENV.compiler, case MacOS.clang_build_version + when 0..210 then :gcc + else :clang + end + + f = TestMixedCompilerFailures.new + assert f.fails_with? :clang + assert !(f.fails_with? :llvm) + assert f.fails_with? :gcc + cs = CompilerSelector.new(f) + cs.select_compiler + assert_equal :llvm, ENV.compiler + + f = TestMoreMixedCompilerFailures.new + assert !(f.fails_with? :clang) + assert f.fails_with? :llvm + assert f.fails_with? :gcc + cs = CompilerSelector.new(f) + cs.select_compiler + assert_equal :clang, ENV.compiler + + f = TestEvenMoreMixedCompilerFailures.new + assert f.fails_with? :clang + assert f.fails_with? :llvm + assert !(f.fails_with? :gcc) + cs = CompilerSelector.new(f) + cs.select_compiler + assert_equal :clang, ENV.compiler + + f = TestBlockWithoutBuildCompilerFailure.new + assert f.fails_with? :clang + assert !(f.fails_with? :llvm) + assert !(f.fails_with? :gcc) + cs = CompilerSelector.new(f) + cs.select_compiler + assert_equal MacOS.default_compiler, ENV.compiler + end end diff --git a/Library/Homebrew/test/testball.rb b/Library/Homebrew/test/testball.rb index aae18115c..a77d7709c 100644 --- a/Library/Homebrew/test/testball.rb +++ b/Library/Homebrew/test/testball.rb @@ -39,3 +39,85 @@ class ConfigureFails <Formula system "./configure" end end + +class TestAllCompilerFailures < Formula + def initialize name=nil + @url="file:///#{TEST_FOLDER}/tarballs/testball-0.1.tbz" + @homepage = 'http://example.com/' + super "compilerfailures" + end + + fails_with :clang + fails_with :llvm + fails_with :gcc +end + +class TestNoCompilerFailures < Formula + def initialize name=nil + @url="file:///#{TEST_FOLDER}/tarballs/testball-0.1.tbz" + @homepage = 'http://example.com/' + super "nocompilerfailures" + end + + fails_with(:clang) { build 42 } + fails_with(:llvm) { build 42 } + fails_with(:gcc) { build 42 } +end + +class TestLLVMFailure < Formula + def initialize name=nil + @url="file:///#{TEST_FOLDER}/tarballs/testball-0.1.tbz" + @homepage = 'http://example.com/' + super "llvmfailure" + end + + fails_with :llvm +end + +class TestMixedCompilerFailures < Formula + def initialize name=nil + @url="file:///#{TEST_FOLDER}/tarballs/testball-0.1.tbz" + @homepage = 'http://example.com/' + super "mixedcompilerfailures" + end + + fails_with(:clang) { build MacOS.clang_build_version } + fails_with(:llvm) { build 42 } + fails_with(:gcc) { build 5666 } +end + +class TestMoreMixedCompilerFailures < Formula + def initialize name=nil + @url="file:///#{TEST_FOLDER}/tarballs/testball-0.1.tbz" + @homepage = 'http://example.com/' + super "moremixedcompilerfailures" + end + + fails_with(:clang) { build 42 } + fails_with(:llvm) { build 2336 } + fails_with(:gcc) { build 5666 } +end + +class TestEvenMoreMixedCompilerFailures < Formula + def initialize name=nil + @url="file:///#{TEST_FOLDER}/tarballs/testball-0.1.tbz" + @homepage = 'http://example.com/' + super "evenmoremixedcompilerfailures" + end + + fails_with :clang + fails_with(:llvm) { build 2336 } + fails_with(:gcc) { build 5648 } +end + +class TestBlockWithoutBuildCompilerFailure < Formula + def initialize name=nil + @url="file:///#{TEST_FOLDER}/tarballs/testball-0.1.tbz" + @homepage = 'http://example.com/' + super "blockwithoutbuildcompilerfailure" + end + + fails_with :clang do + cause "failure" + end +end diff --git a/Library/Homebrew/test/testing_env.rb b/Library/Homebrew/test/testing_env.rb index c0556651c..1e183287a 100644 --- a/Library/Homebrew/test/testing_env.rb +++ b/Library/Homebrew/test/testing_env.rb @@ -9,6 +9,7 @@ ABS__FILE__=File.expand_path(__FILE__) $:.push(File.expand_path(__FILE__+'/../..')) require 'extend/pathname' require 'exceptions' +require 'utils' # these are defined in global.rb, but we don't want to break our actual # homebrew tree, and we do want to test everything :) |
