I have a target //src/hello:hello_proj.bit which should not be a dependency for any tests. This is confirmed by:
$ 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
And:
$ 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
In addition, the following returns no results:
$ bazel aquery 'deps(tests(//...))' | grep hello_proj.bit
But yet the following still tries to build //src/hello:hello_proj.bit even though the tests can complete successfully if --keep_going is issued. So clearly it is not truly a dependecy but ends up in the action graph for some unknown reason.
$ 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
I'm at a loss at what else to try to dig into this. No query, cquery, or aquery that I have tried has yielded any connection from any test to //src/hello:hello_proj.bit. What am I missing?
In bazel, the test verb is essentially "build the given targets and execute any of them that are tests".
//... expands to all targets in the current workspace, which therefore includes //src/hello:hello_proj.bit
So here bazel is building everything (//...) and then running any tests.
To build just the test cases, pass --build_tests_only
Related
I followed these instrcutions:
cd /path/to/drake
bazel build //... # Build the entire project.
bazel test //... # Build and test the entire project.
But, I got the following error:
[----------] Global test environment tear-down
[==========] 31 tests from 17 test suites ran. (123 ms total)
[ PASSED ] 30 tests.
[ FAILED ] 1 test, listed below:
[ FAILED ] TestSOS.MotzkinPolynomial
1 FAILED TEST
================================================================================
INFO: Elapsed time: 1.431s, Critical Path: 0.32s
INFO: 3 processes: 1 internal, 1 linux-sandbox, 1 local.
INFO: Build completed, 1 test FAILED, 3 total actions
//solvers:csdp_solver_test FAILED in 0.2s
/home/aj/.cache/bazel/_bazel_aj/84dff73cad498d702e4464d2c661c905/execroot/drake/bazel-out/k8-opt/testlogs/solvers/csdp_solver_test/test.log
Executed 2 out of 6054 tests: 6053 tests pass and 1 fails locally.
INFO: Build completed, 1 test FAILED, 3 total actions
My OS is Ubuntu 20 and my complier is gcc 9.
Here is the link to my test.log file.
It is solved by sudo apt remove libatlas3-base
The detailed discussion is at this link.
bazel run #maven//:pin
Starting local Bazel server and connecting to it...
INFO: Analyzed target #maven//:pin (7 packages loaded, 26 targets configured).
INFO: Found 1 target...
Target #maven//:pin up-to-date:
bazel-bin/external/maven/pin
bazel-bin/external/maven/pin.exe
INFO: Elapsed time: 14.964s, Critical Path: 0.13s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Build completed successfully, 1 total action
Starting local Bazel server and connecting to it...
C:\Users\mohit.jaiswal_bazel_mohit.jaiswal\3crxb23l\execroot_main_\bazel-out\x64_windows-fastbuild\bin\external\maven\pin: line 13: ../maven/jq: No such file o
r directory
and maven_install.json file is showing empty
Make sure github.com/bazelbuild/rules_jvm_external is added properly in the worksapce file. Clean the build by [bazel clean --expunge] and try compiling it again.
I'm writing analysis-time tests for my project as per https://docs.bazel.build/versions/master/skylark/testing.html and I'm wondering what the most useful way of reporting failures is.
Using the unittest.bzl module, I am using asserts.equals, asserts.true etc and find the error reporting in the logs somewhat lacking. For example, if an asserts.true fails the error message is Expected condition to be true, but was false, with no mention of which line, or what the condition it expected to be true was. In a file full of lots of tests, this isn't very useful! I'm aware one can add a message as an argument to these assertions, but having tailored messages for every assertion doesn't feel ideal either. Is there a way to get at the backtrace caused by the assertion failure at all? Or any other way of accessing the line number/details of assertion failure?
I took the minimal example from your link and added the latest Skylib release to a new WORKSPACE. I then changed the expected value in _provider_contents_test_impl to make the test fail.
Below is the full output, note the DEBUG that contains a lot of useful info (file, line, expectation, actual value).
$ bazel test //mypkg:myrules_test
DEBUG: /home/user/.cache/bazel/_bazel_user/863abec759a50d843603ddf033727331/external/bazel_skylib/lib/unittest.bzl:351:10: In test _provider_contents_test_impl from //mypkg:myrules_test.bzl: Expected "some valuexxxxx", but got "some value"
INFO: Analyzed target //mypkg:provider_contents_test (0 packages loaded, 0 targets configured).
INFO: Found 1 test target...
FAIL: //mypkg:provider_contents_test (see /home/user/.cache/bazel/_bazel_user/863abec759a50d843603ddf033727331/execroot/__main__/bazel-out/k8-fastbuild/testlogs/mypkg/provider_contents_test/test.log)
Target //mypkg:provider_contents_test up-to-date:
bazel-bin/mypkg/provider_contents_test.sh
INFO: Elapsed time: 0.108s, Critical Path: 0.04s
INFO: 2 processes: 2 linux-sandbox.
INFO: Build completed, 1 test FAILED, 2 total actions
//mypkg:provider_contents_test FAILED in 0.0s
/home/user/.cache/bazel/_bazel_user/863abec759a50d843603ddf033727331/execroot/__main__/bazel-out/k8-fastbuild/testlogs/mypkg/provider_contents_test/test.log
INFO: Build completed, 1 test FAILED, 2 total actions
Tracebacks are also supported, see this bug report for example.
tion, actual value).
$ bazel test //mypkg:myrules_test
DEBUG: /home/user/.cache/bazel/_bazel_user/863abec759a50d843603ddf033727331/external/bazel_skylib/lib/unittest.bzl:351:10: In test _provider_contents_test_impl from //mypkg:myrules_test.bzl: Expected "some valuexxxxx", but got "some value"
INFO: Analyzed target //mypkg:provider_contents_test (0 packages loaded, 0 targets configured).
INFO: Found 1 test target...
FAIL: //mypkg:provider_contents_test (see /home/user/.cache/bazel/_bazel_user/863abec759a50d843603ddf033727331/execroot/__main__/bazel-out/k8-fastbuild/testlogs/mypkg/provider_contents_test/test.log)
Target //mypkg:provider_contents_test up-to-date:
bazel-bin/mypkg/provider_contents_test.sh
INFO: Elapsed time: 0.108s, Critical Path: 0.04s
INFO: 2 processes: 2 linux-sandbox.
INFO: Build completed, 1 test FAILED, 2 total actions
//mypkg:provider_contents_test FAILED in 0.0s
/home/user/.cache/bazel/_bazel_user/863abec759a50d843603ddf033727331/execroot/__main__/bazel-out/k8-fastbuild/testlogs/mypkg/provider_contents_test/test.log
INFO: Build completed, 1 test FAILED, 2 total actions
Tracebacks are also supported, see this bug report for example.
Note that asserts.equals will print the actual value on failure, but asserts.true will not - but you can easily work around this by using asserts.equals(env, True, test_val, msg) instead.
How do you run bazel gazelle update-repo command when you have private repository when your go.mod file has private repository in there
❯ bazel run //:gazelle -- update-repos -from_file=search/go.mod
INFO: Analyzed target //:gazelle (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //:gazelle up-to-date:
bazel-bin/gazelle-runner.bash
bazel-bin/gazelle
INFO: Elapsed time: 0.231s, Critical Path: 0.00s
INFO: 0 processes.
INFO: Build completed successfully, 1 total action
INFO: Build completed successfully, 1 total action
go: bitbucket.org/blah/backend-components/go-logging#v1.0.5/go.mod: verifying module: bitbucket.org/blah/backend-components/go-logging#v1.0.5/go.mod: reading https://sum.golang.org/lookup/bitbucket.org/blah/backend-components/go-logging#v1.0.5: 410 Gone
server response:
not found: bitbucket.org/blah/backend-components/go-logging#v1.0.5: reading https://api.bitbucket.org/2.0/repositories/blah/backend-components?fields=scm: 403 Forbidden
server response: Access denied. You must have write or admin access.
gazelle: exit status 1
I can't find it in the docs how, but you set the environment variable GOPRIVATE to a comma-separated list of module-like patters. For example:
export GOPRIVATE='github.com/mycompany/myrepo,*.example.com'
im trying to build abseil on windows using bazel,
the version im trying to build is :
abseil-cpp-20181200
im using the next bazel command:
bazel build
im getting this output:
INFO: Invocation ID: d85f94c1-e562-4ede-9bcd-9ab7e39020f3
Loading:
Loading: 0 packages loaded
Analyzing: 0 targets (0 packages loaded, 0 targets configured)
INFO: Analysed 0 targets (0 packages loaded, 0 targets configured).
INFO: Found 0 targets...
[0 / 1] [-----] BazelWorkspaceStatusAction stable-status.txt
INFO: Elapsed time: 0.261s, Critical Path: 0.01s
INFO: 0 processes.
INFO: Build completed successfully, 1 total action
INFO: Build completed successfully, 1 total action
I see that some folders were created in abseil-cpp-20181200
bazel-abseil-cpp-20181200
bazel-bin
bazel-genfiles
bazel-out
bazel-testlogs
these folders are empty.
the system im using is windows7 64 bit
if more info is needed please tell me and I will supply it,
help is appreciated
bazel build itself doesn't build anything. You'll have to specify a target to tell Bazel what to build. For example, if you want to build strings, specify the target //absl/strings:strings, or //absl/strings for short:
$ bazel build //absl/strings
See the C++ Quickstart for more information.