#!/bin/sh
set -efu

PYS=${PYS:-"$(pyversions -r 2>/dev/null)"}
TESTMODE=${TESTMODE:-full}
TESTPKG=${TESTPKG:-scipy}

cd "$ADTTMP"
#nosetest does not handle knowfailures
cat << EOF > runtest.py
import $TESTPKG
import re
# add failures to skip here
skip = [
# ppc failure
"test_qhull.TestUtilities.test_degenerate_barycentric_transforms",
# dict ordering fixed 0.12
"test_mio.test_save_dict",
# i386 small rounding issue
"test_spfun_stats.TestMultiGammaLn",
# i386 small rounding issue should be fixed in 0.12
"test_qhull.TestUtilities.test_more_barycentric_transforms",
# fixed #457
"test_io.test_imread",
# fails with atlas on i386 #702461
"test_decomp.TestEig.test_singular",
]
r = $TESTPKG.test(label='$TESTMODE', verbose=2);
errors = []
for e in (r.errors + r.failures):
    if not any(re.search(s, e[0].id()) for s in skip):
        print e[0].id()
        errors.append(e)
print "#errors: %d" % len(errors)
assert len(errors) == 0
EOF


for py in $PYS; do
    echo "=== $py ==="
    $py runtest.py 2>&1
done
