c++ - 我如何在 Jenkins 中使用 GoogleMock?

标签 c++ gcc jenkins centos googlemock

我在 CentOS 虚拟机上安装了 Jenkins。现在我想用模拟(谷歌模拟)运行单元测试(谷歌测试)。我尝试像 here 中描述的那样安装框架. (在我的 lubuntu 机器上,使用这些步骤一切都可以毫无问题地运行)

当我尝试构建时:

g++ -O2 -pthread -Werror -Wall -o unitTest DriveTest.cpp Drive.cpp PWM.cpp -lgtest -lgtest_main -lgmock

我收到以下错误:

 make unitTest
 g++ -O2 -std=c++0x -pthread -Werror -Wall -o unitTest DriveTest.cpp Drive.cpp PWM.cpp -lgtest -lgtest_main -lgmock
 In file included from /usr/include/gmock/gmock-spec-builders.h:75,
                  from /usr/include/gmock/gmock-generated-function-mockers.h:43,
                  from /usr/include/gmock/gmock.h:61,
                  from PWMMock.h:4,
                  from DriveTest.cpp:1:
 /usr/include/gmock/gmock-matchers.h:1485: sorry, unimplemented: cannot expand ‘Tail ...’ into a fixed-length argument list
 /usr/include/gmock/gmock-matchers.h:1486: error: ‘int’ is not a class type
 /usr/include/gmock/gmock-matchers.h:1486: error: ‘ListType’ in class ‘int’ does not name a type
 /usr/include/gmock/gmock-matchers.h:1486: error: template argument 2 is invalid
 /usr/include/gmock/gmock-matchers.h:1486: error: expected ‘::’ before ‘ListType’
 /usr/include/gmock/gmock-matchers.h: In static member function ‘static int testing::internal::MatcherList<kSize, Head,
 Tail>::BuildList(const Head&, const Tail& ...)’:
 /usr/include/gmock/gmock-matchers.h:1493: error: ‘int’ is not a class type
 /usr/include/gmock/gmock-matchers.h:1493: error: ‘int’ is not a class type
 /usr/include/gmock/gmock-matchers.h:1493: error: ‘int’ is not a class type
 /usr/include/gmock/gmock-matchers.h:1493: error: ‘BuildList’ is not a member of ‘int’
 /usr/include/gmock/gmock-matchers.h: In static member function ‘static testing::Matcher<T> testing::internal::MatcherList<kSize,
 Head, Tail>::CreateMatcher(const int&)’:
 /usr/include/gmock/gmock-matchers.h:1503: error: request for member ‘first’ in ‘matchers’, which is of non-class type ‘const int’
 /usr/include/gmock/gmock-matchers.h:1504: error: ‘int’ is not a class type
 /usr/include/gmock/gmock-matchers.h:1504: error: ‘int’ is not a class type
 /usr/include/gmock/gmock-matchers.h:1504: error: ‘int’ is not a class type
 /usr/include/gmock/gmock-matchers.h:1504: error: ‘int’ is not a class type
 /usr/include/gmock/gmock-matchers.h:1504: error: ‘int’ is not a class type
 /usr/include/gmock/gmock-matchers.h:1504: error: ‘CreateMatcher’ is not a member of ‘int’
 ...

我该如何解决这个问题?

最佳答案

您在 CentOS 上的 GCC 版本似乎太旧,无法处理这些可变参数模板。我希望 4.4.7 从 the status page 开始提供它们似乎表明他们应该。然而this question似乎证实了这一情况。

我的建议是使用 dev-toolset 2 升级编译器 repo 。这将使您可以访问 CentOS 6 上的 GCC 4.8(我猜您使用的是 GCC 版本),但使用经过修改的标准库,这意味着您的二进制文件仍将使用 CentOS/RedHat 5 的运行时运行。

关于c++ - 我如何在 Jenkins 中使用 GoogleMock?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30601438/

相关文章:

Jenkins - 在不同时间触发不同的插件,独立于构建

groovy - 如何在 Jenkins Workflow 中包含外部代码文件

c++ - Jenkins 测试报告分析器与 catch 的集成

Objective C 中的 C++ 函数

c++ - C++中遍历目录和迭代器

c++ - 可接受的 USB MIDI 带宽是多少?

c - 编译C程序时gcc的错误

C++:复制具有加倍节点的二叉树

c++ - 将 HW BP 放在哪里以捕获全局变量地址损坏?

c - 字符串转换宏