Cargo: Allow enabling / disabling doc tests as a CLI flag and a .cargo/config option

Created on 8 Jul 2015  ·  10Comments  ·  Source: rust-lang/cargo

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

A-configuration C-feature-request Command-test

Most helpful comment

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.

All 10 comments

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

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.

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

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.

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.

I think @alexcrichton implemented this in #2578.

@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 🤦‍♂️

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?

Sounds good to me!

~@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.

Was this page helpful?
0 / 5 - 0 ratings