mirror of
https://github.com/CatalaLang/catala.git
synced 2024-11-09 22:16:10 +03:00
.. | ||
test_arithmetic/bad | ||
test_array | ||
test_bool | ||
test_date | ||
test_dec/good | ||
test_default/bad | ||
test_enum | ||
test_exception | ||
test_func | ||
test_literate/good | ||
test_metadata/good | ||
test_money | ||
test_name_resolution/good | ||
test_proof | ||
test_scope | ||
test_struct | ||
test_visibility/good | ||
Makefile | ||
README.md |
Catala test suite
This folder contains Catala source files designed to test the features of the language.
Expected outputs are stored using the convention
<name_of_test>.catala_<language>.<name_of_scope>.Interpret
in the corresponding test output folder.
For both workflows: use CATALA_OPTS="..." make ...
to pass in Catala compiler
options when debugging.
Workflow for adding new tests
- Create a new test file in
foo/{good,bad}/bar.catala_<language>
(pick the right directory and an informative name for your test) - Write your test, and pick a toplevel scope
A
to run. - From this directory, create
mkdir -p foo/{good,bad}/output
and the empty expected output filetouch foo/{good,bad}/output/bar.catala_<language>.A.Interpret
. - 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 thetests
directory. - 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 will record the content of the output of your test into a file. - Check that your test pass with
make -C tests foo/{good,bad}/bar.catala_<language>
from the root of the Catala repository. - That's it, you've added a new test for the Catala language!
Workflow for fixing regressions
- Run
make test_suite
from the root of the Catala repository, if a test fails you should see something like[ERROR] Test failed: foo/{good,bad}/output/bar.catala_<language>.A.Interpret]
. - Compare the computed and expected output with
make -C tests foo/{good,bad}/bar.catala_<language>
from the root of the Catala repository. - 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. - When you're finished debugging, record the new test output with
CLERK_OPTS=--reset make foo/{good,bad}/bar.catala_<language>
. - Re-run
make test_suite
from the root of the Catala repository to check that everything passes. - That's it, you've fixed the Catala test suite to adapt for changes in the language.
If a compiler change causes a lot of regressions (error message formatting changes
for instance), you can mass-reset the expected the outputs with CLERK_OPTS=--reset make test_suite
.
Caution: use at your own risk, regressions should be fixed one by one in
general.