Skip to content

Convert golden_diff.py from a CLI script into a real pytest test, and commit a golden_master.json fixture #329

Closed

Description

@squid-protocol

Problem

golden_diff.py is a standalone CLI script (sys.argv, print,
sys.exit), not a pytest test. Even once it's wired into CI (see companion
issue), it only runs as a special-cased shell step -- it's invisible to
pytest, doesn't show up in the existing "GitGalaxy Smoke Tests" workflow,
and produces raw print output instead of standard pytest failure diffs.

Separately, there's currently no committed golden_master.json fixture in
the repo to compare against -- the comparison logic (load_and_sanitize,
generate_deterministic_hash, deep_compare) is solid and should be kept
as-is, it just has nothing checked in to run against yet.

Fix

1. Wrap the existing logic in a real pytest test

New file, e.g. tests/test_golden_diff.py, reusing load_and_sanitize,
generate_deterministic_hash, and deep_compare from golden_diff.py
unchanged:

def test_golden_master_parity():
    golden = load_and_sanitize("tests/golden_master/language_crucible_golden.json")
    actual = load_and_sanitize("telemetry_out/<output_file>.json")
    if generate_deterministic_hash(golden) == generate_deterministic_hash(actual):
        return
    diffs = deep_compare(golden, actual)
    assert not diffs, "\n".join(diffs[:50]) + (f"\n... and {len(diffs)-50} more" if len(diffs) > 50 else "")

This gets picked up automatically by the existing test-running workflows
rather than needing a bespoke CLI invocation.

2. Generate and commit a real golden_master.json fixture

Explicitly out of scope for this issue

  • Actually wiring the CI step to call this test (companion issue -- can land
    in either order, but both are needed for the full fix).
  • Golden-master update governance / preventing silent auto-overwrite
    (separate issue).

Activity

  1. added
    bug
    testing
    on Jul 23, 2026
  2. squid-protocol commented on Jul 25, 2026

    @squid-protocol
    OwnerAuthor

    Resolved by #398: golden_diff.py's comparison is now a real pytest test (tests/test_golden_crucible.py), opt-in via the golden_crucible marker, with the golden master fixtures committed in #395.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpriority: mediumtesting

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions