#!/bin/sh
set -efu

PYS=${PYS:-"$(py3versions -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",
]
import platform
extra=""
#http://projects.scipy.org/scipy/ticket/1858
if platform.processor() == "ppc":
    extra=["-e", "test_mio"]
r = $TESTPKG.test(label='$TESTMODE', verbose=2, extra_argv=extra);
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
