Project

General

Profile

Task #3033

Clean up and modernize googletest bundling and usage

Added by Eric Irrgang about 1 month ago. Updated 7 days ago.

Status:
In Progress
Priority:
Normal
Assignee:
-
Category:
build system
Difficulty:
uncategorized
Close

Description

There is a little bit of noise left from https://gerrit.gromacs.org/c/gromacs/+/7502 but there is also some house keeping we can do.

Because we have moved to CMake 3.9, we could start using the https://cmake.org/cmake/help/v3.9/module/GoogleTest.html and
https://cmake.org/cmake/help/latest/module/GoogleTest.html#command:gtest_add_tests

We would also like to store a single copy of the googletest source in the repository, but we need to find a good way to use the bundled source when building the python_packaging/sample_restraint tests in the same build tree.

modernizing usage in CMake

0. Reduce use of global CMake variables for tests and test support targets (https://gerrit.gromacs.org/c/gromacs/+/12197)
1. Move custom googletest CMakeLists.txt file out of the way so that we can have a more standard googletest distribution in place.
2. Remove global definitions of variables that are redundant with properties of the gtest and gmock targets.
3. Import missing googletest files that allow for standard definitions of gtest and gmock targets. Replace GROMACS custom targets with standard targets.
4. Migrate consuming targets from variable usage to target dependencies and other modern CMake tools.


Related issues

Related to GROMACS - Task #3027: Move sample_restraint development from GitHub to GerritIn Progress
Related to GROMACS - Task #2756: gmxapi integration testingIn Progress

Associated revisions

Revision e97a85b3 (diff)
Added by Eric Irrgang about 1 month ago

Remove extraneous file.

A file was overlooked in Change-Id: I0d847bc2490935e0ddc3170b674d7460a5a08506

Refs #3033

Change-Id: I4fb6af0b6d51b477091c6305872c0c7124e754d6

Revision 9efd4499 (diff)
Added by Eric Irrgang 21 days ago

Reduce conflicts with external googletest files.

Move the custom googletest CMakeLists.txt up a level to src/external so
that we can just drop in the downloaded googletest bundle as it is
distributed. In a future change, we can use the gmock and gtest targets
defined in that infrastructure instead of sculpting our own.

Refs #3033

Change-Id: I4c8ed84195f7673fd798301ba149de8c122ccb05

Revision 1e4d5573 (diff)
Added by Eric Irrgang 17 days ago

Convert test infrastructure targets to static library targets.

Convert CMake function `gmx_add_unit_test_object_library()` to
`gmx_add_unit_test_library()` and produce STATIC instead of OBJECT
targets. Update `mdrun_test_objlib` to `mdrun_test_infrastructure`
using the helper function.

This allows the target to use `target_link_libraries` to get the
compiler flags, definitions, and include directories necessary for
compatibility with `gmock` and other resources. Resolves some noisiness
from googletest headers under the standard GROMACS `-Wundef` flag.
Relevant to related change that migrate from global GMOCK variables to
modern usage of gtest and gmock CMake targets.

Removed unnecessary TESTUTILS_LIBS variable.

Refs #3033

Change-Id: Id5b47774b679e8e205f899ea80df65153da44516

Revision f7940fa0 (diff)
Added by Eric Irrgang 15 days ago

Use gmock and gtest targets from googletest-release-1.8.0

Import a couple of missing files from the googletest-release-1.8.0 and
switch to the upstream definition of the `gmock` and `gtest` targets.

Removed some outdated content from README.Gromacs

Refs #3033

Change-Id: Iaefe4d11b01a3d37e162d7d00bae7ba34a0b5b4e

Revision 298f4798 (diff)
Added by Eric Irrgang 10 days ago

Improve sample_restraint project integration.

Build for testing as part of a gmxapi enabled GROMACS build. Fix some
errors and collisions.

  • Use distinct CMake options for using bundled pybind sources in
    gmxapi Python package and sample_restraint package.
  • Distinguish between "umbrella" build and standalone build when
    trying to determine googletest source for sample_restraint.
  • Avoid a couple of warnings about unused variables.
  • Use GTest::Main target more consistently for sample_restraint tests.

Refs #2056
Refs #3027
Refs #3033

Change-Id: I55d20e6228779ecc726587231c83298356192f6f

History

#1 Updated by Eric Irrgang about 1 month ago

  • Related to Task #3027: Move sample_restraint development from GitHub to Gerrit added

#2 Updated by Eric Irrgang about 1 month ago

  • Related to Task #2756: gmxapi integration testing added

#3 Updated by Eric Irrgang about 1 month ago

  • Description updated (diff)

#4 Updated by Eric Irrgang about 1 month ago

Eric Irrgang wrote:

We would also like to store a single copy of the googletest source in the repository, but we need to find a good way to use the bundled source when building the python_packaging/sample_restraint tests in the same build tree.

Per discussion with Mark, we can use the googletest distribution bundled in src/external to configure and build a (sub-/external )project that we can then get targets from with add_subdirectory, a la https://github.com/google/googletest/blob/master/googletest/README.md#incorporating-into-an-existing-cmake-project
This entails migrating our customizations and custom src/external/googletest/CMakeLists.txt into more "standard" form (however it is we are supposed to make customizations) so that the 'gtest', 'gtest_main', and 'gmock' targets are defined such that aliases to them will behave the way GTest::Main, etc, are expected to behave.

#5 Updated by Eric Irrgang about 1 month ago

Also to do: update COPYING file.

#6 Updated by Eric Irrgang 25 days ago

  • Description updated (diff)

#7 Updated by Mark Abraham 13 days ago

  • Status changed from New to In Progress

#8 Updated by Eric Irrgang 9 days ago

Remaining tasks under this issue include

- updating to googletest 1.8.1 (or 1.9)
- migrating to the GoogleTest CMake module and gtest_add_tests()

but the primary infrastructure updates are done.

#9 Updated by Mark Abraham 7 days ago

Eric Irrgang wrote:

Remaining tasks under this issue include

- updating to googletest 1.8.1 (or 1.9)

I don't think that offers a compelling advantage for GROMACS 2020 to prioritize more time on it now, but on principle it makes sense to do for GROMACS 2021

- migrating to the GoogleTest CMake module and gtest_add_tests()

Likewise, I suggest we defer that improvement

Also available in: Atom PDF