Skip to content

cargo test does not report failures when a test exits the process #87323

@EverlastingBugstopper

Description

@EverlastingBugstopper

Problem
I'm running cargo test with tests that fail, and it exits with code 0 and does not gather and report errors.

Steps

  1. git clone https://github.com/apollographql/rover
  2. git checkout avery/repro-tests
  3. Notice there is a test at the root crate that has a single call to panic!("It fails")
  4. Run cargo test, you should notice the FAILED test only if you scroll up to look for it, the message at the end makes you think the tests pass.
  5. Run echo $? and see output 0

Possible Solution(s)
No idea why this is happening and... it's quite alarming!

If I run the same tests through my IDE, it makes a call to cargo test --package rover --lib -- test command::supergraph::config::tests::it_can_fail_a_test --exact --nocapture < which does fail properly!

Notes

$ cargo version
cargo 1.53.0 (4369396ce 2021-04-27)
$ rustc -V      
rustc 1.53.0 (53cb7b09b 2021-06-17)
$ rustup version
rustup 1.24.3 (ce5817a94 2021-05-31)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.53.0 (53cb7b09b 2021-06-17)`

This seems to be a cross-platform bug, as our CI runner does not detect issues with any of the following targets:

x86_64-unknown-linux-musl,
x86_64-unknown-linux-gnu,
x86_64-pc-windows-msvc,
x86_64-apple-darwin,

This is a workspace using the 2018 edition, and seems to happen on test runs with both v1 and v2 of the resolver. It also happens whether you're testing a single package with -p, the whole workspace with --workspace, or just cargo test by itself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-libtestArea: `#[test]` / the `test` library

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions