#!/bin/sh
# Copyright © 2016-2018 Simon McVittie
# Copyright © 2018-2019 Collabora Ltd.
# SPDX-License-Identifier: BSD-3-Clause

set -e
set -u

if [ -z "${G_TEST_SRCDIR-}" ]; then
    me="$(readlink -f "$0")"
    G_TEST_SRCDIR="${me%/*}"
fi

cd "$G_TEST_SRCDIR/.."

export MYPYPATH="${PYTHONPATH:=$(pwd)}"

i=0
for script in \
    abi/*.py \
    tests/*.py \
    tests/platform/*.py \
    tests/sdk/*.py \
; do
    i=$((i + 1))
    if [ "${MYPY:="$(command -v mypy || echo false)"}" = false ]; then
        echo "ok $i - $script # SKIP mypy not found"
    elif "${MYPY}" \
            --python-executable="${PYTHON:=python3}" \
            --follow-imports=skip \
            --ignore-missing-imports \
            "$script" >&2; then
        echo "ok $i - $script"
    else
        echo "not ok $i - $script # TODO mypy issues reported"
    fi
done
echo "1..$i"

# vim:set sw=4 sts=4 et:
