From e0440734a3310caaa42a390dba27aeaf3d8037e7 Mon Sep 17 00:00:00 2001 From: Yue Ying Date: Wed, 19 Aug 2026 14:30:01 -0400 Subject: [PATCH] build: drop the test suite from the serial and omp presets The serial and omp presets are for building the simulation programs, but they also configured and ran the GoogleTest suite, which made GoogleTest an effective prerequisite for the ordinary build path. Both now set SLIMED_BUILD_TESTS=OFF, so tests/CMakeLists.txt is never added and find_package(GTest) never runs -- verified by the absence of any GTest entry in either build directory's CMakeCache.txt. Their workflow presets stop after the build step, and their test presets are removed. The coverage preset is unchanged: coverage without tests is pointless, so it still builds and runs them and still needs GoogleTest. SLIMED_BUILD_TESTS still defaults to ON, so a plain `cmake -S . -B build-test` includes the tests as before. The README's test instructions now use that directory rather than build/, which the serial preset populates without a test target. Co-Authored-By: Claude Opus 5 --- CMakePresets.json | 28 +++++++++++++++------------- README.md | 42 ++++++++++++++++++++++++++++++++---------- 2 files changed, 47 insertions(+), 23 deletions(-) diff --git a/CMakePresets.json b/CMakePresets.json index acfb2d7..b411f9b 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -16,23 +16,29 @@ "name": "serial", "inherits": "base", "displayName": "Serial", - "description": "Default build, no OpenMP (was: make serial / make dyna)", + "description": "Simulation programs only, no OpenMP, no GoogleTest (was: make serial / make dyna)", "binaryDir": "${sourceDir}/build", - "cacheVariables": { "SLIMED_ENABLE_OPENMP": "OFF" } + "cacheVariables": { + "SLIMED_ENABLE_OPENMP": "OFF", + "SLIMED_BUILD_TESTS": "OFF" + } }, { "name": "omp", "inherits": "base", "displayName": "OpenMP", - "description": "OpenMP build, -fopenmp and -DOMP (was: make omp / make dyna_omp)", + "description": "Simulation programs only, -fopenmp and -DOMP, no GoogleTest (was: make omp / make dyna_omp)", "binaryDir": "${sourceDir}/build-omp", - "cacheVariables": { "SLIMED_ENABLE_OPENMP": "ON" } + "cacheVariables": { + "SLIMED_ENABLE_OPENMP": "ON", + "SLIMED_BUILD_TESTS": "OFF" + } }, { "name": "coverage", "inherits": "base", "displayName": "Coverage", - "description": "Serial build instrumented for gcov/lcov (was: make test COVERAGE=1)", + "description": "Instrumented for gcov/lcov; builds and runs the tests, so needs GoogleTest (was: make test COVERAGE=1)", "binaryDir": "${sourceDir}/build-cov", "cacheVariables": { "SLIMED_ENABLE_OPENMP": "OFF", @@ -53,28 +59,24 @@ "hidden": true, "output": { "outputOnFailure": true } }, - { "name": "serial", "inherits": "base", "configurePreset": "serial" }, - { "name": "omp", "inherits": "base", "configurePreset": "omp" }, { "name": "coverage", "inherits": "base", "configurePreset": "coverage" } ], "workflowPresets": [ { "name": "serial", - "displayName": "Configure, build and test the serial version", + "displayName": "Configure and build the serial version", "steps": [ { "type": "configure", "name": "serial" }, - { "type": "build", "name": "serial" }, - { "type": "test", "name": "serial" } + { "type": "build", "name": "serial" } ] }, { "name": "omp", - "displayName": "Configure, build and test the OpenMP version", + "displayName": "Configure and build the OpenMP version", "steps": [ { "type": "configure", "name": "omp" }, - { "type": "build", "name": "omp" }, - { "type": "test", "name": "omp" } + { "type": "build", "name": "omp" } ] }, { diff --git a/README.md b/README.md index d0e9fbd..8a4b8ea 100644 --- a/README.md +++ b/README.md @@ -115,13 +115,17 @@ SLIMED builds with CMake. Because serial and OpenMP builds are both used routinely, `CMakePresets.json` defines them as named presets, each with its own build directory: -| Preset | Build directory | Equivalent to | -| --- | --- | --- | -| `serial` | `build/` | `make serial` / `make dyna` | -| `omp` | `build-omp/` | `make omp` / `make dyna_omp` | -| `coverage` | `build-cov/` | `make test COVERAGE=1` | +| Preset | Build directory | Builds | Equivalent to | +| --- | --- | --- | --- | +| `serial` | `build/` | simulation programs | `make serial` / `make dyna` | +| `omp` | `build-omp/` | simulation programs | `make omp` / `make dyna_omp` | +| `coverage` | `build-cov/` | programs + unit tests | `make test COVERAGE=1` | + +`serial` and `omp` build the four simulation programs only. They set +`SLIMED_BUILD_TESTS=OFF`, so GoogleTest is never looked for and does not need to +be installed to use them. -Configure, build and test in one command: +Configure and build in one command: ```console cmake --workflow --preset omp @@ -133,7 +137,16 @@ Or drive the steps separately: ```console cmake --preset omp # configure cmake --build --preset omp # build (all cores) -ctest --preset omp # test +``` + +To run the unit tests, either use the `coverage` preset or configure a build +directory by hand -- `SLIMED_BUILD_TESTS` defaults to `ON`, so a plain +configure includes them: + +```console +cmake -S . -B build-test +cmake --build build-test -j8 +ctest --test-dir build-test --output-on-failure ``` Because each preset owns a separate build directory, switching back and forth @@ -276,17 +289,26 @@ libstdc++; use the default Apple Clang when you need the tests. ### Tests +`SLIMED_BUILD_TESTS` defaults to `ON`, so any build directory configured by hand +includes the unit tests: + ```console -ctest --test-dir build --output-on-failure +cmake -S . -B build-test +cmake --build build-test -j8 +ctest --test-dir build-test --output-on-failure ``` +Note that the `serial` and `omp` presets deliberately set it to `OFF`, so +`build/` and `build-omp/` contain no tests; use a separate directory as above, +or the `coverage` preset. + Each GoogleTest case is registered with CTest individually. Several tests open fixture files by paths relative to the working directory, so CTest runs `test_main` from the top of the source tree automatically. The binary can also be run directly, from the source root: ```console -./build/bin/test_main +./build-test/bin/test_main ``` If GoogleTest is not installed, CMake prints a warning and skips the test @@ -311,7 +333,7 @@ collect. There is no packaged `coverage-html` target yet. ```console cmake --build build --target clean # like "make clean"; keeps the configuration rm -rf build # full reset, forgets all cached options -rm -rf build build-omp build-cov # remove every preset build directory +rm -rf build build-omp build-cov build-test # remove all build directories ``` ### The previous Makefile