Generate class methods and constructors with runtime smoke tests
This commit is contained in:
parent
56de5bc976
commit
144da7860e
9 changed files with 673 additions and 115 deletions
38
scripts/smoke-test.sh
Executable file
38
scripts/smoke-test.sh
Executable file
|
|
@ -0,0 +1,38 @@
|
|||
#!/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"
|
||||
Loading…
Add table
Add a link
Reference in a new issue