From 56aa5b0d8c6b66369f979e8bee4f1bd99454a99f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Thu, 16 Jul 2020 12:58:49 +0200 Subject: T73268: Link C/C++ unit tests into single executable This commit introduces a new way to build unit tests. It is now possible for each module to generate its own test library. The tests in these libraries are then bundled into a single executable. The test executable can be run with `ctest`. Even though the tests reside in a single executable, they are still exposed as individual tests to `ctest`, and thus can be selected via its `-R` argument. Not yet ported tests still build & run as before. The following rules apply: - Test code should reside in the same directory as the code under test. - Tests that target functionality in `somefile.{c,cc}` should reside in `somefile_test.cc`. - The namespace for tests is the `tests` sub-namespace of the code under test. For example, tests for `blender::bke` should be in `blender::bke:tests`. - The test files should be listed in the module's `CMakeLists.txt` in a `blender_add_test_lib()` call. See the `blenkernel` module for an example. Reviewed By: brecht Differential Revision: https://developer.blender.org/D7649 --- tests/gtests/CMakeLists.txt | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'tests/gtests/CMakeLists.txt') diff --git a/tests/gtests/CMakeLists.txt b/tests/gtests/CMakeLists.txt index 0dfe041974e..4ce68a6f4c0 100644 --- a/tests/gtests/CMakeLists.txt +++ b/tests/gtests/CMakeLists.txt @@ -1,18 +1,13 @@ -# GTest if(WITH_GTESTS) - - include(GTestTesting) - - add_definitions(${GFLAGS_DEFINES}) - add_definitions(${GLOG_DEFINES}) - add_definitions(-DBLENDER_GFLAGS_NAMESPACE=${GFLAGS_NAMESPACE}) - # Otherwise we get warnings here that we cant fix in external projects remove_strict_flags() + # Build common test runner + add_subdirectory(runner) + + # Build tests not yet ported to the common runner add_subdirectory(testing) - add_subdirectory(blenkernel) add_subdirectory(blenlib) add_subdirectory(blenloader) add_subdirectory(guardedalloc) -- cgit v1.2.3