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 --all-targets does NOT run doctests #11015

Closed
crepererum opened this issue Aug 23, 2022 · 1 comment
Closed

cargo test --all-targets does NOT run doctests #11015

crepererum opened this issue Aug 23, 2022 · 1 comment
Labels
C-bug Category: bug

Comments

@crepererum
Copy link

Problem

While cargo test runs unit tests AND doctests (no matter if they are marked to run or just to compile), cargo test --all-targets does not which is counterintuitive. The documentation for --all-targets reads: "Test all targets".

Steps

  1. Create a new crate via cargo init --lib
  2. Add a failing doctest at the top of src/lib.rs:
    //! ```
    //! does not compile
    //! ```
  3. Run cargo test, this will fail.
  4. Run cargo test --all-targets, this will pass.

Possible Solution(s)

Also run doctests when --all-targets is passed.

Notes

This MIGHT be related to #6424, but that issue talks specifically about cargo check and that is seems to be impossible to run check on doctests.

Version

cargo 1.63.0 (fd9c4297c 2022-07-01)
release: 1.63.0
commit-hash: fd9c4297ccbee36d39e9a79067edab0b614edb5a
commit-date: 2022-07-01
host: x86_64-unknown-linux-gnu
libgit2: 1.4.2 (sys:0.14.2 vendored)
libcurl: 7.83.1-DEV (sys:0.4.55+curl-7.83.1 vendored ssl:OpenSSL/1.1.1n)
os: Arch Linux [64-bit]
@crepererum crepererum added the C-bug Category: bug label Aug 23, 2022
@ehuss
Copy link
Contributor

ehuss commented Aug 23, 2022

Thanks for the report! Closing as a duplicate of #6669.

@ehuss ehuss closed this as not planned Won't fix, can't repro, duplicate, stale Aug 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

2 participants