#!/bin/bash
# Run the test suite against the host platform's keyring.
set -euo pipefail
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd "$SCRIPTDIR/.."

FEATURES=()
if [ "$(uname -s)" == "Darwin" ]; then
    # Tests run against a throwaway keychain instead of the developer's login keychain.
    FEATURES=(--features macos-specify-keychain)
fi

if cargo nextest --version >/dev/null 2>&1; then
    exec cargo nextest run --profile ci "${FEATURES[@]}" "$@"
fi

echo "cargo-nextest not found, falling back to cargo test" >&2
# The platform and insecure suites share the system keyring, so never run them in parallel.
exec cargo test "${FEATURES[@]}" "$@" -- --test-threads=1
