mirage / alcotest

A lightweight and colourful test framework
ISC License
451 stars 80 forks source link

Extension with new subcommands: status, approve, rerun #400

Open mjambon opened 10 months ago

mjambon commented 10 months ago

Hi. I'm looking into adding functionality to our test suite. We'll be porting tests from Pytest to Ocaml and we'll need a convenient way to check stdout and stderr outputs. I'm not sure what the implementation would look like. At best, it extends the command-line interface generated by alcotest without breaking existing code. At worst, it's some custom code in our (open-source) project that nobody else can use conveniently.

Here's what I have in mind:

Subcommands offered by the generated test program

* new subcommand

All these subcommands support filters that restrict the selection of tests. Filtering can be done:

Library changes

Please let me know if there's already something we can use that supports capturing stdout/stderr and the status and approve subcommand.

Other requirements

mjambon commented 9 months ago

I did a bit of work toward these goals. This is a lot of code (~2000 lines), all of it as a layer on top of the Alcotest library. The code, for now, is kept within the semgrep project at https://github.com/semgrep/semgrep/tree/develop/libs/alcotest_ext. Given its size and complexity, it should probably not be merged into the main Alcotest project but I'm still up for it. The current status is "alpha" in the sense that many features will need to be adjusted after we use it. The visual output is a bit of a mess.

Here's what was implemented and works:

Unchanged:

Partially implemented:

Unavailable:

mjambon commented 8 months ago

The project is now known as "Testo" and has its own repo: https://github.com/semgrep/testo. We're using it in Semgrep.