-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extension with new subcommands: status, approve, rerun #400
Comments
I want to add support for capturing and checking the output of tests. We want the test framework to manage the output snapshots, show us the differences with expectations, and let us approve new output. This will require specifying options such as "capture stdout for this test and compare it against the expectation". This PR creates a richer type for specifying tests and provides a function `create_test` with optional arguments. The legacy way of specifying a test using just a pair (name, function) is still supported and used in many places but it requires a call to `simple_test` or `simple_tests` to convert to the new type. Future steps will involve implementing was I mentioned in mirage/alcotest#400. If things work out, it may be integrated into Alcotest or become a standalone library that wraps around Alcotest. For now, we're keeping it in semgrep. The next steps are: * figure out how to add subcommands to the test program (`status`, `approve`, `rerun`) * implement stdout/stderr capturing * implement the new subcommands These initial changes will break semgrep-proprietary but it should only be a matter of inserting calls to `Testutil.simple_test` like I did on the semgrep code base. I'm not a fan of the name `Testutil`, I'm thinking of renaming it to something that alludes more to an experimental extension of Alcotest. Update: I renamed `Testutil` and isolated it in its own library named `Alcotest_ext`.
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:
|
I want to add support for capturing and checking the output of tests. We want the test framework to manage the output snapshots, show us the differences with expectations, and let us approve new output. This will require specifying options such as "capture stdout for this test and compare it against the expectation". This PR creates a richer type for specifying tests and provides a function `create_test` with optional arguments. The legacy way of specifying a test using just a pair (name, function) is still supported and used in many places but it requires a call to `simple_test` or `simple_tests` to convert to the new type. Future steps will involve implementing was I mentioned in mirage/alcotest#400. If things work out, it may be integrated into Alcotest or become a standalone library that wraps around Alcotest. For now, we're keeping it in semgrep. The next steps are: * figure out how to add subcommands to the test program (`status`, `approve`, `rerun`) * implement stdout/stderr capturing * implement the new subcommands These initial changes will break semgrep-proprietary but it should only be a matter of inserting calls to `Testutil.simple_test` like I did on the semgrep code base. I'm not a fan of the name `Testutil`, I'm thinking of renaming it to something that alludes more to an experimental extension of Alcotest. Update: I renamed `Testutil` and isolated it in its own library named `Alcotest_ext`.
The project is now known as "Testo" and has its own repo: https://github.com/semgrep/testo. We're using it in Semgrep. |
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
run
(today known astest
): run the testslist
: list the tests - shows the names, identifiers, or tags that can be used to filter testsstatus
*: show the status of the last run for each test - OK, FAIL, XFAIL, XPASS, or Unknownapprove
*: approve the output of the last run for the selected tests, similar todune promote
andpytest --snapshot-update
without rerunning the testsrerun
*: rerun the failed tests (and those that haven't run)* new subcommand
All these subcommands support filters that restrict the selection of tests. Filtering can be done:
some_product and not todo
Library changes
Please let me know if there's already something we can use that supports capturing stdout/stderr and the
status
andapprove
subcommand.Other requirements
The text was updated successfully, but these errors were encountered: