如何在jenkins中使用GoogleMock?

时间:2015-06-02 16:22:12

标签: c++ gcc jenkins centos googlemock

我在CentOS vm上安装了Jenkins。现在我想用模拟运行unittests(谷歌测试)(谷歌模拟)。我尝试安装类似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’
 ...

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

好像你在CentOS上使用的GCC版本太旧了,无法处理这些可变参数模板。我希望4.4.7可以使用它们,因为the status page似乎表明他们应该这样做。但是this question似乎证实了这种情况。

我的建议是使用dev-toolset 2 repo升级编译器。这将允许您访问CentOS 6上的GCC 4.8(GCC版本是我猜你正在使用的),但是使用修改后的stdlib,这意味着你的二进制文件仍将使用CentOS / RedHat 5的运行时运行。 / p>