#!/bin/sh -ex

export DISPLAY=:99.0

for py in $(py3versions --supported 2> /dev/null); do
    tmphome=$(mktemp -d)
    /sbin/start-stop-daemon --start --quiet --pidfile $tmphome/custom_xvfb.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99
    /sbin/start-stop-daemon --start --quiet --pidfile $tmphome/custom_herbstluftwm.pid --make-pidfile --background --exec /usr/bin/herbstluftwm -- --replace

    echo "Testing with $py: "
    HOME=$tmphome $py -m pytest --pyargs orangecanvas -k "not test_iconengine" --capture=no

    /sbin/start-stop-daemon --stop --quiet --pidfile $tmphome/custom_herbstluftwm.pid --remove-pidfile || true
    /sbin/start-stop-daemon --stop --quiet --pidfile $tmphome/custom_xvfb.pid --remove-pidfile || true
    rm -rf $tmphome
done
