-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Add an ability to print line number or stack trace of the failing assert in unit tests in Starlark #13275
Description
Hello dear Bazel maintainers :)
I'm re-filing this feature request from bazelbuild/bazel-skylib#290.
Right now there is not a way to print an assertion failure with the stack trace. We currently print the assertion error with the location .../external/bazel_skylib/lib/unittest.bzl:351:10:. It would be much more useful if we either printed the entire stack trace, or show the location of the callsite.
An argument could be made that there should be just one assertion per unit test, in that scenario this is not a problem. However there is so much boilerplate involved with adding a unit test that this is not practical to have one assertion per test. And even Bazel's internal BuildViewTestCase tests have multiple assertions per test.
@tetromino suggested to add something like a stacktrace() builtin or perhaps a with_stacktrace optional named parameter to print(). Both sound good to me.
Thank you!