catala/tests
Denis Merigoux 9008a7f0e6
Improving French housing benefits (#314)
Follow-up of #287, #266 and #165.
Time spent
Pair programming sessions

Before 2022-07-11: 50h (50 h for each person of the pair programming duo)

Refactoring sessions

Before 2022-07-11: 24 h
2022-07-14: 3 h

Legal research sessions

Before 2022-07-11: 21,5 h

Testing and debugging

Before 2022-07-11: 13,5 h
2022-07-11: 3 h with Denis
2022-07-13: 2 h with Denis
2022-07-14: 1 h with Denis
2022-07-16: 2 h with Denis
2022-07-19: 2 h with Denis
2022-07-21: 2 h with Denis
2022-08-11: 6 h with Denis
2022-08-15: 4 h with Denis
2022-08-16: 2 h with Denis

UI and form

2022-08-09: 8 h with Denis
2022-08-10: 8 h with Denis
2022-08-15: 2 h with Denis
2022-08-16: 2 h with Denis
2022-08-17: 6 h with Denis
2022-08-18: 4 h with Denis
2022-08-19 14:57:48 +02:00
..
test_arithmetic Adjust test results 2022-07-11 17:43:59 +02:00
test_array Change syntax for set membership predicate 2022-07-27 14:34:58 +02:00
test_bool Fix uncaught type error 2022-08-15 16:20:31 +02:00
test_date Register all existing tests through the new engine 2022-07-08 17:06:20 +02:00
test_dec/good Register all existing tests through the new engine 2022-07-08 17:06:20 +02:00
test_default/bad Cleaned code for generating exception graph, now correct and fully general 2022-07-22 12:25:41 +02:00
test_enum Register all existing tests through the new engine 2022-07-08 17:06:20 +02:00
test_exception Fix subtle bug with the default false value for conditions 2022-08-15 16:47:36 +02:00
test_func Cleaned code for generating exception graph, now correct and fully general 2022-07-22 12:25:41 +02:00
test_io Simplify default tree encoding 2022-07-22 12:31:02 +02:00
test_literate/good Register all existing tests through the new engine 2022-07-08 17:06:20 +02:00
test_metadata/good Register all existing tests through the new engine 2022-07-08 17:06:20 +02:00
test_money Register all existing tests through the new engine 2022-07-08 17:06:20 +02:00
test_name_resolution/good Add test for precedence of local variabes vs. local scopes 2022-08-19 11:08:28 +02:00
test_proof Register all existing tests through the new engine 2022-07-08 17:06:20 +02:00
test_scope More factorisation, in particular for variables 2022-08-12 17:18:06 +02:00
test_struct Register all existing tests through the new engine 2022-07-08 17:06:20 +02:00
test_variable_state Simplify default tree encoding 2022-07-22 12:31:02 +02:00
Makefile Pass some make flags to Clerk 2022-04-14 11:47:18 +02:00
README.md Update doc for handling tests 2022-07-11 16:03:47 +02: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 {id="TEST-IDENT"}
catala ARGS
```

The output of running catala with the given ARGS for a foo.catala_en file is expected to be in an output/foo.catala_en.TEST-IDENT file (use CLERK_OPTS=--reset to (re-)generate it).

You can use CATALA_OPTS="..." make ... to pass in Catala compiler options when debugging.

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 {id="A.Interpret"}
    catala Interpret -s A
    ```
    
  4. Run CLERK_OPTS=--reset make 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 the target file.
  5. Check that the expected output is present in tests/foo/{good,bad}/output/bar.catala_<language>.A.Interpret
  6. Don't forget to git add both the test file and the output 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 [ERROR] Test failed: foo/{good,bad}/output/bar.catala_<language>.A.Interpret].
  2. Compare the computed and expected output with make tests/foo/{good,bad}/bar.catala_<language> from the root of the Catala repository. Debug the compiler and the test and repeat.
  3. When you're finished debugging, if you are positive that a change in the test output is legitimate, record the new outputs with CLERK_OPTS=--reset make tests/foo/{good,bad}/bar.catala_<language>.
  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 the outputs with CLERK_OPTS=--reset make test_suite. Caution: It's your responsability to check all the changes before committing them.