#!/bin/sh
set -eu

# The `build-needed` restriction builds the package and leaves the build
# directory as `obj-$(DEB_HOST_GNU_TYPE)`.
#
# Running `meson test` in the build directory exercises the package against the
# archive versions of its build dependencies which can help catch regressions
# from library, compiler or toolchain migrations.

BUILD_DIR="obj-$(dpkg-architecture -qDEB_HOST_GNU_TYPE)"

# autopkgtest builds the package with the `nocheck` profile, for which
# debian/rules disables the unit tests. Enable them again; `meson test` then
# builds them before running the suite.
meson configure "$BUILD_DIR" -Dtests=enabled

meson test \
    -C "$BUILD_DIR" \
    --print-errorlogs
