1
0
Fork 0

Tier 2 compile-gate compliance: interfaces, cross-module refs, Gio

This commit is contained in:
Brendan Szymanski 2026-07-19 00:27:08 -04:00
parent 5abb48e889
commit 0504b34d7f
18 changed files with 9186 additions and 304 deletions

View file

@ -2,30 +2,49 @@
# smoke-test.sh — runtime smoke tests for the generated bindings.
#
# The compile gate proves the generated Swift type-checks. This goes further:
# it generates the tier-1 bindings, links them against the REAL C libraries via
# pkg-config, and runs hand-written swift-testing cases (smoke/*.swift) that
# invoke real GLib/GObject functionality through the wrappers and check the
# results at runtime.
# it generates a tier's bindings, links them against the REAL C libraries via
# pkg-config, and runs hand-written swift-testing cases (smoke/*.swift, plus
# smoke/tier<N>/*.swift for tier N ≥ 2) that invoke real GLib/GObject/Gio
# functionality through the wrappers and check the results at runtime.
#
# Usage: scripts/smoke-test.sh [--fresh]
# Usage: scripts/smoke-test.sh [tier] [--fresh]
#
# Output goes to ${TMPDIR:-/tmp}/swift-gtk-gen-smoke/tier-1 (a stable path so
# tier 1..6 (default 1). tier1 = GLib+GObject, tier2 = +GModule+Gio, …
# --fresh wipe the tier's output directory before generating
#
# Output goes to ${TMPDIR:-/tmp}/swift-gtk-gen-smoke/tier-<N> (a stable path so
# incremental swift builds stay fast between runs).
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
OUT="${TMPDIR:-/tmp}/swift-gtk-gen-smoke/tier-1"
CONFIG="$ROOT/configs/tier1.toml"
[[ "${1:-}" == "--fresh" ]] && rm -rf "$OUT"
TIER="1"
FRESH=0
for arg in "$@"; do
if [[ "$arg" == "--fresh" ]]; then
FRESH=1
else
TIER="$arg"
fi
done
CONFIG="$ROOT/configs/tier${TIER}.toml"
OUT="${TMPDIR:-/tmp}/swift-gtk-gen-smoke/tier-${TIER}"
if [[ ! -f "$CONFIG" ]]; then
echo "!! missing $CONFIG" >&2
exit 2
fi
[[ "$FRESH" == 1 ]] && rm -rf "$OUT"
mkdir -p "$OUT"
echo "==> Building generator"
swift build --package-path "$ROOT"
BIN="$(swift build --package-path "$ROOT" --show-bin-path)/swift-gtk-gen"
echo "==> Generating bindings (with SmokeTests target) into $OUT"
echo "==> Generating tier $TIER bindings (with SmokeTests target) into $OUT"
"$BIN" --monorepo-config "$CONFIG" --output "$OUT" --smoke-target >"$OUT/generate.log" 2>&1
echo "==> Installing smoke tests"
@ -33,6 +52,11 @@ mkdir -p "$OUT/Tests/SmokeTests"
# Refresh so edits to smoke/*.swift always take effect.
rm -f "$OUT/Tests/SmokeTests/"*.swift
cp "$ROOT/smoke/"*.swift "$OUT/Tests/SmokeTests/"
# Tier-specific smoke cases (e.g. smoke/tier2/*.swift exercises Gio) are only
# installed — and only need to compile — for tiers that generate their deps.
if [[ -d "$ROOT/smoke/tier${TIER}" ]]; then
cp "$ROOT/smoke/tier${TIER}/"*.swift "$OUT/Tests/SmokeTests/"
fi
echo "==> Running smoke tests against the real C libraries"
swift test --package-path "$OUT"