Establish gtest version Establish gtest version linux linux

Establish gtest version


The source code of libgtest or libgtest_main libraries doesn't contain special functions which allow recognize their version (something like GetGTestVersion () or something else).Also header files doesn't have any defined identifiers (something like GTEST_VERSION or something else).So you can’t check version of Google C++ Testing Framework at runtime inside user code.

But maintainers provide as part of the framework special script scripts/gtest-conf which:

...provides access to the necessary compile and linkingflags to connect with Google C++ Testing Framework, both in a build prior toinstallation, and on the system proper after installation....

Among other things this script has several options which connected with version:

...Installation Queries:...--version the version of the Google Test installationVersion Queries:--min-version=VERSION return 0 if the version is at least VERSION--exact-version=VERSION return 0 if the version is exactly VERSION--max-version=VERSION return 0 if the version is at most VERSION...

The script also contain usage example of it:

Examples:gtest-config --min-version=1.0 || echo "Insufficient Google Test version."...

It means that user can test version of the framework in build time using script gtest-config.

Note:

The script gtest-config get actual version of the framework during configuration through variables declared in configure.ac.

...AC_INIT([Google C++ Testing Framework],        [1.7.0],        [googletestframework@googlegroups.com],        [gtest])...

And after calling autoconf the following identifiers inside configure file populated:

...# Identity of this package.PACKAGE_NAME='Google C++ Testing Framework'PACKAGE_TARNAME='gtest'PACKAGE_VERSION='1.7.0'PACKAGE_STRING='Google C++ Testing Framework 1.7.0'PACKAGE_BUGREPORT='googletestframework@googlegroups.com'PACKAGE_URL=''...# Define the identity of the package.PACKAGE='gtest'VERSION='1.7.0'...

As far the framework compiled with option AC_CONFIG_HEADERS this identifiers stored into file build-aux/config.h and availiable for user at compile time.


The file CHANGES, in the gtest home directory, contains a gtest version number.


If you have cloned the official repo you can check the latest Git commit inside Google Test's directory (using for example git log -n 1 or git rev-parse HEAD) and compare it with the list of released versions.

In my case, the commit hash is ec44c6c1675c25b9827aacd08c02433cccde7780, which turns out to correspond to release-1.8.0.