Skip to content

feat: add golden conformance test suite for format conversion and mappings#88

Merged
alvinreal merged 2 commits intomainfrom
fix/issue-82
Feb 23, 2026
Merged

feat: add golden conformance test suite for format conversion and mappings#88
alvinreal merged 2 commits intomainfrom
fix/issue-82

Conversation

@alvinreal
Copy link
Owner

Summary

Adds a golden-file conformance test suite to detect output drift across morph's parsers, serializers, and mapping evaluator.

Tests added (14 total)

Format conversion (7 tests):

  • JSON → YAML, JSON → CSV, JSON → JSON (pretty)
  • CSV → JSON, CSV → YAML
  • YAML → JSON, YAML → CSV

Mapping operations (4 tests):

  • rename — field renaming
  • select — field selection
  • where — row filtering
  • Complex pipeline — rename + set + drop combined

Round-trip consistency (3 tests):

  • JSON → YAML → JSON
  • JSON → CSV → JSON
  • YAML → CSV → YAML

Structure

tests/golden/
├── inputs/
│   ├── users.json
│   ├── users.csv
│   └── users.yaml
├── expected/
│   ├── json_to_yaml.txt
│   ├── csv_to_json.txt
│   └── ... (11 golden files)
└── golden_conformance.rs

Updating golden files

After an intentional output change:

UPDATE_GOLDEN=1 cargo test --test golden_conformance

Fixes #82

…pings

Adds 14 golden-file tests that detect output drift across parsers,
serializers, and the mapping evaluator:

- 7 format conversion tests (JSON/CSV/YAML cross-product)
- 4 mapping tests (rename, select, filter, complex pipeline)
- 3 round-trip consistency tests (JSON↔YAML, JSON↔CSV, YAML↔CSV)

Golden files can be updated with: UPDATE_GOLDEN=1 cargo test --test golden_conformance

Fixes #82
@alvinreal
Copy link
Owner Author

CI triage: Linux/macOS are green, but both Windows jobs fail in with broad golden mismatches (11 tests).\n\nLikely cause: line-ending normalization ( vs ) in golden fixture comparisons rather than logic regressions, since round-trip tests still pass and failures are across many text outputs at once.\n\nSuggested fix:\n1) Normalize before compare in test helper (e.g. )\n2) Or enforce LF for golden fixtures via :\n - \n3) Keep output normalization deterministic (trim trailing whitespace/newlines consistently).\n\nIf you want, I can open a follow-up PR/commit with normalization in the test harness.

@alvinreal
Copy link
Owner Author

Correction (formatting): Windows failures in PR #88 are likely line-ending normalization issues in golden-file comparisons (CRLF vs LF), not core logic regressions, since Linux/macOS are green and round-trip tests pass. Suggested fix: normalize line endings in test compare helper (replace CRLF with LF before assert), and optionally enforce LF in tests/golden via .gitattributes. I can help with a follow-up patch if needed.

@alvinreal alvinreal merged commit 483a7ae into main Feb 23, 2026
14 checks passed
@alvinreal alvinreal deleted the fix/issue-82 branch February 23, 2026 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Golden Conformance Suite for JSON/YAML/CSV mapping outputs

1 participant