#!/bin/sh
# Copyright © 2018-2023 Collabora Ltd
# SPDX-License-Identifier: MIT

set -eu

if ! command -v shellcheck >/dev/null 2>&1; then
    echo "1..0 # SKIP shellcheck not available"
    exit 0
fi

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

cd "$G_TEST_SRCDIR/.."
echo "TAP version 13"

n=0
for shell_script in \
        debian/tests/cross-sdk \
        debian/tests/platform \
        debian/tests/sdk \
        debian/tests/steamrt-crossbuild-* \
        hooks/platform-pre-apt.d/* \
        hooks/runtime.d/* \
        hooks/sdk.d/* \
        tests/*.sh \
        tests/cross-sdk/*.t \
        tests/platform/*.t \
        tests/sdk/*.t \
        ; do
    n=$((n + 1))

    if shellcheck "$shell_script" >&2; then
        echo "ok $n - $shell_script"
    elif [ -n "${LINT_WARNINGS_ARE_ERRORS-}" ]; then
        echo "not ok $n - $shell_script"
    else
        echo "not ok $n # TO""DO - $shell_script"
    fi
done

echo "1..$n"
