diff options
| author | Misty De Meo | 2013-06-28 01:38:09 -0500 |
|---|---|---|
| committer | Misty De Meo | 2013-09-01 13:19:13 -0700 |
| commit | ef1d9c0cd04c21b5b19cae17e83bbdc6ef28d712 (patch) | |
| tree | e65e63fa2b446cc0ec80694f2572acba589b70e7 /Library/Homebrew/test/test_compiler_selector.rb | |
| parent | 71268b7f16f017a94304488e3b3cbc4c1ca3bfe7 (diff) | |
| download | brew-ef1d9c0cd04c21b5b19cae17e83bbdc6ef28d712.tar.bz2 | |
Implement fails_with for non-Apple compilers
This adds support for non-Apple GCC compilers in the fails_with code.
A fails_with block for a non-Apple compiler looks like:
fails_with :gcc => '4.8.1' do
cause 'Foo'
end
Non-Apple compilers don't have build numbers, so compiler failures are
based on version strings instead.
Internally non-Apple compilers can be distinguished because they are
passed around as strings instead of symbols.
In addition, this alters the priority list for compilers, with the
following changes:
* Apple GCC 4.2 and LLVM-GCC swap positions, with GCC now taking
priority. (Maybe LLVM-GCC should just go away.)
* Non-Apple GCC compilers are ranked below GCC 4.2 but above LLVM-GCC
and Apple GCC 4.0.
Diffstat (limited to 'Library/Homebrew/test/test_compiler_selector.rb')
| -rw-r--r-- | Library/Homebrew/test/test_compiler_selector.rb | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/Library/Homebrew/test/test_compiler_selector.rb b/Library/Homebrew/test/test_compiler_selector.rb index 17c3b0449..5374a5452 100644 --- a/Library/Homebrew/test/test_compiler_selector.rb +++ b/Library/Homebrew/test/test_compiler_selector.rb @@ -22,16 +22,29 @@ class CompilerSelectorTests < Test::Unit::TestCase MacOS.stubs(:gcc_build_version).returns(5666) MacOS.stubs(:llvm_build_version).returns(2336) MacOS.stubs(:clang_build_version).returns(425) + # Yes, this is ugly - we only want one GCC version to be available. + MacOS.send(:alias_method, :old_non_apple_gcc_version, :non_apple_gcc_version) + MacOS.send(:define_method, :non_apple_gcc_version) do |name| + if name == 'gcc-4.8' + '4.8.1' + else + nil + end + end @f = Double.new @cc = :clang end + def teardown + MacOS.send(:alias_method, :non_apple_gcc_version, :old_non_apple_gcc_version) + end + def actual_cc CompilerSelector.new(@f).compiler end def test_all_compiler_failures - @f << :clang << :llvm << :gcc + @f << :clang << :llvm << :gcc << 'gcc-4.8' assert_raise(CompilerSelectionError) { actual_cc } end @@ -41,7 +54,7 @@ class CompilerSelectorTests < Test::Unit::TestCase def test_fails_with_clang @f << :clang - assert_equal :llvm, actual_cc + assert_equal :gcc, actual_cc end def test_fails_with_llvm @@ -54,13 +67,18 @@ class CompilerSelectorTests < Test::Unit::TestCase assert_equal :clang, actual_cc end + def test_fails_with_non_apple_gcc + @f << "gcc-4.8" + assert_equal :clang, actual_cc + end + def test_mixed_failures_1 @f << :clang << :llvm assert_equal :gcc, actual_cc end def test_mixed_failures_2 - @f << :gcc << :clang + @f << :gcc << :clang << 'gcc-4.8' assert_equal :llvm, actual_cc end @@ -69,22 +87,32 @@ class CompilerSelectorTests < Test::Unit::TestCase assert_equal :clang, actual_cc end + def test_mixed_failures_4 + @f << :clang << "gcc-4.8" + assert_equal :gcc, actual_cc + end + def test_older_clang_precedence MacOS.stubs(:clang_build_version).returns(211) - @f << :gcc + @f << :gcc << 'gcc-4.8' assert_equal :llvm, actual_cc end + def test_non_apple_gcc_precedence + @f << :clang << :gcc + assert_equal 'gcc-4.8', actual_cc + end + def test_missing_gcc MacOS.stubs(:gcc_build_version).returns(nil) - @f << :clang << :llvm + @f << :clang << :llvm << 'gcc-4.8' assert_raise(CompilerSelectionError) { actual_cc } end def test_missing_llvm_and_gcc MacOS.stubs(:gcc_build_version).returns(nil) MacOS.stubs(:llvm_build_version).returns(nil) - @f << :clang + @f << :clang << 'gcc-4.8' assert_raise(CompilerSelectionError) { actual_cc } end end |
