Skip to content

Latest commit

 

History

History
92 lines (66 loc) · 3.23 KB

File metadata and controls

92 lines (66 loc) · 3.23 KB

Hazel Test Suite

This directory contains the test suite for the Hazel project.

Overview

  • Test Framework: Alcotest
  • Execution: Tests are run via make commands or the run_tests script.

How to Run Tests

1. Using Make

  • Run all tests (including slow and property-based):

    make test
  • Run only quick tests (skip slow/property-based):

    make test-quick

2. Using the run_tests Script

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.

Architecture

  • test/dune defines the test executable and two dune aliases (@runtest for all tests, @test-quick for quick tests). The Makefile targets invoke these aliases.
  • test/run_node.sh is a shared wrapper that runs the compiled JS with the correct Node.js flags (--stack-size=8192 for deeply recursive tests, --require idb_stub.js for IndexedDB globals). Both dune rules and run_tests use this script so the flags are defined in one place.
  • run_tests builds with dune, then calls run_node.sh directly, which allows it to forward arbitrary CLI arguments to the test runner.

Test File Structure

  • All test files are located in this directory and its statics/ subdirectory.
  • Each file tests a specific module or feature (e.g., Test_Evaluator.re for the evaluator).
  • Property-based tests use QCheck and are included when running the full test suite.

Adding New Tests

  • To add a new test, create a new file named Test_<Feature>.re or add to an existing file.
  • Use the Alcotest API for defining test cases.
  • Utility functions for property-based testing are in QCheck_Util.re.

Troubleshooting

  • 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).

Code Coverage

  • 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.

Continuous Integration

  • 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.xml report, which is picked up by CI for test result reporting.
  • Coverage information is uploaded to Codecov to provide coverage metrics on pull requests.