#! /bin/bash

# Many tests fail with Python 3.11.  This script generates appropriate
# code for the pytest call.

# This script is called from both debian/rules and from the
# autopkgtest suite.  Because many of the test exclusions include
# parentheses, any they are called in different ways, we take an
# argument specifying rules or autopkgtest

quoting=$1
if [ "$quoting" != rules ] && [ "$quoting" != autopkgtest ]
then
    echo "Argument must be 'rules' or 'autopkgtest'" >&2
    exit 1
fi

arch=$(dpkg --print-architecture)

EXCLUDES+=(
    "tests/debugpy/test_exception.py::test_systemexit[0-zero-uncaught-raised-attach_listen(api)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[0-zero--raised-attach_connect(api)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[0-zero-uncaught-raised-attach_listen(api)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[0-zero--raised-attach_connect(cli)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[0-zero-uncaught-raised-attach_listen(cli)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[0-zero-uncaught-raised-attach_listen(cli)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[0-zero--raised-attach_connect(cli)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[0-zero-uncaught-raised-attach_connect(api)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[0-zero--raised-attach_pid-program]"
    "tests/debugpy/test_exception.py::test_systemexit[0-zero-uncaught-raised-attach_connect(api)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[0-zero-uncaught-raised-attach_connect(cli)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[0-zero--raised-attach_pid-module]"
    "tests/debugpy/test_exception.py::test_systemexit[0-zero-uncaught-raised-attach_connect(cli)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[0-zero-uncaught-raised-attach_pid-program]"
    "tests/debugpy/test_exception.py::test_systemexit[0-zero-uncaught-raised-attach_pid-module]"
    "tests/debugpy/test_exception.py::test_systemexit[0-zero--raised-launch(console=internalConsole)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[0-zero--raised-launch(console=internalConsole)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[0-zero--raised-launch(console=integratedTerminal)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[0-zero--raised-launch(console=integratedTerminal)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[0-zero--raised-launch(console=externalTerminal)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[0-zero--raised-launch(console=externalTerminal)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[0-zero--raised-attach_listen(api)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[0-zero--raised-attach_listen(api)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[0-zero--raised-attach_listen(cli)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[0-zero--raised-attach_listen(cli)-module]"
    "tests/debugpy/test_exception.py::test_vsc_exception_options_raise_with_except[program-launch-uncaught-raised]"
    "tests/debugpy/test_exception.py::test_systemexit[0-zero--raised-attach_connect(api)-program]"
    "tests/debugpy/test_exception.py::test_vsc_exception_options_raise_with_except[program-launch--raised]"
    "tests/debugpy/test_exception.py::test_vsc_exception_options_raise_without_except[program-launch-uncaught-raised]"
    "tests/debugpy/test_exception.py::test_vsc_exception_options_raise_without_except[program-launch-uncaught-]"
    "tests/debugpy/test_exception.py::test_vsc_exception_options_raise_without_except[program-launch--raised]"
    "tests/debugpy/test_exception.py::test_systemexit[0-zero-uncaught-raised-launch(console=internalConsole)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[0-zero-uncaught-raised-launch(console=internalConsole)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[0-zero-uncaught-raised-launch(console=integratedTerminal)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[0-zero-uncaught-raised-launch(console=integratedTerminal)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[0-zero-uncaught-raised-launch(console=externalTerminal)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[0-zero-uncaught-raised-launch(console=externalTerminal)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[1-zero--raised-attach_connect(api)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[1-zero--raised-attach_connect(cli)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[1-zero--raised-attach_connect(cli)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[nan-zero-uncaught-raised-attach_connect(cli)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[1-zero--raised-attach_pid-program]"
    "tests/debugpy/test_exception.py::test_systemexit[nan-zero-uncaught-raised-attach_connect(cli)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[1-zero--raised-attach_pid-module]"
    "tests/debugpy/test_exception.py::test_systemexit[nan-zero-uncaught-raised-attach_pid-program]"
    "tests/debugpy/test_exception.py::test_systemexit[1-zero-uncaught-raised-launch(console=internalConsole)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[nan-zero-uncaught-raised-attach_pid-module]"
    "tests/debugpy/test_exception.py::test_systemexit[1-zero-uncaught-raised-launch(console=internalConsole)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[1-zero-uncaught-raised-launch(console=integratedTerminal)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[1---raised-launch(console=internalConsole)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[1-zero-uncaught-raised-launch(console=integratedTerminal)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[1---raised-launch(console=internalConsole)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[1-zero-uncaught-raised-launch(console=externalTerminal)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[1---raised-launch(console=integratedTerminal)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[1-zero-uncaught-raised-launch(console=externalTerminal)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[1---raised-launch(console=integratedTerminal)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[1-zero-uncaught-raised-attach_listen(api)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[1---raised-launch(console=externalTerminal)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[1-zero-uncaught-raised-attach_listen(api)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[1-zero-uncaught-raised-attach_listen(cli)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[1---raised-launch(console=externalTerminal)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[1-zero-uncaught-raised-attach_listen(cli)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[1---raised-attach_listen(api)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[1-zero-uncaught-raised-attach_connect(api)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[1---raised-attach_listen(api)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[nan---raised-launch(console=integratedTerminal)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[1---raised-attach_listen(cli)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[1-zero-uncaught-raised-attach_connect(api)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[nan---raised-launch(console=externalTerminal)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[1---raised-attach_listen(cli)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[1-zero-uncaught-raised-attach_connect(cli)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[nan---raised-launch(console=externalTerminal)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[1---raised-attach_connect(api)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[nan---raised-attach_listen(api)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[1-zero-uncaught-raised-attach_connect(cli)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[1---raised-attach_connect(api)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[nan---raised-attach_listen(api)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[nan---raised-attach_listen(cli)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[1---raised-attach_connect(cli)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[1-zero-uncaught-raised-attach_pid-program]"
    "tests/debugpy/test_exception.py::test_systemexit[nan---raised-attach_listen(cli)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[1---raised-attach_connect(cli)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[nan--uncaught-raised-launch(console=internalConsole)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[1-zero-uncaught-raised-attach_pid-module]"
    "tests/debugpy/test_exception.py::test_systemexit[nan---raised-attach_connect(api)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[nan--uncaught-raised-launch(console=internalConsole)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[1---raised-attach_pid-program]"
    "tests/debugpy/test_exception.py::test_systemexit[nan---raised-attach_connect(api)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[nan--uncaught-raised-launch(console=integratedTerminal)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[nan---raised-attach_connect(cli)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[nan--uncaught-raised-launch(console=integratedTerminal)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[1---raised-attach_pid-module]"
    "tests/debugpy/test_exception.py::test_systemexit[nan---raised-attach_connect(cli)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[nan--uncaught-raised-launch(console=externalTerminal)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[nan--uncaught-raised-launch(console=externalTerminal)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[nan---raised-attach_pid-program]"
    "tests/debugpy/test_exception.py::test_systemexit[nan--uncaught-raised-attach_listen(api)-program]"
    "tests/debugpy/test_exception.py::test_raise_exception_options[program-launch-exceptions3-always]"
    "tests/debugpy/test_exception.py::test_systemexit[nan--uncaught-raised-attach_listen(api)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[nan---raised-attach_pid-module]"
    "tests/debugpy/test_exception.py::test_systemexit[nan--uncaught-raised-attach_listen(cli)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[nan--uncaught-raised-attach_listen(cli)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[nan--uncaught-raised-attach_connect(api)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[nan--uncaught-raised-attach_connect(api)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[nan--uncaught-raised-attach_connect(cli)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[nan--uncaught-raised-attach_connect(cli)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[nan--uncaught-raised-attach_pid-program]"
    "tests/debugpy/test_exception.py::test_systemexit[nan--uncaught-raised-attach_pid-module]"
    "tests/debugpy/test_exception.py::test_systemexit[1--uncaught-raised-launch(console=internalConsole)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[1--uncaught-raised-launch(console=internalConsole)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[1--uncaught-raised-launch(console=integratedTerminal)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[nan-zero--raised-launch(console=internalConsole)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[1--uncaught-raised-launch(console=integratedTerminal)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[nan-zero--raised-launch(console=internalConsole)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[1--uncaught-raised-launch(console=externalTerminal)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[nan-zero--raised-launch(console=integratedTerminal)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[1--uncaught-raised-launch(console=externalTerminal)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[nan-zero--raised-launch(console=integratedTerminal)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[1--uncaught-raised-attach_listen(api)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[nan-zero--raised-launch(console=externalTerminal)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[1--uncaught-raised-attach_listen(api)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[nan-zero--raised-launch(console=externalTerminal)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[1--uncaught-raised-attach_listen(cli)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[nan-zero--raised-attach_listen(api)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[1--uncaught-raised-attach_listen(cli)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[nan-zero--raised-attach_listen(api)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[1--uncaught-raised-attach_connect(api)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[nan-zero--raised-attach_listen(cli)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[nan-zero--raised-attach_listen(cli)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[1--uncaught-raised-attach_connect(api)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[nan-zero--raised-attach_connect(api)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[1--uncaught-raised-attach_connect(cli)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[nan-zero--raised-attach_connect(api)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[1--uncaught-raised-attach_connect(cli)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[nan-zero--raised-attach_connect(cli)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[1--uncaught-raised-attach_pid-program]"
    "tests/debugpy/test_exception.py::test_systemexit[nan-zero--raised-attach_connect(cli)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[1--uncaught-raised-attach_pid-module]"
    "tests/debugpy/test_exception.py::test_systemexit[nan-zero--raised-attach_pid-program]"
    "tests/debugpy/test_exception.py::test_systemexit[1-zero--raised-launch(console=internalConsole)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[nan-zero--raised-attach_pid-module]"
    "tests/debugpy/test_exception.py::test_systemexit[1-zero--raised-launch(console=internalConsole)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[1-zero--raised-launch(console=integratedTerminal)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[nan-zero-uncaught-raised-launch(console=internalConsole)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[1-zero--raised-launch(console=integratedTerminal)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[nan-zero-uncaught-raised-launch(console=internalConsole)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[1-zero--raised-launch(console=externalTerminal)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[nan-zero-uncaught-raised-launch(console=integratedTerminal)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[1-zero--raised-launch(console=externalTerminal)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[nan-zero-uncaught-raised-launch(console=integratedTerminal)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[1-zero--raised-attach_listen(api)-program]"
    "tests/debugpy/test_exception.py::test_raise_exception_options[program-launch-exceptions0-always]"
    "tests/debugpy/test_exception.py::test_systemexit[nan-zero-uncaught-raised-launch(console=externalTerminal)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[1-zero--raised-attach_listen(api)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[1-zero--raised-attach_listen(cli)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[nan-zero-uncaught-raised-launch(console=externalTerminal)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[1-zero--raised-attach_listen(cli)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[nan-zero-uncaught-raised-attach_listen(api)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[nan-zero-uncaught-raised-attach_listen(api)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[1-zero--raised-attach_connect(api)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[nan-zero-uncaught-raised-attach_listen(cli)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[nan-zero-uncaught-raised-attach_listen(cli)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[nan-zero-uncaught-raised-attach_connect(api)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[nan-zero-uncaught-raised-attach_connect(api)-module]"
    "tests/debugpy/test_exception.py::test_raise_exception_options[program-launch-exceptions1-always]"
    "tests/debugpy/test_exception.py::test_systemexit[nan---raised-launch(console=internalConsole)-program]"
    "tests/debugpy/test_exception.py::test_systemexit[nan---raised-launch(console=internalConsole)-module]"
    "tests/debugpy/test_exception.py::test_systemexit[nan---raised-launch(console=integratedTerminal)-program]"
    "tests/debugpy/test_exception.py::test_exception_stack[program-launch-default]"
    "tests/debugpy/test_exception.py::test_raise_exception_options[program-launch-exceptions2-always]"
    "tests/debugpy/test_exception.py::test_exception_stack[program-launch-all]"
    "tests/debugpy/test_exception.py::test_exception_stack[program-launch-10]"
    "tests/debugpy/test_django.py::test_django_breakpoint_no_multiproc[launch-code]"
    "tests/debugpy/test_exclude_rules.py::test_exceptions_and_partial_exclude_rules[program-launch-exclude_code_to_debug]"
    "tests/debugpy/test_exclude_rules.py::test_exceptions_and_partial_exclude_rules[program-launch-exclude_callback_dir]"
    "tests/debugpy/test_exclude_rules.py::test_exceptions_and_partial_exclude_rules[module-launch-exclude_code_to_debug]"
    "tests/debugpy/test_exclude_rules.py::test_exceptions_and_partial_exclude_rules[module-launch-exclude_callback_dir]"
    "tests/debugpy/test_run.py::test_frame_eval[-module-launch(console=internalConsole)]"
    "tests/debugpy/test_run.py::test_frame_eval[-module-launch(console=integratedTerminal)]"
    "tests/debugpy/test_run.py::test_frame_eval[-code-attach_listen(cli)]"
    "tests/debugpy/test_run.py::test_frame_eval[-module-launch(console=externalTerminal)]"
    "tests/debugpy/test_run.py::test_frame_eval[-code-attach_connect(api)]"
    "tests/debugpy/test_run.py::test_frame_eval[-module-attach_listen(api)]"
    "tests/debugpy/test_run.py::test_frame_eval[-module-attach_listen(cli)]"
    "tests/debugpy/test_run.py::test_frame_eval[-code-attach_connect(cli)]"
    "tests/debugpy/test_run.py::test_frame_eval[-module-attach_connect(api)]"
    "tests/debugpy/test_run.py::test_frame_eval[-code-attach_pid]"
    "tests/debugpy/test_run.py::test_frame_eval[-module-attach_connect(cli)]"
    "tests/debugpy/test_run.py::test_frame_eval[-module-attach_pid]"
    "tests/debugpy/test_run.py::test_frame_eval[-code-launch(console=internalConsole)]"
    "tests/debugpy/test_run.py::test_frame_eval[-code-launch(console=integratedTerminal)]"
    "tests/debugpy/test_run.py::test_frame_eval[-code-launch(console=externalTerminal)]"
    "tests/debugpy/test_run.py::test_frame_eval[-code-attach_listen(api)]"
    "tests/debugpy/test_run.py::test_frame_eval[-program-launch(console=internalConsole)]"
    "tests/debugpy/test_run.py::test_frame_eval[-program-launch(console=integratedTerminal)]"
    "tests/debugpy/test_run.py::test_frame_eval[-program-launch(console=externalTerminal)]"
    "tests/debugpy/test_run.py::test_frame_eval[-program-attach_listen(api)]"
    "tests/debugpy/test_run.py::test_frame_eval[-program-attach_listen(cli)]"
    "tests/debugpy/test_run.py::test_frame_eval[-program-attach_connect(api)]"
    "tests/debugpy/test_run.py::test_frame_eval[-program-attach_connect(cli)]"
    "tests/debugpy/test_run.py::test_frame_eval[-program-attach_pid]"
    "tests/debugpy/test_flask.py::test_flask_template_exception_no_multiproc[launch]"
    "tests/debugpy/test_flask.py::test_flask_exception_no_multiproc[launch-handled]"
    "tests/debugpy/test_flask.py::test_flask_exception_no_multiproc[launch-unhandled]"
    "tests/debugpy/test_django.py::test_django_breakpoint_no_multiproc[launch-template]"
    "tests/debugpy/test_django.py::test_django_exception_no_multiproc[launch-handled]"
    "tests/debugpy/test_django.py::test_django_exception_no_multiproc[launch-unhandled]"
    "tests/debugpy/test_django.py::test_django_template_exception_no_multiproc[launch]"
    "tests/debugpy/test_django.py::test_django_breakpoint_multiproc[launch]"
)

DESELECTS=()
if [ $quoting = rules ]
then
    for test in "${EXCLUDES[@]}"
    do
        DESELECTS+=("--deselect='$test'")
    done
    echo ${DESELECTS[*]}
else
    for test in "${EXCLUDES[@]}"
    do
        DESELECTS+=("--deselect=$test")
    done
    echo "${DESELECTS[*]}"
fi
