https://pantsbuild.org/ logo
#development
Title
# development
h

hundreds-breakfast-49010

08/27/2020, 10:39 PM
there's a way to make rust logging appear in the output of a failing pants test, right?
f

fast-nail-55400

08/27/2020, 10:44 PM
when I’ve needed rust logs in tests, I’ve had to add
env_logger
to the crate’s dependencies and then add
env_logger::init()
at the top of the test
and then invoke with
RUST_LOG=trace cargo test — name_of_test
(or whatever level you want)
given rust does not support test setup functions, not that easy to enable logging 😞
h

hundreds-breakfast-49010

08/27/2020, 10:56 PM
turns out its easier to add printfs, which do manifest themselves in the output
that is, the
Captured stdout call
output in pytest
but I think setting
RUST_LOG
might've been what I was looking for
f

fast-nail-55400

08/27/2020, 11:00 PM
be aware that
RUST_LOG
is from the env_logger crate
thus you would still have to setup env_logger
w

witty-crayon-22786

08/28/2020, 12:40 AM
TestBase doesn’t initialize our rust logging
it probably could.