gpt4 book ai didi

googletest - 为什么我的 Bazel 测试在所有单独测试都通过时报告失败?

转载 作者:行者123 更新时间:2023-12-04 17:35:42 24 4
gpt4 key购买 nike

通过 Bazel 运行我的单元测试 (gtest) 时,我看到报告失败。但是,日志表明我的测试运行成功并通过。

我项目中的其他测试都通过了,异常测试与其他测试之间的唯一区别是异常测试是多线程的。

我自己运行了在 bazel-bin 中找到的测试二进制文件,它通过并成功返回。

Bazel 版本:

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 文件中的相关 block :

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 测试失败输出:

>> 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 测试结果报告为通过,因为实际测试正在通过,但我看到测试失败。

最佳答案

在优雅地终止我的项目生成的所有线程时,这个问题已得到解决。

关于googletest - 为什么我的 Bazel 测试在所有单独测试都通过时报告失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56748111/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com