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

Allow enabling / disabling doc tests as a CLI flag and a .cargo/config option #1789

Closed
carllerche opened this issue Jul 7, 2015 · 11 comments
Labels
A-configuration Area: cargo config files and env vars C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-test

Comments

@carllerche
Copy link
Member

It would be nice to be able to enable / disable doc tests as a CLI flag and a local (.cargo/config) option.

@alexcrichton
Copy link
Member

This was motivated because doctests don't work for cross-compiled testing right now, but we should also just fix that.

@briansmith
Copy link

This was motivated because doctests don't work for cross-compiled testing right now, but we should also just fix that.

What is the bug for that? I am hitting this when cross-compiling to i686 from x64_64 on the same OS.

@alexcrichton
Copy link
Member

We may not actually have a bug open (I don't recall one off-hand), but if we did it'd be rattling around in rust-lang/rust somewhere

@reem
Copy link

reem commented Feb 27, 2016

I am running into this as well, would be really nice to get a fix here even outside the context of cross compiling (though that is where I am hitting an issue). Sometimes I just don't want to run doctests because they are slow, currently broken, etc. without making it a permanent option.

@bluss
Copy link
Member

bluss commented Mar 16, 2016

I have a lot of tests and it takes a long time to recompile them all. So it would be nice to have a flag that runs just the doctests.

I'm aware of cargo test --lib and cargo --test TEST but none of them reach the doctests subset.

@carols10cents carols10cents added A-configuration Area: cargo config files and env vars Command-test C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` labels Sep 10, 2017
@jooert
Copy link

jooert commented Jan 13, 2018

I think @alexcrichton implemented this in #2578.

@kbknapp
Copy link

kbknapp commented Feb 3, 2018

@jooert --doc tests only the doctests but there isn't a way to disable them. (AFAIK)

Oops, looks like that's exactly what --lib does 🤦‍♂️

@dwijnand
Copy link
Member

Shall we close this ticket?

  • Running just doc tests is available as cargo test --doc
  • Running just library tests without doc tests is available as cargo test --lib

The only thing left is disabling doc tests in .cargo/config, but is there much request for that? Do we want to include that?

@alexcrichton
Copy link
Member

Sounds good to me!

@webern
Copy link

webern commented Nov 22, 2020

@jooert --doc tests only the doctests but there isn't a way to disable them. (AFAIK)

Oops, looks like that's exactly what --lib does 🤦‍♂️

Not quite, --lib doesn't seem to run the 'integration' tests from the integ library.

I found my way here because my IDE cannot attach a debugger when multiple binaries are produced. I believe doc tests must be in a separate binary?

So I have no way to run all tests, including the integ tests from the tests directory, and attach my IDE's debugging functionality. What I need is a --no-doc flag.

@FedorSmirnov89
Copy link

I found my way here while facing a similar issue as @webern . Just in case this helps anyone: For me the solution to not running doc tests whenever I execute cargo test (while still running both unit and integration tests) was to add the following lined to the Cargo.toml:

[lib]
doctest = false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-configuration Area: cargo config files and env vars C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-test
Projects
None yet
Development

No branches or pull requests