catala/tests
Aminata-Dev 94f8eac858 Better indications for the user :
- We're able to say from the parser what the user could have written. It may not be complete due to the acceptable function of Menhir : it is only an indication given to the user (and not intended to be an adaptive documentation)
- .mli file added : module interface for suggestions
- Add a test that provides a typographical or a logical error.
- Documentation and type / name changes for suggestions
2023-07-12 16:32:55 +02:00
..
test_arithmetic Improve suggestions 2023-07-12 11:55:11 +02:00
test_array Improve suggestions 2023-07-12 11:55:11 +02:00
test_bool Improve suggestions 2023-07-12 11:55:11 +02:00
test_date Improve suggestions 2023-07-12 11:55:11 +02:00
test_dec/good Implement an additional localised, user-facing value printer 2023-07-03 16:42:54 +02:00
test_default Better indications for the user : 2023-07-12 16:32:55 +02:00
test_enum Tests updated 2023-07-12 11:55:11 +02:00
test_exception Improve suggestions 2023-07-12 11:55:11 +02:00
test_func Improve suggestions 2023-07-12 11:55:11 +02:00
test_io Improve suggestions 2023-07-12 11:55:11 +02:00
test_literate/good Implement an additional localised, user-facing value printer 2023-07-03 16:42:54 +02:00
test_metadata/good removed one remaning debuging print, and updating all the tests 2023-04-14 17:59:08 +02:00
test_money Improve suggestions 2023-07-12 11:55:11 +02:00
test_name_resolution Improve suggestions 2023-07-12 11:55:11 +02:00
test_proof Improve suggestions 2023-07-12 11:55:11 +02:00
test_scope Improve suggestions 2023-07-12 11:55:11 +02:00
test_struct Improve suggestions 2023-07-12 11:55:11 +02:00
test_typing Improve suggestions 2023-07-12 11:55:11 +02:00
test_variable_state Improve suggestions 2023-07-12 11:55:11 +02:00
Makefile Fix documentation and test invocation 2022-08-30 13:48:20 +02:00
README.md style 2023-02-22 12:11:42 +01:00

Catala test suite

This folder contains Catala source files designed to test the features of the language.

Tests are declared inside plain Catala files with the following format:

```catala-test-inline
$ catala ARGS
... output from the catala command ...
```

Workflow for adding new tests

  1. Create a new test file in foo/{good,bad}/bar.catala_<language> (pick the right directory and an informative name for your test)
  2. Write your test, and pick a toplevel scope A to run.
  3. Add the following section to your file:
    ```catala-test-inline
    $ catala Interpret -s A
    ```
    
  4. Run make tests/foo/{good,bad}/bar.catala_<language> CLERK_OPTS=--reset from the root of the Catala repository. This will update the test with the actual output of the catala command.
  5. Don't forget to git add the test file.

Workflow for fixing regressions

  1. Run make test_suite from the root of the Catala repository, if a test fails you should see something like FAILED: foo/{good,bad}/bar.catala_<language>.out] followed by the diff between the expected output and the current output of the command.
  2. Debug the compiler and the test and repeat. Run make tests/foo/{good,bad}/bar.catala_<language> to check the test again.
  3. When you're finished debugging, if you are positive that a change in the test output is legitimate, record the new outputs with make tests/foo/{good,bad}/bar.catala_<language> CLERK_OPTS=--reset.
  4. Re-run make test_suite from the root of the Catala repository to check that everything passes.
  5. Run git diff to double-check your changes to the test outputs are expected. If necessary, justify them in your commit message.

If a compiler change causes a lot of regressions (error message formatting changes for instance), you can mass-reset the expected outputs with make test_suite CLERK_OPTS=--reset. git diff will then allow to check all the changes at once. Caution: It's your responsability to check all the changes before committing them.

Tips

  • Running a single test-file just to check changes when tweaking either the compiler or the test file itself, but without updating or diffing with the reference can be useful when debugging. The following command outputs the result to stdout and can be used from within text editors:

    clerk runtest test-file.catala_en
    # Or, to use the current build artefacts, wrap with `dune exec`:
    dune exec --display=quiet --no-build -- clerk runtest -e dune -c "exec --display=quiet --no-build -- catala" test-file.catala_en