我想用buildbot和gtest设置一个持续集成服务器。我已经设法在单元测试步骤之后设置了导致以下输出的环境:
Running main() from gtest_main.cc
[==========] Running 7 tests from 3 test cases.
[----------] Global test environment set-up.
[----------] 4 tests from VectorTest
[ RUN ] VectorTest.size_is_correct
[ OK ] VectorTest.size_is_correct (0 ms)
[ RUN ] VectorTest.min_index
[ OK ] VectorTest.min_index (0 ms)
[ RUN ] VectorTest.sort_is_correct
[ OK ] VectorTest.sort_is_correct (0 ms)
[ RUN ] VectorTest.indices_of_smallest_are_correct
[ OK ] VectorTest.indices_of_smallest_are_correct (0 ms)
[----------] 4 tests from VectorTest (0 ms total)
[----------] 2 tests from MatrixTest
[ RUN ] MatrixTest.NumberOfColumnsIsCorrect
[ OK ] MatrixTest.NumberOfColumnsIsCorrect (0 ms)
[ RUN ] MatrixTest.NumberOfRowsIsCorrect
[ OK ] MatrixTest.NumberOfRowsIsCorrect (0 ms)
[----------] 2 tests from MatrixTest (0 ms total)
[----------] 1 test from SparseMatrix
[ RUN ] SparseMatrix.IteratorIsCorrect
[ OK ] SparseMatrix.IteratorIsCorrect (0 ms)
[----------] 1 test from SparseMatrix (0 ms total)
[----------] Global test environment tear-down
[==========] 7 tests from 3 test cases ran. (2 ms total)
[ PASSED ] 7 tests.
[100%] Built target unit
我希望buildbot解析此输出,以便检查关键字PASSED是否存在,以便在单元测试期间知道是否出现了问题。
你知道怎么做吗?
答案 0 :(得分:1)
GoogleTest使用命令行选项--gtest_output
支持JUnit格式的XML输出,大多数CI系统已经知道如何解析。
我不知道Buildbot是否支持JUnit解析。如果没有,那么解析XML结构化输出肯定比标准纯文本输出更容易。
答案 1 :(得分:1)
为什么不检查测试程序的退出代码?如果测试通过,它将是成功代码(0),如果失败则通常是失败(通常为1)。