#!/bin/sh
# Run tests for different runners in parallel

MYDIR=$(dirname $0)

# these are fast, run them first
set -e
$MYDIR/pep8
$MYDIR/pyflakes
$MYDIR/testdesc
$MYDIR/run_args
set +e

# parse out the AdtTestCase classes
CLASSES=`grep -oP '(?<=class )[a-zA-Z]+(?=\(AdtTest)' tests/adt-run`

# get sudo password early, to avoid asking for it in background jobs
[ `id -u` -eq 0 ] || sudo true

for c in $CLASSES; do
    (OUT=$($MYDIR/adt-run $c 2>&1) || rc=$?; echo "=== $c ==="; echo "$OUT"; exit $rc) &
done
for c in $CLASSES; do wait; done
