From b36f59dd3c8a3bf95eeb715e3fdd05bce2ccdc75 Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Sun, 18 Mar 2012 13:58:13 -0500 Subject: 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 --- Library/Homebrew/test/test_formula.rb | 69 ++++++++++++++++++++++++++++- Library/Homebrew/test/testball.rb | 82 +++++++++++++++++++++++++++++++++++ Library/Homebrew/test/testing_env.rb | 1 + 3 files changed, 151 insertions(+), 1 deletion(-) (limited to 'Library/Homebrew/test') 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