Skip to content

fix(res-to-affine): restore the five test fixtures deleted by f766dcb - #741

Merged
hyperpolymath merged 1 commit into
mainfrom
fix/restore-res-to-affine-fixtures
Sep 7, 2026
Merged

fix(res-to-affine): restore the five test fixtures deleted by f766dcb#741
hyperpolymath merged 1 commit into
mainfrom
fix/restore-res-to-affine-fixtures

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

What

Restores tools/res-to-affine/test/fixtures/{partial1,phase2c,phase3,phase3b,phase3c}.res,
deleted by f766dcb "chore: remove rescript example configuration" (2026-08-18).
sample.res was restored on main previously; these five were not.

Why they are not "rescript example configuration"

They are the inputs to the res-to-affine migration tool's own test suite —
synthetic anti-pattern files, each headed "Not a real ReScript program" — against
which expected/*.affine is compared. They are the only correctness check the
ReScript→AffineScript migration tool has.

Why it was silent

Two independent failure-to-signal mechanisms:

  1. test/dune declares the inputs as (glob_files fixtures/*.res). A glob over a
    directory that does not exist matches zero files and does not fail the build,
    so the suite kept compiling and each test died at runtime on
    Sys_error("fixtures/<f>.res: No such file or directory").

  2. test_walker.ml's skip_unless_ready () calls Alcotest.skip () when the
    tree-sitter grammar is not built. In an environment without the grammar all 32
    walker cases SKIP and alcotest reports Test Successful … 0 test run, exit 0
    so the suite is green precisely when it is testing nothing.

Evidence

With the grammar built and the fixtures absent: 32 of 32 walker tests fail.
With the fixtures restored: 32 of 32 pass, and repo-wide dune runtest goes
rc=1 → rc=0.

Not fixed here

Mechanism (2) above — the fail-open skip — is left as-is deliberately; turning a
skip into a hard failure is a policy change for the maintainer, not part of a
restore. Filed as a follow-up.

f766dcb ("chore: remove rescript example configuration") deleted
tools/res-to-affine/test/fixtures/*.res as ReScript artefacts. They are
not artefacts: they are the *inputs* to the res-to-affine migration
tool's own test suite -- synthetic anti-pattern files, each headed
"Not a real ReScript program", against which the expected/*.affine
goldens are compared.

The deletion was silent. test/dune declares the inputs as
(glob_files fixtures/*.res); a glob over a directory that does not
exist matches zero files and does not fail the build, so the suite kept
building and every test died at runtime on
Sys_error("fixtures/sample.res: No such file or directory").

Effect: 35 of 35 res-to-affine tests failed, i.e. the tool that
performs the ReScript-to-AffineScript migration has had no working
correctness check since 2026-08-18. Restoring the six files takes the
repo from `dune runtest` rc=1 to rc=0.

Refs f766dcb

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Team

Run ID: beca7d92-35ef-45fe-8a5d-10f897b787e8

📥 Commits

Reviewing files that changed from the base of the PR and between b585f13 and a1e32b6.

📒 Files selected for processing (5)
  • tools/res-to-affine/test/fixtures/partial1.res
  • tools/res-to-affine/test/fixtures/phase2c.res
  • tools/res-to-affine/test/fixtures/phase3.res
  • tools/res-to-affine/test/fixtures/phase3b.res
  • tools/res-to-affine/test/fixtures/phase3c.res

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (4)
  • GitHub Check: coverage-visibility
  • GitHub Check: bench-visibility
  • GitHub Check: lint
  • GitHub Check: build
🔇 Additional comments (3)
tools/res-to-affine/test/fixtures/phase2c.res (1)

1-83: LGTM!

tools/res-to-affine/test/fixtures/phase3c.res (1)

1-27: LGTM!

tools/res-to-affine/test/fixtures/partial1.res (1)

1-6: LGTM!

Also applies to: 8-11, 13-17, 19-23, 25-29, 31-38


📝 Summary

Summary by CodeRabbit

  • Tests
    • Added coverage for ReScript-to-Affine translation scenarios, including expressions, control flow, records, arrays, type declarations, generics, and literal bindings.
    • Added fixtures covering unsupported or deferred cases, such as mutable and optional fields, qualified types, destructuring, and non-literal bindings.
    • Added walker scenarios for inline callbacks and long function bodies.

Walkthrough

The PR adds five res-to-affine fixtures. They cover expression translation, walker-only patterns, structural types, records, generic aliases, literal bindings, and skipped forms.

Changes

res-to-affine test fixtures

Layer / File(s) Summary
Expression translation fixtures
tools/res-to-affine/test/fixtures/partial1.res
Adds functions for switch expressions, arithmetic, strings, logging, pipes, conditionals, blocks, arrays, records, and an untranslated template string.
Walker anti-pattern fixtures
tools/res-to-affine/test/fixtures/phase2c.res
Adds inline callback patterns and a function body longer than 50 source rows.
Structural type translation fixtures
tools/res-to-affine/test/fixtures/phase3.res, tools/res-to-affine/test/fixtures/phase3b.res
Adds primitive, variant, generic, record, and alias declarations. It also documents skipped qualified-path, mutable-field, and optional-field cases.
Literal binding translation fixtures
tools/res-to-affine/test/fixtures/phase3c.res
Adds literal bindings for Int, Float, String, and Bool, plus skipped call, ref, and destructuring cases.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to a1e32

The restored fixtures match the migration tool's tested behavior and introduce no actionable merge risk.

Suggested reviewers: metadatastician

Poem

A rabbit checks each fixture line,
Pipes and patterns fall in line.
Types become structs, clear and bright,
Literal constants hold their type.
Skipped forms wait beneath the moon.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the res-to-affine change and states that five deleted test fixtures were restored.
Description check ✅ Passed The description directly explains which fixtures were restored, why they are required, the failure they prevented, and the intentional scope limitation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
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.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@sonarqubecloud

sonarqubecloud Bot commented Sep 7, 2026

Copy link
Copy Markdown

@hyperpolymath
hyperpolymath merged commit 8abeaaa into main Sep 7, 2026
19 of 20 checks passed
@hyperpolymath
hyperpolymath deleted the fix/restore-res-to-affine-fixtures branch September 7, 2026 21:00
hyperpolymath added a commit that referenced this pull request Sep 8, 2026
Implements the owner ruling of 2026-09-07: **no environment may silently
run zero tests.**

## The fake green

`test_walker.ml:65 skip_unless_ready()` called `Alcotest.skip()` when
the tree-sitter
CLI or the generated grammar was absent.
`tools/vendor/tree-sitter-rescript/src/parser.c`
is gitignored (`.gitignore:112`), so **every fresh checkout** took that
path: all 32
walker cases skipped and alcotest printed

```
Test Successful in 0.018s. 0 test run.
```

with exit 0. The suite was green precisely when it was testing nothing.

This is not hypothetical. It is why the deletion of this suite's own
fixtures in
`f766dcb` went unnoticed for three weeks (restored in #741): in any
environment
lacking the grammar, a missing test corpus produced a pass.

## The change

Renames the guard to `require_ready()` and replaces both
`Alcotest.skip()` calls with
`Alcotest.failf` carrying the remedy (`cargo install tree-sitter-cli` /
`just install-grammar`). One file, 32 call sites renamed mechanically.

## Verified, both directions

| Grammar | Result |
|---|---|
| absent | `rc=1` — `32 failures! in 0.020s. 32 tests run.` |
| present | `rc=0` — `Test Successful in 1.257s. 32 tests run.` |

The important column is the **count**: previously the absent case
reported
`0 test run` and passed. `ci.yml:70-79` installs the CLI and builds the
grammar
before `dune runtest`, so CI lands in the passing row.

## Accepted cost

A fresh clone can no longer run the walker suite without installing the
tree-sitter
CLI and building the grammar first. That is the deliberate trade, chosen
over the
milder "fail under CI, skip locally".

## Note

`ocamlformat` is not available in my environment, so I could not
pre-check
`dune build @fmt`. If the formatting gate objects, say so and I will
correct it.

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
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