Add wasm compiler integration tests with golden file comparison#16643
Add wasm compiler integration tests with golden file comparison#16643
Conversation
Add a comprehensive test suite to verify the wasm compiler produces correct YAML output by comparing against golden files. ## What's included ### Go golden tests (pkg/workflow/wasm_golden_test.go) - TestWasmGolden_CompileFixtures: Compiles 16 workflow fixtures via the string API (same code path as wasm) and compares against golden files - TestWasmGolden_CompileWithImports: Tests import resolution via filesystem - TestWasmGolden_RoundTrip: Verifies compilation determinism (3 runs) - TestWasmGolden_NativeVsStringAPI: Informational comparison of native vs string API output, logging differences without failing - TestWasmGolden_AllEngines: Verifies copilot, claude, codex engines compile ### Test fixtures (16 workflows covering) - All 3 engine types (copilot, claude, codex) - Multiple trigger types (workflow_dispatch, issues, push, PR, schedule) - Tool configurations, safe-outputs, permissions, expressions, imports - Network configurations, strict mode, dispatch inputs ### Node.js wasm binary test (scripts/test-wasm-golden.mjs) - Builds the actual wasm binary, loads in Node.js, compiles fixtures - Compares wasm binary output against Go golden files ### Makefile targets - make test-wasm-golden: Run Go golden tests - make test-wasm: Build wasm + run Node.js comparison - make update-wasm-golden: Regenerate golden files ### CI integration - Added golden test + Node.js wasm test steps to build-wasm CI job Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive golden-file integration tests for the wasm compiler to verify YAML output correctness. The implementation includes both Go-level string API tests and Node.js-level wasm binary tests, covering 16 workflow fixtures across 3 engine types (copilot, claude, codex) with various configurations.
Changes:
- Added Go test suite (
wasm_golden_test.go) with 5 test functions covering compilation, imports, determinism, API comparison, and all engines - Created Node.js test runner (
test-wasm-golden.mjs) for wasm binary validation against golden files - Added 16 test fixtures covering different engines, triggers, and features (tools, safe-outputs, permissions, imports, expressions, strict mode)
- Integrated tests into Makefile with new targets (
test-wasm-golden,update-wasm-golden,test-wasm) and CI pipeline
Reviewed changes
Copilot reviewed 38 out of 38 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
pkg/workflow/wasm_golden_test.go |
Main Go test suite with 5 test functions for wasm compiler validation |
scripts/test-wasm-golden.mjs |
Node.js script to test actual wasm binary output against golden files |
pkg/parser/virtual_fs_test_helpers.go |
Test helper for overriding file reading function |
pkg/workflow/testdata/wasm_golden/fixtures/*.md |
16 workflow fixtures covering various engine types, triggers, and features |
pkg/workflow/testdata/wasm_golden/fixtures/shared/tools.md |
Shared import fixture for testing import resolution |
pkg/workflow/testdata/wasm_golden/TestWasmGolden_CompileFixtures/*.golden |
Golden output files for each fixture |
Makefile |
Added test targets for wasm golden tests and updated help documentation |
.github/workflows/ci.yml |
Integrated wasm golden tests into CI pipeline |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Go 1.24+ moved wasm_exec.js from misc/wasm/ to lib/wasm/. Update the test script to check lib/wasm/ first with fallback to misc/wasm/ for older Go versions, matching the pattern already used in bundle-wasm-docs.sh. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…orts - Wasm API: accept optional filename parameter (3rd arg) so GH_AW_WORKFLOW_FILE matches golden files - JS test: pass fixture filename and virtual files for import resolution - Lint: remove unused abs() function, add nolint for golden comparison (exact string match is intentional for golden tests) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@copilot keep working |
|
🧪 Smoke Project is now testing project operations... |
|
✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟 |
|
📰 BREAKING: Smoke Copilot is now investigating this pull request. Sources say the story is developing... |
|
💫 TO BE CONTINUED... Smoke Claude failed! Our hero faces unexpected challenges... |
|
🧪 Smoke Temporary ID is now testing temporary ID functionality... |
|
❌ Smoke Temporary ID encountered failures. Check the logs for details. |
|
📰 DEVELOPING STORY: Smoke Copilot reports failed. Our correspondents are investigating the incident... |
|
✅ Smoke Project completed successfully. All project operations validated. |
|
Smoke test summary
|
Summary
What's included
Go golden tests (
pkg/workflow/wasm_golden_test.go)TestWasmGolden_CompileFixturesTestWasmGolden_CompileWithImportsTestWasmGolden_RoundTripTestWasmGolden_NativeVsStringAPITestWasmGolden_AllEngines16 test fixtures covering
Node.js wasm binary test (
scripts/test-wasm-golden.mjs)Builds the actual
.wasmbinary, loads it in Node.js using Go'swasm_exec.js, compiles all fixtures, and compares output against the Go golden files.Makefile targets
CI integration
Added to the existing
build-wasmCI job:Key findings from NativeVsStringAPI comparison
The string API (wasm) path diverges from the native file-based path in expected ways:
pre_activationjob not present in native outputThese differences are expected — the golden tests verify the string API/wasm path is self-consistent, not identical to the native path.
Test plan
go test ./... -shortpasses)make build-wasmin CI)🤖 Generated with Claude Code
Changeset