diff options
| author | Jack Nagel | 2012-04-14 13:17:22 -0500 |
|---|---|---|
| committer | Jack Nagel | 2012-04-14 15:27:45 -0500 |
| commit | 2289f98003d5cba6a9b56f12a2da978498dc2a2b (patch) | |
| tree | ea006bd47175de3c073d0ac37c817d04a0a0e894 /Library | |
| parent | 141f21db11c43c20f213ddc2455de70dac98820e (diff) | |
| download | homebrew-2289f98003d5cba6a9b56f12a2da978498dc2a2b.tar.bz2 | |
tests: reorganize compiler selection tests
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/test/test_compilers.rb | 143 | ||||
| -rw-r--r-- | Library/Homebrew/test/test_formula.rb | 72 | ||||
| -rwxr-xr-x | Library/Homebrew/test/tests | 3 |
3 files changed, 145 insertions, 73 deletions
diff --git a/Library/Homebrew/test/test_compilers.rb b/Library/Homebrew/test/test_compilers.rb new file mode 100644 index 000000000..7ad6f2df7 --- /dev/null +++ b/Library/Homebrew/test/test_compilers.rb @@ -0,0 +1,143 @@ +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' + +module CompilerTestsEnvExtension + def unset_use_cc + vars = %w{HOMEBREW_USE_CLANG HOMEBREW_USE_LLVM HOMEBREW_USE_GCC} + vars.each { |v| ENV.delete(v) } + end +end +ENV.extend(CompilerTestsEnvExtension) + +class CompilerTests < Test::Unit::TestCase + def test_llvm_failure + ENV.unset_use_cc + f = TestLLVMFailure.new + cs = CompilerSelector.new(f) + + assert !(f.fails_with? :clang) + assert f.fails_with? :llvm + assert !(f.fails_with? :gcc) + + cs.select_compiler + + assert_equal case MacOS.clang_build_version + when 0..210 then :gcc + else :clang + end, ENV.compiler + + ENV.send MacOS.default_compiler + end + + def test_all_compiler_failures + ENV.unset_use_cc + f = TestAllCompilerFailures.new + cs = CompilerSelector.new(f) + + assert f.fails_with? :clang + assert f.fails_with? :llvm + assert f.fails_with? :gcc + + cs.select_compiler + + assert_equal MacOS.default_compiler, ENV.compiler + + ENV.send MacOS.default_compiler + end + + def test_no_compiler_failures + ENV.unset_use_cc + f = TestNoCompilerFailures.new + cs = CompilerSelector.new(f) + + assert !(f.fails_with? :clang) + assert !(f.fails_with? :llvm) + assert case MacOS.gcc_42_build_version + when 0 then f.fails_with? :gcc + else !(f.fails_with? :gcc) + end + + cs.select_compiler + + assert_equal MacOS.default_compiler, ENV.compiler + + ENV.send MacOS.default_compiler + end + + def test_mixed_compiler_failures + ENV.unset_use_cc + f = TestMixedCompilerFailures.new + cs = CompilerSelector.new(f) + + assert f.fails_with? :clang + assert !(f.fails_with? :llvm) + assert f.fails_with? :gcc + + cs.select_compiler + + assert_equal :llvm, ENV.compiler + + ENV.send MacOS.default_compiler + end + + def test_more_mixed_compiler_failures + ENV.unset_use_cc + f = TestMoreMixedCompilerFailures.new + cs = CompilerSelector.new(f) + + assert !(f.fails_with? :clang) + assert f.fails_with? :llvm + assert f.fails_with? :gcc + + cs.select_compiler + + assert_equal :clang, ENV.compiler + + ENV.send MacOS.default_compiler + end + + def test_even_more_mixed_compiler_failures + ENV.unset_use_cc + f = TestEvenMoreMixedCompilerFailures.new + cs = CompilerSelector.new(f) + + assert f.fails_with? :clang + assert f.fails_with? :llvm + assert case MacOS.gcc_42_build_version + when 0 then f.fails_with? :gcc + else !(f.fails_with? :gcc) + end + + cs.select_compiler + + assert_equal case MacOS.clang_build_version + when 0..210 then :gcc + else :clang + end, ENV.compiler + + ENV.send MacOS.default_compiler + end + + def test_block_with_no_build_compiler_failures + ENV.unset_use_cc + f = TestBlockWithoutBuildCompilerFailure.new + cs = CompilerSelector.new(f) + + assert f.fails_with? :clang + assert !(f.fails_with? :llvm) + assert !(f.fails_with? :gcc) + + cs.select_compiler + + assert_equal MacOS.default_compiler, ENV.compiler + + ENV.send MacOS.default_compiler + end +end diff --git a/Library/Homebrew/test/test_formula.rb b/Library/Homebrew/test/test_formula.rb index 3144afaa9..b49b06757 100644 --- a/Library/Homebrew/test/test_formula.rb +++ b/Library/Homebrew/test/test_formula.rb @@ -8,8 +8,6 @@ ENV.extend(HomebrewEnvExtension) require 'test/testball' -require 'hardware' - class AbstractDownloadStrategy attr_reader :url end @@ -68,74 +66,4 @@ class FormulaTests < Test::Unit::TestCase assert_equal downloader.url, "file:///#{TEST_FOLDER}/tarballs/testball-0.1.tbz" end 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 - ENV.send MacOS.default_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 - ENV.send MacOS.default_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_equal case MacOS.clang_build_version - when 0..210 then :gcc - else :clang - end, ENV.compiler - ENV.send MacOS.default_compiler - - 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 - ENV.send MacOS.default_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 - ENV.send MacOS.default_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 - ENV.send MacOS.default_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 - ENV.send MacOS.default_compiler - end end diff --git a/Library/Homebrew/test/tests b/Library/Homebrew/test/tests index adbc600ec..c7e2689f2 100755 --- a/Library/Homebrew/test/tests +++ b/Library/Homebrew/test/tests @@ -8,6 +8,7 @@ EXIT=0 /usr/bin/ruby test_formula.rb $* || EXIT=1 /usr/bin/ruby test_versions.rb $* || EXIT=1 /usr/bin/ruby test_checksums.rb $* || EXIT=1 +/usr/bin/ruby test_compilers.rb $* || EXIT=1 /usr/bin/ruby test_inreplace.rb $* || EXIT=1 /usr/bin/ruby test_hardware.rb $* || EXIT=1 /usr/bin/ruby test_formula_install.rb $* || EXIT=1 @@ -20,4 +21,4 @@ EXIT=0 /usr/bin/ruby test_updater.rb $* || EXIT=1 /usr/bin/ruby test_string.rb $* || EXIT=1 -exit $EXIT
\ No newline at end of file +exit $EXIT |
