Decouple CompilerSelector from ENV
This commit is contained in:
parent
f8b4959742
commit
a55fa2c359
@ -114,7 +114,7 @@ def install f
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
CompilerSelector.new(f).select_compiler if f.fails_with? ENV.compiler
|
ENV.send(CompilerSelector.new(f).compiler) if f.fails_with? ENV.compiler
|
||||||
|
|
||||||
f.brew do
|
f.brew do
|
||||||
if ARGV.flag? '--git'
|
if ARGV.flag? '--git'
|
||||||
|
@ -56,11 +56,11 @@ class CompilerSelector
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def select_compiler
|
def compiler
|
||||||
begin
|
begin
|
||||||
cc = @compilers.pop
|
cc = @compilers.pop
|
||||||
end while @f.fails_with?(cc)
|
end while @f.fails_with?(cc)
|
||||||
ENV.send(cc.name) unless cc.nil?
|
cc.nil? ? @old_compiler : cc.name
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -2,14 +2,6 @@ require 'testing_env'
|
|||||||
require 'test/testball'
|
require 'test/testball'
|
||||||
|
|
||||||
class CompilerTests < Test::Unit::TestCase
|
class CompilerTests < Test::Unit::TestCase
|
||||||
def setup
|
|
||||||
%w{HOMEBREW_USE_CLANG HOMEBREW_USE_LLVM HOMEBREW_USE_GCC}.each { |v| ENV.delete(v) }
|
|
||||||
end
|
|
||||||
|
|
||||||
def teardown
|
|
||||||
ENV.send MacOS.default_compiler
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_llvm_failure
|
def test_llvm_failure
|
||||||
f = TestLLVMFailure.new
|
f = TestLLVMFailure.new
|
||||||
cs = CompilerSelector.new(f)
|
cs = CompilerSelector.new(f)
|
||||||
@ -17,13 +9,10 @@ class CompilerTests < Test::Unit::TestCase
|
|||||||
assert !(f.fails_with? :clang)
|
assert !(f.fails_with? :clang)
|
||||||
assert f.fails_with? :llvm
|
assert f.fails_with? :llvm
|
||||||
assert !(f.fails_with? :gcc)
|
assert !(f.fails_with? :gcc)
|
||||||
|
|
||||||
cs.select_compiler
|
|
||||||
|
|
||||||
assert_equal case MacOS.clang_build_version
|
assert_equal case MacOS.clang_build_version
|
||||||
when 0..210 then :gcc
|
when 0..210 then :gcc
|
||||||
else :clang
|
else :clang
|
||||||
end, ENV.compiler
|
end, cs.compiler
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_all_compiler_failures
|
def test_all_compiler_failures
|
||||||
@ -33,10 +22,7 @@ class CompilerTests < Test::Unit::TestCase
|
|||||||
assert f.fails_with? :clang
|
assert f.fails_with? :clang
|
||||||
assert f.fails_with? :llvm
|
assert f.fails_with? :llvm
|
||||||
assert f.fails_with? :gcc
|
assert f.fails_with? :gcc
|
||||||
|
assert_equal MacOS.default_compiler, cs.compiler
|
||||||
cs.select_compiler
|
|
||||||
|
|
||||||
assert_equal MacOS.default_compiler, ENV.compiler
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_no_compiler_failures
|
def test_no_compiler_failures
|
||||||
@ -49,10 +35,7 @@ class CompilerTests < Test::Unit::TestCase
|
|||||||
when nil then f.fails_with? :gcc
|
when nil then f.fails_with? :gcc
|
||||||
else !(f.fails_with? :gcc)
|
else !(f.fails_with? :gcc)
|
||||||
end
|
end
|
||||||
|
assert_equal MacOS.default_compiler, cs.compiler
|
||||||
cs.select_compiler
|
|
||||||
|
|
||||||
assert_equal MacOS.default_compiler, ENV.compiler
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_mixed_compiler_failures
|
def test_mixed_compiler_failures
|
||||||
@ -62,10 +45,7 @@ class CompilerTests < Test::Unit::TestCase
|
|||||||
assert f.fails_with? :clang
|
assert f.fails_with? :clang
|
||||||
assert !(f.fails_with? :llvm)
|
assert !(f.fails_with? :llvm)
|
||||||
assert f.fails_with? :gcc
|
assert f.fails_with? :gcc
|
||||||
|
assert_equal :llvm, cs.compiler
|
||||||
cs.select_compiler
|
|
||||||
|
|
||||||
assert_equal :llvm, ENV.compiler
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_more_mixed_compiler_failures
|
def test_more_mixed_compiler_failures
|
||||||
@ -75,10 +55,7 @@ class CompilerTests < Test::Unit::TestCase
|
|||||||
assert !(f.fails_with? :clang)
|
assert !(f.fails_with? :clang)
|
||||||
assert f.fails_with? :llvm
|
assert f.fails_with? :llvm
|
||||||
assert f.fails_with? :gcc
|
assert f.fails_with? :gcc
|
||||||
|
assert_equal :clang, cs.compiler
|
||||||
cs.select_compiler
|
|
||||||
|
|
||||||
assert_equal :clang, ENV.compiler
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_even_more_mixed_compiler_failures
|
def test_even_more_mixed_compiler_failures
|
||||||
@ -91,13 +68,10 @@ class CompilerTests < Test::Unit::TestCase
|
|||||||
when nil then f.fails_with? :gcc
|
when nil then f.fails_with? :gcc
|
||||||
else !(f.fails_with? :gcc)
|
else !(f.fails_with? :gcc)
|
||||||
end
|
end
|
||||||
|
|
||||||
cs.select_compiler
|
|
||||||
|
|
||||||
assert_equal case MacOS.gcc_42_build_version
|
assert_equal case MacOS.gcc_42_build_version
|
||||||
when nil then :llvm
|
when nil then :llvm
|
||||||
else :gcc
|
else :gcc
|
||||||
end, ENV.compiler
|
end, cs.compiler
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_block_with_no_build_compiler_failures
|
def test_block_with_no_build_compiler_failures
|
||||||
@ -107,9 +81,6 @@ class CompilerTests < Test::Unit::TestCase
|
|||||||
assert f.fails_with? :clang
|
assert f.fails_with? :clang
|
||||||
assert !(f.fails_with? :llvm)
|
assert !(f.fails_with? :llvm)
|
||||||
assert !(f.fails_with? :gcc)
|
assert !(f.fails_with? :gcc)
|
||||||
|
assert_not_equal :clang, cs.compiler
|
||||||
cs.select_compiler
|
|
||||||
|
|
||||||
assert_not_equal :clang, ENV.compiler
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user