Testing
Run the local tests first. GPU tests are optional.
Prerequisites
- Xcode command line tools
- CMake 3.10+
- C++17 compatible compiler
- Python 3.10+
Code Quality
Run the normal checks before opening a pull request:
pre-commit run --all-files
The main checks are lint, Python tests, native build, and CTest.
Running Tests
Unit Tests
mkdir -p build && cd build cmake .. -DBUILD_TESTS=ON make ctest --output-on-failure
Performance Benchmarks
cd build ./bin/benchmark_metal_shim --benchmark_min_time=1s
Test Coverage
mkdir -p build_coverage && cd build_coverage cmake .. -DCMAKE_BUILD_TYPE=Debug -DENABLE_COVERAGE=ON make test_metal_shim lcov --capture --directory . --output-file coverage.info genhtml coverage.info --output-directory coverage
Writing Tests
Unit Tests: Place in tests/unit/, use Google Test framework, name files test_*.cpp
Benchmark Tests: Place in tests/performance/, use Google Benchmark framework, name files benchmark_*.cpp
Best Practices
- Write tests for all new features
- Keep tests independent and isolated
- Use meaningful test names
- Test edge cases and error conditions
- Document test assumptions and requirements