diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 73617d5a6aa..e60788c4d94 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -321,6 +321,25 @@ CI is run automatically on all pull requests. However, if you want to run tests - The `test/run_oss_cpp_tests.sh` script will build and run C++ tests locally - Running `pytest` from the root directory will run Python tests locally. Make sure to run this after finishing [Dev Install](#dev-install). +To build C++ tests manually with CMake, run the following from the repository root: + +```bash +cmake . -Bcmake-out -DCMAKE_INSTALL_PREFIX=cmake-out -DEXECUTORCH_BUILD_TESTS=ON +cmake --build cmake-out -j9 --target install +``` + +You can then use `ctest` to list or run individual C++ tests directly: + +```bash +ctest --test-dir cmake-out -N +ctest --test-dir cmake-out -R --output-on-failure +``` + +This workflow is useful when you want to rerun one test, attach a debugger to a +test binary under `cmake-out`, or keep a build directory around for quick rebuild +cycles. Add the same `-DEXECUTORCH_BUILD_*` options used by +`test/run_oss_cpp_tests.sh` when the test needs optional kernels or extensions. + ### Writing Tests To help keep code quality high, ExecuTorch uses a combination of unit tests and end-to-end (e2e) tests. If you add a new feature or fix a bug, please add tests