Skip to content

Commit 78a7424

Browse files
ElleNajtclaude
andcommitted
Normalize test output for cross-platform consistency
The test comparison now strips platform-specific differences: - Carriage returns (\r) that appear in macOS pandoc output - Trailing empty columns like "| \r |" or "| |" from org tables This fixes CI failures where macOS-generated golden files differ from Linux test output due to line ending handling in pandoc. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent f07c671 commit 78a7424

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

tests/run_expect_tests.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,15 @@ compare_test() {
114114
has_failure=1
115115
difference="No golden file found for test ${test_name}"
116116
else
117-
staging_test=$(echo "$staging_results" | jq --arg name "$test_name" 'fromjson | .[$name] | with_entries(select(.value | type == "string" and (contains(".png") | not)))')
118-
golden_test=$(cat "golden/${test_name}.json" | jq 'with_entries(select(.value | type == "string" and (contains(".png") | not)))')
117+
# Normalize function to remove platform-specific differences:
118+
# - Remove \r characters (carriage returns from macOS)
119+
# - Remove trailing empty columns like "| \r |" or "| |" from org tables
120+
normalize_filter='with_entries(
121+
select(.value | type == "string" and (contains(".png") | not)) |
122+
.value |= (gsub("\\| \\\\r \\|$"; "|") | gsub("\\| \\|$"; "|") | gsub("\\\\r"; ""))
123+
)'
124+
staging_test=$(echo "$staging_results" | jq --arg name "$test_name" "fromjson | .[\$name] | $normalize_filter")
125+
golden_test=$(cat "golden/${test_name}.json" | jq "$normalize_filter")
119126

120127
# Compare non-PNG content
121128
if [ "$(echo "$golden_test" | jq -S .)" != "$(echo "$staging_test" | jq -S .)" ]; then

0 commit comments

Comments
 (0)