62 lines
2.1 KiB
Bash
Executable file
62 lines
2.1 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# smoke-test.sh — runtime smoke tests for the generated bindings.
|
|
#
|
|
# The compile gate proves the generated Swift type-checks. This goes further:
|
|
# 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 [tier] [--fresh]
|
|
#
|
|
# 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}/gobject-generator-smoke/tier-<N> (a stable path so
|
|
# incremental swift builds stay fast between runs).
|
|
|
|
set -euo pipefail
|
|
|
|
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
|
|
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}/gobject-generator-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)/generator"
|
|
|
|
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"
|
|
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"
|