Adds the per-user High-Water Mark API to TMessageBase:
function SupportsHWM: boolean;
function GetHWM(const UserName: AnsiString): longint;
procedure SetHWM(const UserName: AnsiString; MsgNum: longint);
procedure MapUser(const UserName: AnsiString; UserId: longint);
property ActiveUser: AnsiString;
GetHWM returns -1 when the format has no HWM mechanism, the user
isn't registered (number-keyed formats), or no HWM has been set
for that user yet.
Two-flavour native dispatch:
- Name-keyed backends (JAM, later Squish/Wildcat) override
DoGetHWMByName / DoSetHWMByName.
- Number-keyed backends (later Hudson/GoldBase/EzyCom) override
DoGetHWMById / DoSetHWMById; caller must register name->id via
MapUser first.
Auto-bump: when ActiveUser is non-empty, ReadMessage compares the
just-read msg.num to GetHWM(ActiveUser); if higher, calls SetHWM.
Never decrements -- reading a lower-numbered message is a no-op.
Default off (ActiveUser = '').
JAM implementation:
- Adds .JLR (lastread) handling to TJamBase: lazy open via
EnsureLrStream, GetLastRead/GetHighRead/SetLastRead methods,
proper Close cleanup.
- TJamMessageBase wires DoGetHWMByName / DoSetHWMByName to
CalcUserCRC + GetLastRead / SetLastRead. SetHWM also keeps
HighReadMsg monotonic.
Coverage map (this milestone):
- JAM: native ✓
- Squish, Hudson, GoldBase, EzyCom, Wildcat: -1 (planned 0.3.1/2)
- PCBoard, MSG, PKT: -1 (no HWM in spec)
Tests: tests/test_hwm.pas covers SupportsHWM, set/get round-trip,
persistence across Open/Close, auto-bump via ActiveUser (advances),
auto-bump never decrements, MSG/PKT correctly return -1, Hudson
returns -1 even after MapUser (until 0.3.1 lands the impl). 7/7
new tests pass; full suite 38/38 across 9 programs.
Recommended caller pattern:
base.ActiveUser := 'NetReader';
for i := 0 to base.MessageCount - 1 do begin
base.ReadMessage(i, msg);
{ process msg ... HWM auto-tracks the high-water for NetReader }
end;
64 lines
1.4 KiB
Bash
Executable File
64 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
|
|
compile tests/test_hwm.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
|
|
run test_hwm
|
|
|
|
echo
|
|
echo "All tests passed."
|