Skip to content

Run expect tests on OCaml5 - #262

Merged
jmid merged 4 commits into
c-cube:masterfrom
jmid:ocaml5-expect-tests
Nov 3, 2022
Merged

Run expect tests on OCaml5#262
jmid merged 4 commits into
c-cube:masterfrom
jmid:ocaml5-expect-tests

Conversation

@jmid

@jmidjmid commented Nov 2, 2022

Copy link
Copy Markdown
Collaborator

This PR fixes#252 to prepare for the forthcoming OCaml5 release.

Since OCaml5 comes with a new, splittable LXM PRNG (ocaml/ocaml#10742), the output distribution from Random.State.* changes - and so affects our QCheck expect tests. This PR adds .ocaml5 output-files similar to the current .32 and .64 files for OCaml<5.0 on 32-bit and 64-bit, respectively. The meta-programming in dune-files is then extended to account for the .ocaml5-case. OCaml5 will not support 32-bit in the foreseeable future (if ever) which eliminates a case.

There are two nits with the approach:

  • Extracting a leading digit from Sys.ocaml_version requires a bit of leg-work to work on earlier OCaml versions (Sys.ocaml_release was only recently added)
  • QCheck2 unit tests of char depend on the PRNG - which then need to account for the two cases. This is an unfortunate consequence of how the QCheck2 code is structured, not allowing us to test char shrinking independently.

Another solution to the above would be to use https://github.com/ocaml/randomV - a backward port of OCaml5's LXM PRNG.

  • Pro: this would mean always building on the same PRNG
  • Con: this adds a dependency, randomV is still unreleased, not clear if we may still have a separate 32-bit case on < OCaml5

Overall I therefore believe this PR is a reasonable first step to get expect tests running on OCaml5.

I've tested the PR code locally on

  • 5.0.0~beta1 (64-bit)
  • 4.13.1 (64-bit)
  • 4.14.0 (32-bit)

While doing the latter I spotted the missing 32-bit update fixed in #261

@jmid
jmid merged commit b36715e into c-cube:masterNov 3, 2022
@jmid
jmid deleted the ocaml5-expect-tests branch November 3, 2022 12:45
@jmidjmid mentioned this pull request Nov 3, 2022
Sign up for freeto 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.

Extend expect tests to OCaml 5.0

1 participant

@jmid