From f276de47518d900282ccaede5c1fe0a6f6170087 Mon Sep 17 00:00:00 2001 From: Ye Kuang Date: Thu, 8 Jul 2021 15:18:58 +0800 Subject: [PATCH] [doc] Add a basic doc explaining how to run Taichi CPP tests (#2502) * [doc] Add a basic doc explaining how to run Taichi CPP tests * Auto Format * Update docs/lang/articles/contribution/writing_cpp_tests.md Co-authored-by: Taichi Gardener --- .../contribution/writing_cpp_tests.md | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 docs/lang/articles/contribution/writing_cpp_tests.md diff --git a/docs/lang/articles/contribution/writing_cpp_tests.md b/docs/lang/articles/contribution/writing_cpp_tests.md new file mode 100644 index 000000000..d41a42037 --- /dev/null +++ b/docs/lang/articles/contribution/writing_cpp_tests.md @@ -0,0 +1,33 @@ +--- +sidebar_position: 11 +--- + +# Workflow for writing a CPP test + +We strongly recommend each developer to write CPP unit tests when sending a PR. + +- We use [googletest](https://github.com/google/googletest) as the CPP + test infrastructure. +- CPP tests should be added to the `tests/cpp/` directory. + +## Build and run Taichi CPP tests + +```bash +# inside build/ +cmake .. -DTI_BUILD_TESTS=ON # ... other regular Taichi cmake args +make + +# run the CPP test +./taichi_cpp_tests +``` + +:::note +Consider polishing the CPP test infrastructure: + +* Separate each translation unit into its own test executable +* Have a unified script to control the execution of which set of tests +::: + +## Adding a new test case + +Please follow [Googletest Primer](https://google.github.io/googletest/primer.html) and [Advanced googletest Topics](https://google.github.io/googletest/advanced.html).