Skip to content

Latest commit

 

History

History
86 lines (63 loc) · 2.79 KB

File metadata and controls

86 lines (63 loc) · 2.79 KB

Hazel Test Suite

This directory contains the test suite for the Hazel project.

Overview

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

How to Run Tests

1. Using the run_tests Script

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

    ./run_tests
  • Filter tests by group or number:

    • Run all tests in the "Statics" group with quick output (excluding slow/property-based):
      ./run_tests test 'Statics.*' -q
    • Run only test 19 from the "Evaluator" group:
      ./run_tests test 'Evaluator' 19

2. Using Make

  • Run all tests:

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

    make test-quick

Additional Information

  • ./run_tests is a shell script that first builds the tests using dune (the OCaml build system), then runs them using node.
  • You can pass CLI arguments to ./run_tests to filter and control test execution.
  • For more CLI options, refer to the Alcotest documentation.

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.