#!/bin/bash
set -euo pipefail

if [[ -z "$2" ]] ; then
    echo Usage: $(basename "$0") TEST-CLASS MODE VARIANT?
    exit 1
fi

CLASS="$1"
ARGS="$2 ${3-}"

OUT=__out
DIR="$(dirname "$0")"
LIB="$DIR/lib/*"

rm -rf "$OUT"

javac \
    -encoding utf-8 \
    -d "$OUT" \
    "--class-path=$LIB:$DIR/../common:$DIR" \
    "$DIR/${CLASS//\.//}.java" \
 && java -ea "--class-path=$LIB:$OUT" "$CLASS" $ARGS
