#!/bin/bash
# this intentionally doesn't actually fail (isn't set -e), as it exists to run known possibly-crashing tests to get a log of whether they still fail

arch=$(dpkg --print-architecture)
pys="$(py3versions -s 2>/dev/null)"
sourcetestroot="$PWD/pandas/tests"
# some tests _require_ the treat-warnings-as-errors set here
# (as they use pytest.raises to catch what would normally be a warning)
tomlfile="$PWD/pyproject.toml"

cd "$AUTOPKGTEST_TMP"
TEST_SUCCESS=true
for py in $pys; do
	echo "=== $py ==="
	modpath=$($py -c 'import pandas as pd; print(pd.__path__[0])')
    echo "various xfailed tests"
    # --runxfail not just --xfail-tb to include run=False tests
    # xfail_tests_nonintel_io.patch
    # --forked because this set may _crash_
    PANDAS_RUN_CRASHING_TESTS=1 PANDAS_CI=1 LC_ALL=C.UTF-8 xvfb-run --auto-servernum --server-args="-screen 0 1024x768x24" $py -m pytest --forked -s --deb-data-root-dir=$sourcetestroot  $modpath/tests/io/pytables
    PANDAS_CI=1 LC_ALL=C.UTF-8 xvfb-run --auto-servernum --server-args="-screen 0 1024x768x24" $py -m pytest --runxfail -s -c $tomlfile --deb-data-root-dir=$sourcetestroot $modpath/tests/io/test_stata.py
    # temp_xfails_pandasv3.patch
    PANDAS_CI=1 LC_ALL=C.UTF-8 xvfb-run --auto-servernum --server-args="-screen 0 1024x768x24" $py -m pytest --runxfail -s -c $tomlfile --deb-data-root-dir=$sourcetestroot $modpath/tests/window/test_numba.py $modpath/tests/api/test_api.py
    # tests_dont_assume_64bit.patch
    PANDAS_CI=1 LC_ALL=C.UTF-8 xvfb-run --auto-servernum --server-args="-screen 0 1024x768x24" $py -m pytest --runxfail -s -c $tomlfile --deb-data-root-dir=$sourcetestroot $modpath/tests/test_downstream.py $modpath/tests/groupby/test_groupby.py $modpath/tests/io/test_pickle.py
    echo "pymysql/psycopg2 tests, which do not work in this test environment - --tb=no to fit in the Salsa CI log, as there are many failures"
    PANDAS_CI=1 LC_ALL=C.UTF-8 xvfb-run --auto-servernum --server-args="-screen 0 1024x768x24" $py -m pytest -s --tb=no -c $tomlfile --deb-data-root-dir=$sourcetestroot $modpath/tests/io/test_sql.py $modpath/tests/tools/test_to_datetime.py
done
# this intentionally doesn't actually fail, as it exists to run known possibly-crashing tests to get a log of whether they still fail
true
