Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make errors from
make_test_list
legible (#1228)
In debugging <sourcefrog/cargo-mutants#226> I found that invocations like `~/.rustup/toolchains/beta-x86_64-unknown-linux-gnu/bin/cargo nextest run` cause some test failures in the nextest tree, for reasons I'm still working to understand. In `main`, those errors are printed like this, with a pile of ASCII byte values: ``` thread 'basic::test_termination' panicked at nextest-runner/tests/integration/fixtures.rs:383:10: test list successfully created: CommandFail { binary_id: RustBinaryId("cdylib-example"), command: ["/home/mbp/src/nextest/fixtures/nextest-tests/target/debug/deps/cdylib_example-9222c584dde9dbd0", "--list", "--format", "terse"], exit_status: ExitStatus(unix_wait_status(32512)), stdout: [], stderr: [47, 104, 111, 109, 101, 47, 109, 98, 112, 47, 115, 114, 99, 47, 110, 101, 120, 116, 101, 115, 116, 47, 102, 105, 120, 116, 117, 114, 101, 115, 47, 110, 101, 120, 116, 101, 115, 116, 45, 116, 101, 115, 116, 115, 47, 116, 97, 114, 103, 101, 116, 47, 100, 101, 98, 117, 103, 47, 100, 101, 112, 115, 47, 99, 100, 121, 108, 105, 98, 95, 101, 120, 97, 109, 112, 108, 101, 45, 57, 50, 50, 50, 99, 53, 56, 52, 100, 100, 101, 57, 100, 98, 100, 48, 58, 32, 101, 114, 114, 111, 114, 32, 119, 104, 105, 108, 101, 32, 108, 111, 97, 100, 105, 110, 103, 32, 115, 104, 97, 114, 101, 100, 32, 108, 105, 98, 114, 97, 114, 105, 101, 115, 58, 32, 108, 105, 98, 116, 101, 115, 116, 45, 99, 98, 97, 98, 55, 49, 54, 57, 55, 100, 102, 57, 55, 98, 48, 48, 46, 115, 111, 58, 32, 99, 97, 110, 110, 111, 116, 32, 111, 112, 101, 110, 32, 115, 104, 97, 114, 101, 100, 32, 111, 98, 106, 101, 99, 116, 32, 102, 105, 108, 101, 58, 32, 78, 111, 32, 115, 117, 99, 104, 32, 102, 105, 108, 101, 32, 111, 114, 32, 100, 105, 114, 101, 99, 116, 111, 114, 121, 10] } note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ``` This is because `unwrap` prints the `Debug` form and the error holds a `Vec<u8>`. There could be a few ways to change this but it seemed like the intention of the existing code was to keep the exact output in the error enum as bytes, and only do lossy conversion to UTF-8 from Display. So, I looked for a way to get the Display form printed, and it seemed like a good way was to just return the error, since the tests that call this already themselves return Results. With this applied the failures are much more helpful: ``` error: creating test list failed Caused by: for `cdylib-example`, command `/tmp/nextest-fixtureQWK72c/src/target/debug/deps/cdylib_example-9222c584dde9dbd0 --list --format terse` exited with code 127 --- stdout: --- stderr: /tmp/nextest-fixtureQWK72c/src/target/debug/deps/cdylib_example-9222c584dde9dbd0: error while loading shared libraries: libtest-cbab71697df97b00.so: cannot open shared object file: No such file or directory --- ```
- Loading branch information