"bazel test //..." 执行与任何测试无关的操作

ago*_*ing 0 bazel

我有一个目标//src/hello:hello_proj.bit,它不应该成为任何测试的依赖项。这得到了证实:

$ bazel cquery 'rdeps(//..., //src/hello:hello_proj.bit)' --output=label_kind
INFO: Analyzed 38 targets (0 packages loaded, 0 targets configured).
INFO: Found 38 targets...
vivado_bitstream rule //src/hello:hello_proj.bit (43fd5e3)
vivado_config_memory rule //src/hello:hello_proj.bin (43fd5e3)
vivado_load rule //src/hello:hello_proj.load (43fd5e3)
vivado_flash rule //src/hello:hello_proj.flash (43fd5e3)
INFO: Elapsed time: 0.175s
INFO: 0 processes.
INFO: Build completed successfully, 0 total actions
Run Code Online (Sandbox Code Playgroud)

和:

$ bazel cquery 'allpaths(tests(//...), //src/hello:hello_proj.bit)'
INFO: Analyzed 38 targets (0 packages loaded, 3 targets configured).
INFO: Found 38 targets...
INFO: Empty query results
INFO: Elapsed time: 0.247s
INFO: 0 processes.
INFO: Build completed successfully, 0 total actions
Run Code Online (Sandbox Code Playgroud)

此外,以下内容不返回任何结果:

$ bazel aquery 'deps(tests(//...))' | grep hello_proj.bit
Run Code Online (Sandbox Code Playgroud)

但是,//src/hello:hello_proj.bit即使如果--keep_going发布测试可以成功完成,以下内容仍然会尝试构建。很明显,它并不是真正的依赖,而是出于某种未知原因最终出现在动作图中。

$ bazel test -s --keep_going //...
INFO: Analyzed 35 targets (0 packages loaded, 0 targets configured).
INFO: Found 26 targets and 9 test targets...
SUBCOMMAND: # //src/hello:hello_proj.bit [action 'Synthesizing hello', configuration: 0decb71fa64362af97ee459b2292a0b5285d3f4092bf077905729774dcbbdb43, execution platform: @local_config_platform//:host]
... Removed for brevity ...
ERROR: /home/agoessling/hdl/src/hello/BUILD:26:15: Synthesizing hello failed (Exit 1):
... Removed for brevity ...
INFO: Elapsed time: 0.339s, Critical Path: 0.18s
INFO: 2 processes: 2 internal.
FAILED: Build did NOT complete successfully
//src/hello:test_hello_ver_BAUD25000000_FREP100000              (cached) PASSED in 0.4s
//src/lib:prove_strobe_div                                      (cached) PASSED in 1.0s
//src/lib:prove_uart_tx                                         (cached) PASSED in 4.2s
//src/lib:test_strobe_div_DIV100                                (cached) PASSED in 0.4s
//src/lib:test_strobe_div_DIV2                                  (cached) PASSED in 0.4s
//src/lib:test_strobe_div_DIV6                                  (cached) PASSED in 0.3s
//src/lib:test_strobe_div_DIV7                                  (cached) PASSED in 0.3s
//src/lib:test_strobe_div_DIV8                                  (cached) PASSED in 0.4s
//src/lib:test_uart_tx_BAUD_DIV3                                (cached) PASSED in 0.4s

Executed 0 out of 9 tests: 9 tests pass.
All tests passed but there were other errors during the build.
FAILED: Build did NOT complete successfully
Run Code Online (Sandbox Code Playgroud)

我不知道还有什么可以尝试深入研究这个问题。不querycquery或者aquery我尝试过的任何测试都产生了任何连接到//src/hello:hello_proj.bit. 我错过了什么?

Mat*_*kay 6

在 bazel 中,test动词本质上是“构建给定的目标并执行其中的任何测试”。

//... 扩展到当前工作区中的所有目标,因此包括 //src/hello:hello_proj.bit

所以这里 bazel 正在构建所有内容 ( //...),然后运行任何测试。

要仅构建测试用例,请传递--build_tests_only