Skip to content

test(node-suite): normalize env-variant tokens so console scores 119/119#5101

Merged
proggeramlug merged 1 commit into
mainfrom
fix/node-suite-console-env-variant-normalize
Jun 13, 2026
Merged

test(node-suite): normalize env-variant tokens so console scores 119/119#5101
proggeramlug merged 1 commit into
mainfrom
fix/node-suite-console-env-variant-normalize

Conversation

@proggeramlug

@proggeramlug proggeramlug commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Investigated the node-suite console category (target: 90.8% → 100%, 119 tests). The headline finding: the Perry console / `util.inspect` formatter has no bugs. It already matches node v26.3.0 byte-for-byte on every deterministic console output across all 119 tests. The official runner reported 109/119 with the 10 residual diffs being entirely environment-variant content — exactly the timing/stack class the suite docs say to note, not chase.

This is a scorer fix, not a runtime fix: no runtime/C++/Rust code changed, so the inspect engine is byte-identical to `origin/main`.

The 10 residual diffs (all environment-variant)

Class Count Why raw diff fails
`console.time`/`timeEnd`/`timeLog` 9 node's `formatTime` prints a live hrtime delta as the raw float `${ms}ms` — non-deterministic and variable-decimal. node itself prints `0.004ms` / `0.004ms` / `0.003ms` across three runs of the same program. Masking the ms → byte-identical (label coercion of `true`/`[]`/`null`/`NaN`/`proto`/object `.toString()`/Symbol-throw, the `mid` data, `{a:1}` extra args, duplicate-label warning all match).
`output/error-cause` 1 stack-trace frames — absolute paths, line/col, node-internal ESM-loader frames Perry can't reproduce (`at `). Removing frame lines → byte-identical (Error headline, `[cause]` block, braces all match).

The original `2>&1` enumeration surfaced 17 diffs, but the runner compares stdout only — count/* warnings and trace/* output go to node's stderr, and Perry already matches their stdout.

Fix

`node_suite_run.normalize()` scrubs the two env-variant token classes symmetrically from both node and perry stdout before the equality check — mirroring how `gen_feature_matrix.py` already strips `(node:PID) Warning` noise:

  • durations — anchored on the `: ` separator so only timer output is masked; the unit is kept, so a dropped `ms` / wrong label / missing trailing arg still surfaces as a diff.
  • stack frames — lines indented ≥4 spaces beginning with `at ` / `N: `, plus Perry's `(… N more identical frames)` elision. The ≥4-space guard leaves ordinary 2-space-per-level inspect output untouched.

Console floor ratcheted 108 → 119 in `node_suite_baseline.json`.

Verification

  • `node_suite_run.py console` → 119/119 (100.0%) (was 109/119).
  • No other module drops below its floor: assert 70/70, buffer 134/134, os 39/39, path 92/92, timers 90/90 (all at full floor), util 85/86 (floor 84, +1). The util improvement is `inspect/error-cause-and-aggregate.ts` — same env-variant stack-trace normalization (its `[cause]`/`[errors]`/AggregateError structure already matched). Only `util/inspect/boxed-and-symbols.ts` remains a genuine pre-existing diff, absorbed by util's floor margin (not touched here).
  • Normalization is conservative: it only ever removes/masks content symmetrically, so it cannot turn a passing test into a failure, and the anchors keep the blast radius to genuine timer/stack output.
  • `scripts/node_suite_run.py` parses; baseline JSON valid.

Notes

  • Per the bench-PR convention, version / `CHANGELOG.md` / `CLAUDE.md` metadata are intentionally not touched (maintainer folds those in at merge).
  • No test files edited.

Summary by CodeRabbit

  • Tests

    • Improved test output comparison by normalizing non-deterministic values and stack traces.
    • Updated baseline test expectations to reflect improved pass rates.
  • Chores

    • Enhanced testing infrastructure to handle console timing and output variations.

The console formatter already matches node v26 byte-for-byte on every
deterministic output across all 119 node-suite console tests. The 10
residual diffs were entirely environment-variant content that the
print-and-diff runner compared raw:

  - 9x console.time/timeEnd/timeLog: node's formatTime prints a live
    hrtime delta as the raw float `${ms}ms`, non-deterministic run-to-run
    (node itself prints 0.004ms / 0.004ms / 0.003ms across three runs).
  - 1x output/error-cause: stack-trace frames (absolute paths, line/col,
    node-internal ESM-loader frames Perry can't reproduce).

Masking ms / removing frame lines makes every one byte-identical, i.e.
they were never Perry defects — they're the timing/stack class the suite
docs already say to leave alone.

Fix the scorer, not the runtime: node_suite_run.normalize() scrubs the
two env-variant token classes symmetrically from both node and perry
stdout before the equality check (mirrors gen_feature_matrix.py already
stripping `(node:PID) Warning` noise):

  - durations: anchored on the `<label>: ` separator so only timer output
    is masked; the unit is kept so a dropped `ms`/wrong label still diffs.
  - stack frames: lines indented >=4 spaces starting with `at `/`N:` plus
    Perry's `(… N more identical frames)` elision; the >=4-space guard
    leaves ordinary 2-space-per-level inspect output untouched.

Ratchet the console floor 108 -> 119. Verified no other module drops
below its floor (assert/buffer/os/path/timers at full pass, util +1 from
the same error-cause stack normalization, all >= floor). No runtime code
changed, so the inspect engine is byte-identical to origin/main.
@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

The PR adds stdout normalization to the node suite regression test script to handle non-deterministic differences in stack traces and console timing output. Stack-trace frame lines and console duration values are masked before comparison. Baseline expectations are updated to reflect the improved pass rate from this normalization.

Changes

Node suite output normalization

Layer / File(s) Summary
Output normalization implementation
scripts/node_suite_run.py
Regex patterns and a normalize() function that filters indented stack-trace frame lines and masks console.time/timeEnd/timeLog duration numbers while preserving labels.
Comparison logic update
scripts/node_suite_run.py
Pass/fail condition updated to compare normalized stdout (with trailing newline trimming) from both node and perry, while still requiring matching exit codes.
Baseline schema and results
test-parity/node_suite_baseline.json
Schema note extended with normalization/flooring details, overall pass count increased from 2781 to 2792, and console module pass count increased from 108 to 119.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • PerryTS/perry#5097: The main PR's changes refine scripts/node_suite_run.py output comparison/normalization and update test-parity/node_suite_baseline.json to match the behavior of the newly added node-suite regression guard/rerunner from the retrieved PR.

Poem

🐰 A rabbit hops through timing traces,
Scrubs the stacks that leave their places,
Masks the durations, keeps the names,
Now the tests match in their games! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: normalizing environment-variant tokens in the node-suite to achieve 119/119 console test passing.
Description check ✅ Passed The description is comprehensive and well-structured, covering the investigation, problem analysis, solution details, and verification steps. All critical context is provided.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/node-suite-console-env-variant-normalize

Comment @coderabbitai help to get the list of available commands and usage tips.

@proggeramlug proggeramlug merged commit 2cfa8ca into main Jun 13, 2026
12 of 14 checks passed
@proggeramlug proggeramlug deleted the fix/node-suite-console-env-variant-normalize branch June 13, 2026 21:22
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.

1 participant