| 1 | # Coq Test Suite |
| 2 | |
| 3 | The test suite can be run from the Coq root directory by `make test-suite`. |
| 4 | However, for incremental test suite builds, we recommend running `make` |
| 5 | from the test-suite directory (or with `make -C test-suite`). |
| 6 | This Makefile is compatible with both Dune |
| 7 | and legacy hybrid builds. |
| 8 | |
| 9 | You can also run `make aaa/bbb/ccc.v.log` to build the log for one test, |
| 10 | or `make ddd` where `ddd` is on of the sub-directories of `test-suite` |
| 11 | to just build the logs for that directory. |
| 12 | In these cases, a summary is not printed, but can be generated by `make summary`. |
| 13 | |
| 14 | `make -B` can be used to rerun tests ( -B meaning always remake). |
| 15 | |
| 16 | From the `test-suite` directory, `make report` (included in `make |
| 17 | all`) prints a summary of which tests failed using the produced log |
| 18 | files (this still works when only some tests are built as described |
| 19 | above). Setting the `PRINT_LOGS` variable will make it print the logs |
| 20 | of the failing tests. |
| 21 | |
| 22 | For instance, running the following in the `test-suite` directory: |
| 23 | |
| 24 | ```bash |
| 25 | $ echo Fail. > success/fail.v # make some failing test |
| 26 | |
| 27 | $ make |
| 28 | TEST prerequisite/make_local.v |
| 29 | ... |
| 30 | TEST success/fail.v |
| 31 | ... |
| 32 | BUILDING SUMMARY FILE |
| 33 | FAILURES |
| 34 | success/fail.v ... Error! (should be accepted) |
| 35 | Makefile:189: recipe for target 'all failed |
| 36 | make: *** [report] Error 1 |
| 37 | |
| 38 | $ make report PRINT_LOGS=1 |
| 39 | BUILDING SUMMARY FILE |
| 40 | logs/success/fail.v.log |
| 41 | ==========> TESTING success/fail.v <========== |
| 42 | Welcome to Coq (version information) |
| 43 | Skipping rcfile loading. |
| 44 | File "/path/to/success/fail.v", line 1, characters 4-5: |
| 45 | Error: |
| 46 | Syntax error: [vernac:Vernac.vernac_control] expected after 'Fail' (in [vernac:Vernac.vernac_control]). |
| 47 | |
| 48 | 0m0.000000s 0m0.000000s |
| 49 | 0m0.040000s 0m0.000000s |
| 50 | ==========> FAILURE <========== |
| 51 | success/fail.v ... Error! (should be accepted) |
| 52 | |
| 53 | FAILURES |
| 54 | success/fail.v ... Error! (should be accepted) |
| 55 | Makefile:189: recipe for target 'report' failed |
| 56 | make: *** [report] Error 1 |
| 57 | |
| 58 | $ echo 'Comments "foo".' > success/fail.v |
| 59 | |
| 60 | $ make |
| 61 | TEST success/fail.v |
| 62 | BUILDING SUMMARY FILE |
| 63 | NO FAILURES |
| 64 | ``` |
| 65 | |
| 66 | See [`test-suite/Makefile`](Makefile) for more information. |
| 67 | |
| 68 | ## Adding a test |
| 69 | |
| 70 | Regression tests for closed bugs should be added to |
| 71 | [`bugs`](bugs), as `bug_1234.v` where `1234` is the bug number. |
| 72 | Files in this directory are tested for successful compilation. |
| 73 | When you fix a bug, you should usually add a regression test here as well. |
| 74 | |
| 75 | The error "(bug seems to be opened, please check)" when running |
| 76 | `make test-suite` means that a test in [`bugs`](bugs) failed to |
| 77 | compile. |
| 78 | |
| 79 | There are also output tests in [`output`](output) which consist of a `.v` file |
| 80 | and a `.out` file with the expected output. Output tests in this directory are |
| 81 | run with coqc in -test-mode. Output tests in [`output-coqtop`](output-coqtop) |
| 82 | work the same way, but are run with coqtop. |
| 83 | |
| 84 | There are unit tests of OCaml code in [`unit-tests`](unit-tests). These tests |
| 85 | are contained in `.ml` files, and rely on the `OUnit` unit-test framework, as |
| 86 | described at <http://ounit.forge.ocamlcore.org/>. Use `make unit-tests` in the |
| 87 | [`unit-tests`](unit-tests) directory to run them. |
| 88 | |
| 89 | ## Fixing output tests |
| 90 | |
| 91 | When an output test `output/foo.v` fails, the output is stored in |
| 92 | `output/foo.out.real`. Move that file to the reference file |
| 93 | `output/foo.out` to update the test, approving the new output. Target |
| 94 | `approve-output` will do this for all failing output tests |
| 95 | automatically. |
| 96 | |
| 97 | Don't forget to check the updated `.out` files into git! |