我如何知道我正在处理的项目中使用的是哪个版本的Gtest?我在linux平台上工作。
发布于 2014-08-16 20:55:34
libgtest或libgtest_main库的源代码不包含允许识别其版本的特殊函数(如GetGTestVersion ()或其他)。此外,头文件没有任何已定义的标识符(例如GTEST_VERSION或其他标识符)。所以你不能在运行时在用户代码中检查Google C++ Testing Framework的版本。
但是维护者提供了特殊的脚本scripts/gtest-conf作为框架的一部分,它:
...
provides access to the necessary compile and linking
flags to connect with Google C++ Testing Framework, both in a build prior to
installation, and on the system proper after installation.
...这个脚本有几个与版本相关的选项:
...
Installation Queries:
...
--version the version of the Google Test installation
Version 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
...该脚本还包含其使用示例:
Examples:
gtest-config --min-version=1.0 || echo "Insufficient Google Test version."
...这意味着用户可以在构建时使用script gtest-config测试框架的版本。
便笺
在配置期间,脚本gtest-config通过在configure.ac中声明的变量获取框架的实际版本。
...
AC_INIT([Google C++ Testing Framework],
[1.7.0],
[googletestframework@googlegroups.com],
[gtest])
...在调用autoconf之后,configure文件内部填充了以下标识符:
...
# 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'
...到目前为止,使用选项AC_CONFIG_HEADERS编译的框架将标识符存储在文件build-aux/config.h中,并在编译时可供用户使用。
发布于 2013-05-15 11:12:34
gtest主目录中的文件更改包含一个gtest版本号。
发布于 2019-06-19 00:46:20
如果你已经克隆了official repo,你可以在Google Test的目录中检查最新的Git提交(例如使用git log -n 1或git rev-parse HEAD),并将其与released versions列表进行比较。
在我的例子中,提交散列是ec44c6c1675c25b9827aacd08c02433cccde7780,结果是对应于release-1.8.0。
https://stackoverflow.com/questions/14687282
复制相似问题