зеркало из https://github.com/github/bert.git
test ruby and c implementations
This commit is contained in:
Родитель
59692ed4a5
Коммит
57c7b1de79
|
@ -2,3 +2,6 @@ language: ruby
|
||||||
rvm:
|
rvm:
|
||||||
- 2.3.3
|
- 2.3.3
|
||||||
- 2.4.0
|
- 2.4.0
|
||||||
|
env:
|
||||||
|
- BERT_TEST_IMPL=Ruby
|
||||||
|
- BERT_TEST_IMPL=C
|
||||||
|
|
15
lib/bert.rb
15
lib/bert.rb
|
@ -6,12 +6,19 @@ $:.unshift File.join(File.dirname(__FILE__), *%w[.. ext])
|
||||||
require 'bert/bert'
|
require 'bert/bert'
|
||||||
require 'bert/types'
|
require 'bert/types'
|
||||||
|
|
||||||
begin
|
case ENV["BERT_TEST_IMPL"]
|
||||||
# try to load the C extension
|
when "C"
|
||||||
require 'bert/c/decode'
|
require 'bert/c/decode'
|
||||||
rescue LoadError
|
when "Ruby"
|
||||||
# fall back on the pure ruby version
|
|
||||||
require 'bert/decode'
|
require 'bert/decode'
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
# try to load the C extension
|
||||||
|
require 'bert/c/decode'
|
||||||
|
rescue LoadError
|
||||||
|
# fall back on the pure ruby version
|
||||||
|
require 'bert/decode'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
require 'bert/encode'
|
require 'bert/encode'
|
||||||
|
|
|
@ -7,4 +7,9 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'ext', 'bert', 'c'))
|
||||||
|
|
||||||
load 'bert.rb'
|
load 'bert.rb'
|
||||||
|
|
||||||
puts "Using #{BERT::Decode.impl} implementation."
|
if ENV.key?("BERT_TEST_IMPL") && ENV["BERT_TEST_IMPL"] != BERT::Decode.impl
|
||||||
|
raise "Incorrect implementation loaded for value of BERT_TEST_IMPL environment variable! " +
|
||||||
|
"Wanted #{ENV["BERT_TEST_IMPL"]}, but loaded #{BERT::Decode.impl}."
|
||||||
|
end
|
||||||
|
|
||||||
|
puts "Using #{BERT::Decode.impl} implementation."
|
||||||
|
|
Загрузка…
Ссылка в новой задаче