#!/bin/sh
set -eu

script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
src=$(CDPATH= cd -- "$script_dir/../.." && pwd)
build="$AUTOPKGTEST_TMP/sonivox-tests"

mkdir -p "$AUTOPKGTEST_TMP/tmp"
export TEMP="$AUTOPKGTEST_TMP/tmp"
export TEST_RESOURCES="$src/test/res"

cmake -S "$src" -B "$build" -DBUILD_TESTING=ON
cmake --build "$build" --parallel 2 2>&1
ctest --test-dir "$build" --output-on-failure
