#!/bin/sh
# Compile upstream's tests with the installed compilers against the
# installed jars, and run them (sourcecode.Main asserts and exits non-zero
# on failure).
set -eu
T=${AUTOPKGTEST_TMP:-$(mktemp -d)}
J=/usr/share/java
for v in 2.13 3; do
	if [ $v = 3 ]; then s=3; else s=2; fi
	mkdir -p "$T/$v"
	find sourcecode/test/src sourcecode/test/src-$s -name '*.scala' \
		| LC_ALL=C sort > "$T/$v.files"
	scalac-$v -d "$T/$v" -cp $J/sourcecode-$v.jar @"$T/$v.files"
	java -cp $J/scala-library-$v.jar:$J/sourcecode-$v.jar:"$T/$v" sourcecode.Main
	echo "Scala $v: upstream tests passed"
done
