spec_helper.rb (1166B)
1 2 require_relative '../lib/ffi/clang' 3 4 require 'pry' 5 6 include FFI::Clang 7 8 TMP_DIR = File.expand_path("tmp", __dir__) 9 10 module ClangSpecHelper 11 def fixture_path(path) 12 File.join File.expand_path("ffi/clang/fixtures", __dir__), path 13 end 14 15 def find_all(cursor, kind) 16 cursor.find_all(kind) 17 end 18 19 def find_first(cursor, kind) 20 cursor.find_first(kind) 21 end 22 23 def find_all_matching(cursor, &term) 24 cursor.filter(&term) 25 end 26 27 def find_matching(cursor, &term) 28 cursor.filter(&term).first 29 end 30 end 31 32 RSpec.configure do |config| 33 # Enable flags like --only-failures and --next-failure 34 config.example_status_persistence_file_path = ".rspec_status" 35 36 config.include ClangSpecHelper 37 38 supported_versions = ['3.4', '3.5', '3.6', '3.7', '3.8', '3.9', '4.0'] 39 current_version = ENV['LLVM_VERSION'] || supported_versions.last 40 supported_versions.reverse_each { |version| 41 break if version == current_version 42 sym = ('from_' + version.tr('.', '_')).to_sym 43 config.filter_run_excluding sym => true 44 } 45 46 supported_versions.each { |version| 47 break if version == current_version 48 sym = ('upto_' + version.tr('.', '_')).to_sym 49 config.filter_run_excluding sym => true 50 } 51 end