From c2d273b10194825c78517ee992b0edffe4ded84e Mon Sep 17 00:00:00 2001 From: wqzhou <33364058+WHUweiqingzhou@users.noreply.github.com> Date: Tue, 25 Jul 2023 11:39:15 +0800 Subject: [PATCH] Doc: add some details of UnitTest and Converge in Documentation (#2752) * add some details of UnitTest and Converge * Update docs/CONTRIBUTING.md Co-authored-by: Chun Cai --------- Co-authored-by: Chun Cai --- docs/CONTRIBUTING.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index 9f9ad2649d..81bc330617 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -113,7 +113,7 @@ Configure your VS Code settings as `"C_Cpp.clang_format_style": "file"` (you can ## Adding a unit test -We use GoogleTest as our test framework. Write your test under the corresponding module folder at `abacus-develop/tests`, then append the test to `tests/CMakeLists.txt`. If there are currently no unit tests provided for the module, do as follows. `module_base` provides a simple demonstration. +We use [GoogleTest](https://github.com/google/googletest) as our test framework. Write your test under the corresponding module folder at `abacus-develop/tests`, then append the test to `tests/CMakeLists.txt`. If there are currently no unit tests provided for the module, do as follows. `module_base` provides a simple demonstration. - Add a folder named `test` under the module. - Append the content below to `CMakeLists.txt` of the module: @@ -142,8 +142,9 @@ To add a unit test: ) ``` -- Build with `-D BUILD_TESTING=1` flag. You can find built testing programs under `build/source//test`. +- Build with `-D BUILD_TESTING=1` flag, `cmake` will look for `GoogleTest` in the default path (usually `/usr/local`); if not found, you can specify the path with `-D GTEST_DIR`. You can find built testing programs under `build/source//test`. - Follow the installing procedure of CMake. The tests will move to `build/test`. +- Considering `-D BUILD_TESTING=1`, the compilation will be slower compared with the case `-D BUILD_TESTING=0`. ## Debugging the codes @@ -187,6 +188,8 @@ This feature requires using GCC compiler. We use `gcov` and `lcov` to generate c cmake --build build --target test ARGS="-V --timeout 21600" ``` +If configuration fails unfortunately, you can find [required files](https://github.com/baixiaokuang/CMake-codecov/tree/master/cmake) (including three *.cmake and llvm-cov-wrapper), and copy these four files into `/abacus-develop/cmake`. Alternatively, you can define the path with option `-D CMAKE_CURRENT_SOURCE_DIR`. + 3. Generate HTML report. ```bash