Files
fpc-msgbase/run_tests.sh
Ken Johnson d7e58932e9 Phase 4: kludge round-trip + cross-format capability tests
Adds tests/test_roundtrip_attrs.pas covering:

1. Capabilities API smoke test — confirms SupportsAttribute('msgid')
   returns true on JAM/Squish/MSG/PKT, false on Hudson/GoldBase/
   EzyCom/Wildcat/PCBoard. Confirms backend-private keys are gated
   correctly (Squish.SupportsAttribute('jam.msgidcrc') = false).

2. Per-format kludge round-trip across all 5 storage formats —
   builds a synthetic message with universal headers + FTSC kludges
   (msgid, replyid, pid, flags, multi-line seen-by + path), writes,
   reopens, reads back, asserts every key the backend's capability
   list advertises survives byte-for-byte. Backends that don't
   support a given key are silently skipped via SupportsAttribute
   gating so the test exercises each format's actual contract.

3. Cross-format JAM → Squish copy — seeds JAM with the kludge
   message, copies to a fresh Squish base via the unified API,
   reopens both, asserts:
   - intersection of capabilities lists is preserved verbatim
     (msgid, seen-by, path, etc. all survive JAM → Squish)
   - jam.* keys not in Squish's capability list are dropped
     (no silent corruption of Squish's data with foreign keys)

Result: 7/7 new tests pass. Total suite now 31/31 across 8 programs.
This is the regression suite that locks the Body+Attributes contract
and proves the showstopper fix holds across every backend.

Hooked into run_tests.sh so CI catches future drift.
2026-04-17 14:32:38 -07:00

62 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
#
# run_tests.sh - build and run every test against the native
# x86_64-linux target. Tests that don't need network / FS features
# that are linux-specific should also work on other native hosts,
# but we only run them here.
#
# Exits non-zero on any failure.
set -e
FPCNATIVE=/opt/fpcup/fpc/bin/x86_64-linux/fpc
TGT=x86_64-linux
cd "$(dirname "$0")"
mkdir -p "units/$TGT" "exe/$TGT"
compile() {
local src=$1
echo " compile $(basename "$src")"
"$FPCNATIVE" -Mobjfpc -Sh -Sgic \
-Fusrc -Fusrc/formats -Fusrc/wc_sdk -Futests \
-FUunits/"$TGT" -FEexe/"$TGT" \
"$src" >/tmp/ma_test_build.$$.log 2>&1 || {
cat /tmp/ma_test_build.$$.log
rm -f /tmp/ma_test_build.$$.log
exit 1
}
rm -f /tmp/ma_test_build.$$.log
}
run() {
local name=$1
echo " run $name"
rm -rf "/tmp/ma_$name"
"./exe/$TGT/$name"
}
echo "Building tests..."
compile tests/test_read.pas
compile tests/test_roundtrip.pas
compile tests/test_roundtrip_attrs.pas
compile tests/test_lock.pas
compile tests/test_batch.pas
compile tests/test_wildcat.pas
compile tests/test_write_existing.pas
compile tests/test_pack.pas
echo
echo "Running tests..."
run test_read
run test_roundtrip
run test_roundtrip_attrs
run test_lock
run test_batch
run test_wildcat
run test_write_existing
run test_pack
echo
echo "All tests passed."