#!/bin/sh

set -e -u

cp -va tests scripts "$AUTOPKGTEST_TMP"/
cd "$AUTOPKGTEST_TMP"

# ensure chromium is found where upstream test expect it.
if [ -x "/usr/bin/chromium" ] && [ ! -x "/usr/bin/chromium-browser" ]; then
	ln -vs /usr/bin/chromium /usr/bin/chromium-browser
fi

echo "Running testsuite with default python3 version:"
# disable some tests:
# test_publicipv4: requires a configured interface and network access
# test_extract_pot: only relevant for internal upstream use
# test_functional_downloads: needs network access and usenet server credentials
# test_happyeyeballs, test_internetspeed.py: needs network access
# test_rss_basic_flow: needs pytest httpserver
# test_queue_repair: too flaky
CI=TRUE PYTHONPATH=/usr/share/sabnzbdplus python3 -m pytest -v -k "not \
	( \
		test_publicipv4 or \
		test_extract_pot or \
		test_functional_downloads or \
		test_happyeyeballs or \
		test_internetspeed or \
		test_permissions_450 or \
		test_http_params_etc or \
		test_rss_basic_flow or \
		test_queue_repair \
	)"
