#!/bin/sh
# verify every installed deimos.openssl.*.di module can be
# imported and type-checked cleanly. This is a broad smoke test for the
# upstream .d -> .di rename in 3.4.0: it catches typos in module names,
# broken imports, or a file that was dropped/renamed inconsistently,
# across all ~78 bindings at once, not just the couple exercised by
# build-and-link.

set -e

INCDIR=/usr/include/d/common
MODDIR="$INCDIR/deimos/openssl"
test -d "$MODDIR"

WORKDIR="${AUTOPKGTEST_TMP:-$(mktemp -d)}"
GEN="$WORKDIR/import_all.d"

{
    for f in "$MODDIR"/*.di; do
        mod=$(basename "$f" .di)
        [ "$mod" = "applink" ] && continue
        echo "import deimos.openssl.${mod};"
    done
    echo "void main() {}"
} > "$GEN"

gdc -I"$INCDIR" -fsyntax-only "$GEN"
echo "OK: all installed deimos.openssl.* modules (except Windows-only applink) imported cleanly"
