#!/bin/sh

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

prepare

cd "$AUTOPKGTEST_TMP"

# extra java libs required
mkdir test/target
ln -s /usr/share/java/junit4.jar test/target/junit.jar
ln -s /usr/share/java/jakarta-annotation-api.jar test/target/annotation-api.jar
ln -s /usr/share/java/jarjar.jar test/target/jarjar.jar

# compile a few test dependencies
gcc test/jruby/testapp/testapp.c -o test/jruby/testapp/testapp
javac -cp lib/jruby.jar:test/target/junit.jar:test/target/annotation-api.jar -d test/target/test-classes \
    test/org/jruby/test/*.java \
    test/org/jruby/javasupport/test/*.java \
    test/org/jruby/javasupport/test/*/*.java \
    test/*.java

# some test cases look for these specific files
cp "$OLDPWD/pom.xml" .
cp bin/jruby bin/jruby.sh

# when $TMPDIR is /tmp and $PWD is under there
# it causes the test_jrubyc.rb/test_target test case to fail
TMPDIR="$(mktemp -d)"
export TMPDIR

# run a single test
#jruby -I. test/jruby/test_loading_builtin_libraries.rb

# run the full rspec testsuite
jruby -S rake test:jruby
