Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cargo test can't find doc tests when --format=json option is presented #102957

Closed
mchernyavsky opened this issue Oct 12, 2022 · 1 comment
Closed
Labels
C-bug Category: This is a bug. regression-untriaged Untriaged performance or correctness regression.

Comments

@mchernyavsky
Copy link

Code

I tried this command:

$ cargo test

on this code (lib.rs):

/// ```
/// ();
/// ```
fn _foo() {}

The result is:

   Compiling sandbox v0.1.0 (/Users/Mikhail.Chernyavsky/CLionProjects/sandbox)
    Finished test [unoptimized + debuginfo] target(s) in 0.13s
     Running unittests src/lib.rs (target/debug/deps/sandbox-c45f1323f0f92a37)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

   Doc-tests sandbox

running 1 test
test src/lib.rs - _foo (line 1) ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.17s

As expected, cargo found 1 doc test. But when I add --format=json option to the command line:

$ cargo test -- -Z unstable-options --format=json

I expected to see this:

    Finished test [unoptimized + debuginfo] target(s) in 0.00s
     Running unittests src/lib.rs (target/debug/deps/sandbox-c45f1323f0f92a37)
{ "type": "suite", "event": "started", "test_count": 0 }
{ "type": "suite", "event": "ok", "passed": 0, "failed": 0, "ignored": 0, "measured": 0, "filtered_out": 0, "exec_time": 0.00002886 }
   Doc-tests sandbox
{ "type": "suite", "event": "started", "test_count": 1 }
{ "type": "test", "event": "started", "name": "src/lib.rs - _foo (line 1)" }
{ "type": "test", "name": "src/lib.rs - _foo (line 1)", "event": "ok" }
{ "type": "suite", "event": "ok", "passed": 1, "failed": 0, "ignored": 0, "measured": 0, "filtered_out": 0, "exec_time": 0.171079421 }

Instead, I got this:

    Finished test [unoptimized + debuginfo] target(s) in 0.00s
     Running unittests src/lib.rs (target/debug/deps/sandbox-c45f1323f0f92a37)
{ "type": "suite", "event": "started", "test_count": 0 }
{ "type": "suite", "event": "ok", "passed": 0, "failed": 0, "ignored": 0, "measured": 0, "filtered_out": 0, "exec_time": 0.000027173 }

Version it worked on

It most recently worked on: nightly-2022-10-02

Version with regression

nightly-2022-10-08

rustc --version --verbose:

rustc 1.63.0-dev
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-apple-darwin
release: 1.63.0-dev
LLVM version: 14.0.4
@mchernyavsky mchernyavsky added C-bug Category: This is a bug. regression-untriaged Untriaged performance or correctness regression. labels Oct 12, 2022
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Oct 12, 2022
@ehuss
Copy link
Contributor

ehuss commented Oct 12, 2022

Thanks for the report! This was a regression in cargo. There was a brief window between 10-05 and 10-08 with this issue. If you update to the latest nightly, it should work.

Closing as a duplicate of rust-lang/cargo#11191. Feel free to comment if the latest nightly doesn't work.

@ehuss ehuss closed this as not planned Won't fix, can't repro, duplicate, stale Oct 12, 2022
@apiraino apiraino removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Oct 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. regression-untriaged Untriaged performance or correctness regression.
Projects
None yet
Development

No branches or pull requests

4 participants