#!/bin/sh

set -e

# Change directory to the root of the project (assuming script is in debian/tests/)
cd "$(dirname "$0")/../.."

CONTROL_FILE="debian/tests/control"

TEST_FILES="
tests/bindings/test_decoders.py
tests/bindings/test_encoding.py
tests/bindings/test_models.py
tests/bindings/test_normalizers.py
tests/bindings/test_pre_tokenizers.py
tests/bindings/test_processors.py
tests/bindings/test_tokenizer.py
tests/documentation/test_pipeline.py
tests/documentation/test_quicktour.py
tests/implementations/test_base_tokenizer.py
tests/implementations/test_bert_wordpiece.py
tests/implementations/test_byte_level_bpe.py
tests/implementations/test_char_bpe.py
tests/implementations/test_sentencepiece.py
"

> "$CONTROL_FILE"

for f in $TEST_FILES; do
    test_name=$(basename "$f" .py | tr '_' '-')
    cat >> "$CONTROL_FILE" << EOF
Test-Command: cd bindings/python/ ; HOME=\$AUTOPKGTEST_TMP pytest-3 -v $f
Depends: python3-numpy,
         python3-pytest,
         python3-pytest-env,
         python3-pytest-mock,
         python3-pytest-asyncio,
         python3-requests,
         @
Restrictions: allow-stderr
Features: test-name=pytest-$test_name
EOF
    if [ "$f" = "tests/bindings/test_tokenizer.py" ]; then
        echo "Architecture: !armhf !i386" >> "$CONTROL_FILE"
    fi
    echo "" >> "$CONTROL_FILE"
done

echo "Successfully generated $CONTROL_FILE"
