Cannot silence test runner

dc1a06b
Opened by phrohdoh at 2020-02-23 20:33:31

IRC Logs

cargo 0.17.0-nightly (740f9c0 2016-12-29)

We should be able to silence the test runner's stdout via --quiet like build and clean's --quiet flag, but alas this is not currently done.

tmba:sentinel thill $ cargo test --quiet -- quiet

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured


running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
tmba:sentinel thill $ cargo test --quiet

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured


running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured

ref: https://github.com/rust-lang/cargo/issues/3482

  1. --quiet prints a compact version of the normal output:

        Finished debug [unoptimized + debuginfo] target(s) in 0.0 secs
         Running /Users/sfackler/code/rust-openssl/target/debug/deps/openssl-3ace7e2ac4871275
    
    running 146 tests
    ..................................................................................................................................................
    test result: ok. 146 passed; 0 failed; 0 ignored; 0 measured
    

    Seems reasonable for --quiet --quiet to completely suppress output though.

    Steven Fackler at 2017-01-01 18:51:57

  2. But --quiet doesn't even do that for me.

    
    tmba:sentinel thill $ cargo test --quiet
    
    running 0 tests
    
    test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
    
    
    running 0 tests
    
    test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
    
    tmba:sentinel thill $ cargo test -- --quiet
        Finished debug [unoptimized + debuginfo] target(s) in 0.0 secs
         Running target/debug/deps/sentinel-0ecd9a282af25c50
    
    running 0 tests
    
    test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
    
       Doc-tests sentinel
    
    running 0 tests
    
    test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
    

    phrohdoh at 2017-01-01 19:24:53

  3. Why doesn't it? It's displaying zero dots for the zero tests it ran.

    Steven Fackler at 2017-01-01 19:25:36

  4. I feel like ultimately -qq could silence test runs completely and just return the exit code; or perhaps we could have an --exit-code option that did the equivalent.

    Mark Rousskov at 2017-05-18 16:05:18

  5. Even with cargo test --quiet -- --quiet (!), it is excessively verbose:

    $ cargo test --quiet -- --quiet
    
    running 0 tests
    
    test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
    
    
    running 7 tests
    .......
    test result: ok. 7 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
    
    
    running 1 test
    .
    test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
    
    
    running 0 tests
    
    test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
    
    

    With --all, this output can easily span multiple pages for a reasonably sized workspace.

    It would be nice to merge all the blocks instead, to eliminate the useless noise (and make --all output actually glanceable):

    $ cargo test --quiet -- --quiet
    running 8 tests
    ........
    test result: ok. 8 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
    

    Gregory Petrosyan at 2017-08-12 13:42:48

  6. I agree that an even quieter setting would be valuable. I would like to see a PR with an implementation.

    In general there is a lot of room for improvement in the cargo test experience. At some point I would love for someone to reimagine how cargo test would work in an ideal world -- a bit like what has been done for error messages over the past year. It would be so wonderful if someone takes the initiative to come up with some design proposals. The RFCs repo or the users forum would be the place to follow up.

    David Tolnay at 2017-11-18 23:46:36

  7. Triage: no changes

    Steve Klabnik at 2020-02-23 20:33:31