Skip to content

Migrate loose tests/test_*.sh regression scripts into the test-parity system #5891

Description

@TheHypnoo

Problem

The tests/test_*.sh directory has grown to ~135 loose shell scripts, each re-implementing ~40 lines of boilerplate (perry-binary + runtime-lib detection, temp dir, compile/run error handling, diff). Most of them are parity tests: they compile a .ts/.js snippet with Perry and diff its stdout against Node. Two structural problems:

  1. No CI coverage. run_tests.sh (which globs these) is not invoked by any CI job. The cargo-test job only runs Rust #[test]s; the parity job (which does run .ts corpus tests) is tag-gated. So these shell tests only ever run when someone runs run_tests.sh locally.
  2. Disorganized & duplicative. Bespoke per-case filenames, no shared harness, no domain grouping.

Meanwhile a mature parity system already exists: drop a .ts into test-files/ (or test-parity/node-suite/<module>/) and the harness auto-discovers it, compiles with Perry, runs under Node, and diffs. Intentional Perry-vs-Node divergences use a stored test-parity/expected/<name>.txt; non-zero exits use expected-exit/.

Proposal

Migrate the parity-shaped shell tests into the parity corpus, so the .ts is the test:

  • Pure "match Node" cases → test-files/test_parity_<case>.ts (auto node-diff, no boilerplate).
  • Node-module-specific cases → test-parity/node-suite/<module>/<case>.ts (grouped by domain; supports subdirs + the multi/ convention for multi-module fixtures).
  • Intentional divergences (e.g. new Function throwing, dynamic-import diagnostics) → add test-parity/expected/<name>.txt.
  • Delete the migrated shell wrappers.

Caveats / not purely mechanical

  • stderr assertions (e.g. test_dynamic_function_probe_fallback_stderr): the parity harness diffs stdout; these need adapting (move the assertion to stdout, or keep as a shell test).
  • Multi-module tests → node-suite/<x>/ with a multi/ deps folder.
  • A handful genuinely can't be pure parity and stay as shell tests.

Interim

PR #5874 added tests/_perry_test_lib.sh (shared harness) and adopted it in two tests, which reduces the boilerplate for any shell tests that remain after migration.

Scope

Start with the ~40 Zod-compat regression tests added in #5874; then sweep the remaining ~95. Best done as its own PR (test-convention change, independent of Zod).

Activity

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

    toolingDeveloper tooling, CI, tests, or release infrastructure

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions