通过Bazel运行单元测试(gtest)时,我看到了失败的报告。但是,日志表明我的测试正在成功运行并通过。
我项目中的其他测试正在通过,并且偏差测试与其他测试之间的唯一区别是偏差测试是多线程的。
我自己运行了bazel-bin
中的测试二进制文件,它成功通过并返回。
挡板版本:
Build label: 0.26.0
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Tue May 28 08:35:14 2019 (1559032514)
Build timestamp: 1559032514
Build timestamp as int: 1559032514
我的BUILD
文件中的相关块:
cc_test(
name = "DBControllerIntegration",
srcs = ["dbcontroller_integration_test.cc"],
deps = [
"//src:db_ctl_lib",
"//test/mocks:sstable_mock_lib",
"@boost//:filesystem",
"@com_google_protobuf//:protobuf",
"@glog//:glog",
"@googletest//:gtest_main",
],
copts = ["-std=c++17"],
)
面板测试失败输出:
>> bazel test //test:DBControllerIntegration --test_output=errors
INFO: Invocation ID: ccca8fa7-27a5-4c8c-badf-3f342934e4e5
INFO: Analysed target //test:DBControllerIntegration (0 packages loaded, 0 targets configured).
INFO: Found 1 test target...
FAIL: //test:DBControllerIntegration (see /home/tallen/.cache/bazel/_bazel_tallen/f087948e065d612174d90a43a5740198/execroot/diodb/bazel-out/k8-dbg/testlogs/test/DBControllerIntegration/test.log)
INFO: From Testing //test:DBControllerIntegration:
==================== Test output for //test:DBControllerIntegration:
Running main() from gmock_main.cc
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from DBControllerIntegrationTest
[ RUN ] DBControllerIntegrationTest.Basic
... <omitting my application's logs> ...
[ OK ] DBControllerIntegrationTest.Basic (4000 ms)
[----------] 1 test from DBControllerIntegrationTest (4000 ms total)
[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran. (4001 ms total)
[ PASSED ] 1 test.
================================================================================
Target //test:DBControllerIntegration up-to-date:
bazel-bin/test/DBControllerIntegration
INFO: Elapsed time: 4.706s, Critical Path: 4.57s
INFO: 1 process: 1 processwrapper-sandbox.
INFO: Build completed, 1 test FAILED, 2 total actions
//test:DBControllerIntegration FAILED in 4.6s
/home/tallen/.cache/bazel/_bazel_tallen/f087948e065d612174d90a43a5740198/execroot/diodb/bazel-out/k8-dbg/testlogs/test/DBControllerIntegration/test.log
INFO: Build completed, 1 test FAILED, 2 total actions
自行运行测试二进制文件:
>> ./bazel-bin/test/DBControllerIntegration
Running main() from gmock_main.cc
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from DBControllerIntegrationTest
[ RUN ] DBControllerIntegrationTest.Basic
... <omitting my application's logs> ...
[ OK ] DBControllerIntegrationTest.Basic (4001 ms)
[----------] 1 test from DBControllerIntegrationTest (4001 ms total)
[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran. (4001 ms total)
[ PASSED ] 1 test.
我希望自实际测试通过以来,Bazel测试结果会报告为通过,但我认为测试失败。
答案 0 :(得分:1)
正常终止由我的项目产生的所有线程时,此问题得以解决。