commaai / panda

code powering the comma.ai panda
MIT License
1.54k stars 783 forks source link

mutation tests: make coverage gradual #2057

Open maxime-desroches opened 1 month ago

maxime-desroches commented 1 month ago

Here is my proposal for making the mutation tests coverage increase over time while still being practical.

We have 2 testing modes that are run in parallel in CI:

  1. DIFF_COVERAGE. This mode verifies mutations with test_xx.py (all of them) on the intersection between its code coverage and the current git diff. This mode is very powerful since it will cover basically all the files if they are changed and will still run super fast.

  2. SAFETY_ONLY. This mode verifies mutations on safety_xx.h with test_xx.py if safety_xx.h is in MUTATION_SAFETY_FILES. Overtime, the goal is to add all the safety modes in that list. We can split those nicely, add them one by one and even put them on bounties.

Regardless of the testing mode, we are using all the ops in the MUTATION_OPS list to mutate the code. Overtime, the goal is to add most ops listed here in that list.

In the end, we can increase coverage in 3 ways: add files to MUTATION_SAFETY_FILES, add ops to MUTATION_OPS and add a third testing mode for other files we want to always check.