38 lines
1.4 KiB
Bash
Executable file
38 lines
1.4 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 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.
|
|
#
|
|
# Usage: scripts/smoke-test.sh [--fresh]
|
|
#
|
|
# Output goes to ${TMPDIR:-/tmp}/swift-gtk-gen-smoke/tier-1 (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"
|
|
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"
|
|
"$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/"
|
|
|
|
echo "==> Running smoke tests against the real C libraries"
|
|
swift test --package-path "$OUT"
|