#!/bin/sh

. "$(dirname $0)/common.sh"

prepare
install_gem_bundle
debug_tests

cd "$AUTOPKGTEST_TMP"

# exclude failing testcase
# with "Expected /OK/ (oid=4000) to be the same as /OK/ (oid=4004)."
# needs further investigation
mri_exclude test_regexp TestBasicInstructions.rb

# exclude unreliable signal+thread tests
# https://github.com/jruby/jruby/issues/4956
mri_exclude test_thread_join_in_trap TestThread.rb
mri_exclude test_thread_value_in_trap TestThread.rb

# flaky test
mri_exclude test_autoload_same_file_with_raise TestAutoload.rb

# fix TestDir#test_instance_chdir which sets HOME to $pwd
JRUBY_OPTS="--nocache"
export JRUBY_OPTS

# fix TestRubyOptions#test_rubylib_invalid_encoding
# due to unavailable locale in autopkgtest
sed -i "s/en_US\.UTF-8/C.UTF-8/g" test/mri/ruby/test_rubyoptions.rb

# run a single test
#jruby test/mri/runner.rb --excludes=test/mri/excludes:test/mri/excludes_wip test/mri/ruby/test_thread.rb

# run the testsuite
jruby -S rake test:mri:core
