
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.
68 lines
1.3 KiB
Ruby
68 lines
1.3 KiB
Ruby
require 'testing_env'
|
|
require 'test/testball'
|
|
|
|
class FailsWithTests < Test::Unit::TestCase
|
|
class Double < Compiler
|
|
attr_accessor :name, :build, :version
|
|
end
|
|
|
|
def assert_fails_with(cc)
|
|
assert @f.new.fails_with?(cc)
|
|
end
|
|
|
|
def assert_does_not_fail_with(cc)
|
|
assert !@f.new.fails_with?(cc)
|
|
end
|
|
|
|
def fails_with(*args, &block)
|
|
@f.send(:fails_with, *args, &block)
|
|
end
|
|
|
|
def build_cc(sym, build, version=nil)
|
|
cc = Double.new
|
|
cc.name = sym
|
|
cc.build = build
|
|
cc.version = version
|
|
cc
|
|
end
|
|
|
|
def setup
|
|
@f = Class.new(TestBall)
|
|
end
|
|
|
|
def test_fails_with_symbol
|
|
fails_with :clang
|
|
cc = build_cc(:clang, 425)
|
|
assert_fails_with cc
|
|
end
|
|
|
|
def test_fails_with_build
|
|
fails_with(:clang) { build 211 }
|
|
cc = build_cc(:clang, 318)
|
|
assert_does_not_fail_with cc
|
|
end
|
|
|
|
def test_fails_with_block_without_build
|
|
fails_with(:clang) { }
|
|
cc = build_cc(:clang, 425)
|
|
assert_fails_with cc
|
|
end
|
|
|
|
def test_non_apple_gcc_version
|
|
fails_with(:gcc => '4.8.2')
|
|
cc = build_cc("gcc-4.8", nil, "4.8.1")
|
|
assert_fails_with cc
|
|
end
|
|
|
|
def test_multiple_failures
|
|
fails_with(:llvm)
|
|
fails_with(:clang)
|
|
gcc = build_cc(:gcc, 5666)
|
|
llvm = build_cc(:llvm, 2336)
|
|
clang = build_cc(:clang, 425)
|
|
assert_fails_with llvm
|
|
assert_fails_with clang
|
|
assert_does_not_fail_with gcc
|
|
end
|
|
end
|