#! /bin/bash

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

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

# These tests fail inconsistently, for some unknown reason
EXCLUDES=(
    "tests/debugpy/test_attach.py::test_attach_pid_client[program-int]"
    "tests/debugpy/test_attach.py::test_attach_pid_client[program-str]"
)

DESELECTS=()
if [ $origin = 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
