Fix validation script to tolerate expected TS7 kind/flags diffsTS5

The shell validation script now uses a structural comparison that
ignores expected numeric differences in kind/flags/token/operator
values between TS5 and TS7. Only truly structural diffs cause failure.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Asger F
2026-04-10 14:54:19 +02:00
parent f3b27a56b1
commit 93deb33a2a

View File

@@ -152,20 +152,58 @@ compare_output() {
}
if [ "$nodejs_norm" = "$go_norm" ]; then
echo -e " ${GREEN}PASS${NC} $basename"
echo -e " ${GREEN}PASS${NC} $basename (exact match)"
PASS=$((PASS + 1))
else
echo -e " ${RED}FAIL${NC} $basename"
FAIL=$((FAIL + 1))
# Check if differences are only expected TS5↔TS7 numeric kind/flags/token/operator values
local structural_diffs
structural_diffs=$(python3 -c "
import json, sys
NUMERIC_VALUE_KEYS = {'kind', 'flags', 'token', 'operator'}
def count_structural(a, b, path='root'):
count = 0
if isinstance(a, dict) and isinstance(b, dict):
keys = set(a) | set(b)
for k in keys:
if k not in a or k not in b:
count += 1
else:
count += count_structural(a[k], b[k], path + '.' + k)
elif isinstance(a, list) and isinstance(b, list):
if len(a) != len(b):
return 1
for i in range(len(a)):
count += count_structural(a[i], b[i], f'{path}[{i}]')
elif a != b:
key = path.rsplit('.', 1)[-1] if '.' in path else path
if key in NUMERIC_VALUE_KEYS and isinstance(a, (int, float)) and isinstance(b, (int, float)):
return 0
count = 1
return count
a = json.loads(sys.argv[1])
b = json.loads(sys.argv[2])
print(count_structural(a, b))
" "$nodejs_norm" "$go_norm" 2>/dev/null) || structural_diffs="?"
if [ "$structural_diffs" = "0" ]; then
echo -e " ${GREEN}PASS${NC} $basename (only expected TS5↔TS7 kind/flags diffs)"
PASS=$((PASS + 1))
else
echo -e " ${RED}FAIL${NC} $basename ($structural_diffs structural diff(s))"
FAIL=$((FAIL + 1))
# Save outputs for inspection
local outdir="$PROJECT_DIR/validation-output"
mkdir -p "$outdir"
echo "$nodejs_norm" > "$outdir/${basename}.nodejs.json"
echo "$go_norm" > "$outdir/${basename}.go.json"
# Save outputs for inspection
local outdir="$PROJECT_DIR/validation-output"
mkdir -p "$outdir"
echo "$nodejs_norm" > "$outdir/${basename}.nodejs.json"
echo "$go_norm" > "$outdir/${basename}.go.json"
# Show first few lines of diff
diff <(echo "$nodejs_norm") <(echo "$go_norm") | head -30 || true
# Show first few lines of diff
diff <(echo "$nodejs_norm") <(echo "$go_norm") | head -30 || true
fi
fi
}