#!/bin/sh
# autopkgtest check: build and run the tests that are provided by upstream.
# Run the tests that come with the upstream source.
# (C) 2020 Pierre Gruet.
# Author: Pierre Gruet <pgtdebian@free.fr>

set -e

SOURCEDIR=$(pwd)
WORKDIR=$(mktemp -d)
trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
cp -r DistLib/ $WORKDIR
cd $WORKDIR

TESTCLASSPATH="/usr/share/java/junit4.jar"
export CLASSPATH="DistLib/src:/usr/share/java/distlib.jar:$TESTCLASSPATH"
# Compiling and running. I am redirecting stderr as a warning is launched.
find . -name '*Test*.java' | xargs javac 2>&1
java DistLib.AllTests

