This directory contains the test suite for the Hazel project.
- Test Framework: Alcotest
- Execution: Tests are run via
makecommands or therun_testsscript.
-
Run all tests (including slow and property-based):
make test -
Run only quick tests (skip slow/property-based):
make test-quick
The run_tests script builds with dune and then invokes the test runner,
forwarding any CLI arguments. Use this when you need to filter tests by
group or number:
-
Run all tests:
./run_tests
-
Run all tests in the "Statics" group with quick output:
./run_tests test 'Statics.*' -q
-
Run only test 19 from the "Evaluator" group:
./run_tests test 'Evaluator' 19
-
For more CLI options, refer to the Alcotest documentation.
test/dunedefines the test executable and two dune aliases (@runtestfor all tests,@test-quickfor quick tests). TheMakefiletargets invoke these aliases.test/run_node.shis a shared wrapper that runs the compiled JS with the correct Node.js flags (--stack-size=8192for deeply recursive tests,--require idb_stub.jsfor IndexedDB globals). Both dune rules andrun_testsuse this script so the flags are defined in one place.run_testsbuilds with dune, then callsrun_node.shdirectly, which allows it to forward arbitrary CLI arguments to the test runner.
- All test files are located in this directory and its
statics/subdirectory. - Each file tests a specific module or feature (e.g.,
Test_Evaluator.refor the evaluator). - Property-based tests use QCheck and are included when running the full test suite.
- To add a new test, create a new file named
Test_<Feature>.reor add to an existing file. - Use the Alcotest API for defining test cases.
- Utility functions for property-based testing are in
QCheck_Util.re.
- If you encounter build errors, ensure all dependencies are installed:
make deps
- For issues with Node.js execution, check your Node.js version (>=14 recommended).
-
Run tests with coverage instrumentation:
make coverage
This will run the test suite and collect coverage data.
-
Generate an HTML coverage report:
make generate-coverage-html
This will produce an HTML file with a coverage overview, which you can open in your browser to inspect which parts of the codebase are covered by tests.
- Tests are automatically run on each pull request via GitHub Actions.
- CI status can be viewed on the repository main page.
- The test suite uses junit_alcotest to generate a
junit.xmlreport, which is picked up by CI for test result reporting. - Coverage information is uploaded to Codecov to provide coverage metrics on pull requests.