reasonml / reason

Simple, fast & type safe code that leverages the JavaScript & OCaml ecosystems
http://reasonml.github.io
MIT License
10.14k stars 428 forks source link

Migrate format unit tests to cram #2689

Closed davesnx closed 1 year ago

davesnx commented 1 year ago

This PR moves all formatTests/unit into refmt_tests/. Added the test suite as part of https://github.com/reasonml/reason/pull/2687.

It doesn't delete the tests from formatTest and it will be done in a further PR.

Part of this PR includes a README with the minimum explanation to run tests, you can take a look under refmt_test/README.md

This PR is spiritually the same as https://github.com/reasonml/reason/pull/2616 by me and https://github.com/reasonml/reason/pull/2454 by @sync (btw, the funny fact here is that it was my first attempt to contribute to reasonml/reason and failed because of the complexity around rely/esy/opam/Azure/CircleCI). In this case, I have already ensure the CI works with one single test https://github.com/reasonml/reason/pull/2687 and we can do the migration progressively.

Why

Example of a faiing test in CI

This is an example (on purpose) of tests failing:

Process

The migration path I took:

  1. Move input/XXXX as XXXX/input.(re|rei|ml)
  2. Move output/XXXX as XXXX/run.t
  3. Add 2 spaces to all lines
  4. Prefix with a comment "Format XXXX" and the refmt call

Some tests are renamed

There were a few tests with same name but different extensions:

A generic test called formatTest/unit/*/syntax.re and formatTest/unit/*/syntax.rei got renamed to refmt_test/general-syntax-re and refmt_test/general-syntax-rei