2020-08-07 18:37:28 +03:00
|
|
|
# Catala test suite
|
|
|
|
|
2021-05-26 22:57:51 +03:00
|
|
|
This folder contains Catala source files designed to test the features of the
|
2020-12-14 12:59:15 +03:00
|
|
|
language.
|
2020-08-07 18:37:28 +03:00
|
|
|
|
2021-05-26 22:57:51 +03:00
|
|
|
Expected outputs are stored using the convention
|
2022-01-10 20:45:02 +03:00
|
|
|
`<name_of_test>.catala_<language>.<name_of_scope>.Interpret` in the corresponding test output folder.
|
2020-12-09 19:31:42 +03:00
|
|
|
|
2020-12-09 20:14:52 +03:00
|
|
|
For both workflows: use `CATALA_OPTS="..." make ...` to pass in Catala compiler
|
|
|
|
options when debugging.
|
2020-12-09 19:31:42 +03:00
|
|
|
|
|
|
|
## Workflow for adding new tests
|
|
|
|
|
2021-05-26 22:57:51 +03:00
|
|
|
1. Create a new test file in `foo/{good,bad}/bar.catala_<language>` (pick the right directory and
|
2020-12-09 19:31:42 +03:00
|
|
|
an informative name for your test)
|
|
|
|
2. Write your test, and pick a toplevel scope `A` to run.
|
2022-01-10 20:45:02 +03:00
|
|
|
3. From this directory, create `mkdir -p foo/{good,bad}/output` and the empty expected
|
|
|
|
output file `touch foo/{good,bad}/output/bar.catala_<language>.A.Interpret`.
|
2022-01-11 14:51:34 +03:00
|
|
|
4. From the root of the Catala repository, Run `make -C tests foo/{good,bad}/bar.catala_<language>` to get the output of
|
|
|
|
your test (compared with the empty file). The failing test will give you the command to use to reproduce
|
|
|
|
the fail from the `tests` directory.
|
|
|
|
5. When you're happy with the output, launch `CLERK_OPTS=--reset make -C tests foo/{good,bad}/bar.catala_<language>`
|
|
|
|
from the root of the Catala repository. This
|
2020-12-09 19:31:42 +03:00
|
|
|
will record the content of the output of your test into a file.
|
2022-01-11 14:51:34 +03:00
|
|
|
6. Check that your test pass with `make -C tests foo/{good,bad}/bar.catala_<language>`
|
|
|
|
from the root of the Catala repository.
|
2022-01-10 20:45:02 +03:00
|
|
|
7. That's it, you've added a new test for the Catala language!
|
2020-12-09 19:31:42 +03:00
|
|
|
|
|
|
|
## Workflow for fixing regressions
|
|
|
|
|
2022-01-11 14:51:34 +03:00
|
|
|
1. Run `make test_suite` from the root of the Catala repository,
|
|
|
|
if a test fails you should see something like
|
2022-01-10 20:45:02 +03:00
|
|
|
`[ERROR] Test failed: foo/{good,bad}/output/bar.catala_<language>.A.Interpret]`.
|
2022-01-11 14:51:34 +03:00
|
|
|
2. Compare the computed and expected output with `make -C tests foo/{good,bad}/bar.catala_<language>`
|
|
|
|
from the root of the Catala repository.
|
|
|
|
3. Debug the compiler and/or the test, running `make -C tests foo/{good,bad}/bar.catala_<language>`
|
|
|
|
from the root of the Catala repository periodically to check the output of Catala
|
|
|
|
on the test case.
|
2021-05-26 22:57:51 +03:00
|
|
|
4. When you're finished debugging, record the new test output with
|
2022-01-10 20:45:02 +03:00
|
|
|
`CLERK_OPTS=--reset make foo/{good,bad}/bar.catala_<language>`.
|
2022-01-11 14:51:34 +03:00
|
|
|
5. Re-run `make test_suite` from the root of the Catala repository
|
|
|
|
to check that everything passes.
|
2021-05-26 22:57:51 +03:00
|
|
|
6. That's it, you've fixed the Catala test suite to adapt for changes in the
|
2020-12-14 12:59:15 +03:00
|
|
|
language.
|
|
|
|
|
|
|
|
If a compiler change causes a lot of regressions (error message formatting changes
|
2022-01-11 14:51:34 +03:00
|
|
|
for instance), you can mass-reset the expected the outputs with `CLERK_OPTS=--reset make test_suite`.
|
2021-05-26 22:57:51 +03:00
|
|
|
**Caution**: use at your own risk, regressions should be fixed one by one in
|
2021-01-24 04:51:30 +03:00
|
|
|
general.
|