From 3a396b8901a9940693d3bff7c16a94b1ed1bffa7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 26 Mar 2026 05:14:48 +0000 Subject: [PATCH] fix: normalize heredoc delimiters in wasm golden test script Agent-Logs-Url: https://github.com/github/gh-aw/sessions/4d02a46e-606f-41a0-af35-d8f93d7b2106 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- scripts/test-wasm-golden.mjs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/scripts/test-wasm-golden.mjs b/scripts/test-wasm-golden.mjs index 43ec1e60ad2..eb325c32e44 100644 --- a/scripts/test-wasm-golden.mjs +++ b/scripts/test-wasm-golden.mjs @@ -131,6 +131,15 @@ function loadFixtures() { })); } +// ── Normalize heredoc delimiters ───────────────────────────────────── +// Replaces randomized heredoc delimiter tokens (e.g. GH_AW_PROMPT_4e0413dfda20da69_EOF) +// with a stable placeholder so that wasm output and golden files compare equal even +// though each compilation embeds different (or seeded) hex tokens. +// Mirrors normalizeHeredocDelimiters() in pkg/workflow/compiler.go. +function normalizeHeredocDelimiters(content) { + return content.replace(/GH_AW_([A-Z0-9_]+)_[0-9a-f]{16}_EOF/g, "GH_AW_$1_NORM_EOF"); +} + // ── Load golden file ───────────────────────────────────────────────── function loadGoldenFile(testName) { // Golden files follow the charmbracelet/x/exp/golden convention: @@ -213,15 +222,18 @@ async function main() { continue; } - if (wasmYaml === goldenYaml) { + const normalizedWasm = normalizeHeredocDelimiters(wasmYaml); + const normalizedGolden = normalizeHeredocDelimiters(goldenYaml); + + if (normalizedWasm === normalizedGolden) { console.log("PASS"); passed++; } else { console.log("FAIL (output differs from golden)"); // Find first difference - const wasmLines = wasmYaml.split("\n"); - const goldenLines = goldenYaml.split("\n"); + const wasmLines = normalizedWasm.split("\n"); + const goldenLines = normalizedGolden.split("\n"); for ( let i = 0; i < Math.min(wasmLines.length, goldenLines.length);