-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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 doc tests
#6669
Comments
An attempt to fix this was made in #6671, but there's a bit of a mismatch between |
Maybe it is worth to add some context to this issue. We ran into this because we use I read some of the discussion in the #6671 and TBH, the whole |
This means the command to run absolutely all tests everywhere is |
It depends on the structure of your packages, but in general there is currently no single command to "test everything". |
Tests has been built slowly lately. That's because we use multiple compile command to build tests for different crates. Things go worse when cdc is split as a component. On my local machine, running `make test`, cargo will be invoked 6 times. 4 of them takes minutes to finish. The reason why we try to run multiple compile command is to get around the problem mentioned in #6097, which is introduced when trying to support prost and protobuf in tests at the same time. But in practice, we don't run tests with prost. Hence overhead is introduced with just potential benefit. In fact, after #6317, it's impossible to run tests by `PROST=1 make test` due to rust-lang/cargo#6669. It's still possible to build, clippy check or release with prost. Given that tests with PROST=1 does not work, this PR combines all the cargo commands into single one, which save a lot of compile time. Signed-off-by: Jay Lee <[email protected]>
Tests has been built slowly lately. That's because we use multiple compile command to build tests for different crates. Things go worse when cdc is split as a component. On my local machine, running `make test`, cargo will be invoked 6 times. 4 of them takes minutes to finish. The reason why we try to run multiple compile command is to get around the problem mentioned in tikv#6097, which is introduced when trying to support prost and protobuf in tests at the same time. But in practice, we don't run tests with prost. Hence overhead is introduced with just potential benefit. In fact, after tikv#6317, it's impossible to run tests by `PROST=1 make test` due to rust-lang/cargo#6669. It's still possible to build, clippy check or release with prost. Given that tests with PROST=1 does not work, this PR combines all the cargo commands into single one, which save a lot of compile time. Signed-off-by: Jay Lee <[email protected]>
Tests has been built slowly lately. That's because we use multiple compile command to build tests for different crates. Things go worse when cdc is split as a component. On my local machine, running `make test`, cargo will be invoked 6 times. 4 of them takes minutes to finish. The reason why we try to run multiple compile command is to get around the problem mentioned in tikv#6097, which is introduced when trying to support prost and protobuf in tests at the same time. But in practice, we don't run tests with prost. Hence overhead is introduced with just potential benefit. In fact, after tikv#6317, it's impossible to run tests by `PROST=1 make test` due to rust-lang/cargo#6669. It's still possible to build, clippy check or release with prost. Given that tests with PROST=1 does not work, this PR combines all the cargo commands into single one, which save a lot of compile time. Signed-off-by: Jay Lee <[email protected]>
Running doctests and all-targets (see rust-lang/cargo#6669) Also bump version
Running doctests and all-targets (see rust-lang/cargo#6669)
The `--all-targets` flag for `cargo test` actually DISABLES doctests. Doctests should of course be run, so removing the flag from the CI scrips. There is a bug report for cargo about this behavior: rust-lang/cargo#6669 This fixes the changes done in #235 / 9a6c3bf.
Yeah it would be great if there was a single command to run all tests, doctests, everything. having a unified command is a blocker for re-attempting #8437 |
`cargo test --all-features` does not run doc-tests. For more information see rust-lang/cargo#6669.
* Add one codecov * Merge another codecov * Merge another codecov * Merge another codecov * Merge another codecov * Place codecov config under .github * Add (only) ASAN workflow * Add first coverage workflow * Merge another coverage.yml * Merge another coverage.yml * Add first features workflow * Merge another features workflow * Merge another features workflow * Merge another features workflow * Add (only) loom workflow * Add (only) LSAN workflow * Add first minial workflow * Add (only) miri workflow * Add first msrv workflow * Merge another msrv workflow * Merge another msrv workflow * Merge another msrv workflow * Add (only) no-std workflow * Add first os-check workflow * Merge another os-check workflow * Add first style workflow * Merge another style workflow * Merge another style workflow * Add first test workflow * Merge another test workflow * Merge another test workflow * Merge another test workflow * Make everything use checkout@v3 * Standardize on 'main' as branch name * Missed a submodule checkout * Add TODOs from twitter thread * Practice what you preach * mv github .github This should make it possible to have rust-ci-conf as a remote you merge from. * Merge safety workflows * Catch upcoming deprecations * More concise name for scheduled jobs * Allow examples and binaries to require features * Use dependabot, but only for major versions * ignore is a list * Notify if actions themselves are outdated * Bump codecov/codecov-action from 2 to 3 Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 2 to 3. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](codecov/codecov-action@v2...v3) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> * Move to maintained rust installer See actions-rs/toolchain#216 * Fix install message for msrv * Get rid of most actions-rs bits Given that that project is unmaintained. actions-rs/toolchain#216 * Minimal token permissions See tokio-rs/tokio#5072 * Remove -Zmiri-tag-raw-pointers as it's now default * Unbreak cargo hack for non-libraries (#4) * Add action to run doctest. (#3) `cargo test --all-features` does not run doc-tests. For more information see rust-lang/cargo#6669. * chore: automatically cancel superseded Actions runs (#5) * [sanity] More robust injection of opt-level 1 (#9) Fixes #8 * Quote MSRV version to avoid float parsing (#11) Put 1.70 in there (for instance if you want to pin against OnceLock stabilizing) and it will actually test 1.7 as it appears github auto converts this to a float? Putting in quotes seems to do the right thing here * Install Openssl for Windows (#12) * Don't install OpenSSL on Windows by default * Bump actions/checkout from 3 to 4 (#13) Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](actions/checkout@v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * docs: Add documentation based on the youtube video (#10) * Nit: Selecting direct minimal versions flag is -Zdirect-minimal-versions (#16) * Add one codecov * Merge another codecov * Merge another codecov * Merge another codecov * Merge another codecov * Place codecov config under .github * Add (only) ASAN workflow * Add first coverage workflow * Merge another coverage.yml * Merge another coverage.yml * Add first features workflow * Merge another features workflow * Merge another features workflow * Merge another features workflow * Add (only) loom workflow * Add (only) LSAN workflow * Add first minial workflow * Add (only) miri workflow * Add first msrv workflow * Merge another msrv workflow * Merge another msrv workflow * Merge another msrv workflow * Add (only) no-std workflow * Add first os-check workflow * Merge another os-check workflow * Add first style workflow * Merge another style workflow * Merge another style workflow * Add first test workflow * Merge another test workflow * Merge another test workflow * Merge another test workflow * Make everything use checkout@v3 * Standardize on 'main' as branch name * Missed a submodule checkout * Add TODOs from twitter thread * Practice what you preach * mv github .github This should make it possible to have rust-ci-conf as a remote you merge from. * Merge safety workflows * Catch upcoming deprecations * More concise name for scheduled jobs * Allow examples and binaries to require features * Use dependabot, but only for major versions * ignore is a list * Notify if actions themselves are outdated * Bump codecov/codecov-action from 2 to 3 Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 2 to 3. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](codecov/codecov-action@v2...v3) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> * Move to maintained rust installer See actions-rs/toolchain#216 * Fix install message for msrv * Get rid of most actions-rs bits Given that that project is unmaintained. actions-rs/toolchain#216 * Minimal token permissions See tokio-rs/tokio#5072 * Remove -Zmiri-tag-raw-pointers as it's now default * Unbreak cargo hack for non-libraries (#4) * Add action to run doctest. (#3) `cargo test --all-features` does not run doc-tests. For more information see rust-lang/cargo#6669. * chore: automatically cancel superseded Actions runs (#5) * [sanity] More robust injection of opt-level 1 (#9) Fixes #8 * Quote MSRV version to avoid float parsing (#11) Put 1.70 in there (for instance if you want to pin against OnceLock stabilizing) and it will actually test 1.7 as it appears github auto converts this to a float? Putting in quotes seems to do the right thing here * Install Openssl for Windows (#12) * Don't install OpenSSL on Windows by default * Bump actions/checkout from 3 to 4 (#13) Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](actions/checkout@v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * docs: Add documentation based on the youtube video (#10) * Nit: Selecting direct minimal versions flag is -Zdirect-minimal-versions (#16) * chore(github): create the code owners file * chore(github): add the funding methods * chore(github): create the issue templates * chore(github): create the PR template * chore(mergify): create `mergify` config * chore(github): remove the `nostd` workflow * chore(github): remove the `os-check` step and updated the branch name * chore(github): create the CI workflow * chore(github): update the branch name * fix(workflow): disable the loom step for now * fix(minimal-versions): set the minimal versoin of `thiserror` at 1.0.2 * fix(workflow): update the minimal rust version * chore(codespell): create the codespell ignore file * fix(workflow): don't try to build on windows or macos * docs: fix typos * chore(codespell): ignore `crate` * fix(workflow): install X11 * fix(workflow): fix typos * chore(mergify): disable the Dbpndabot rule * chore(github): remove the CI workflow * chore(github): add lint step to the test workflow --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Jon Gjengset <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Tudyx <[email protected]> Co-authored-by: Burkhard Mittelbach <[email protected]> Co-authored-by: Simen Bekkhus <[email protected]> Co-authored-by: James Chacon <[email protected]> Co-authored-by: Rod Elias <[email protected]> Co-authored-by: Josh McKinney <[email protected]> Co-authored-by: Mathias Pius <[email protected]>
I don't know anything about the internals of Can we just remove the |
doctests are not unit tests, they are integration tests. In other words, they require a separate rustc process to be spawned for each snippet. On top of that, you have the rustdoc process (which isn't that neccessary, one could move the logic to extract the snippets to a place shared by rustc and rustdoc). edit: there is the third issue, one that all integration tests face, that they can depend on the crate as an external dependency. In other words you need to compile the lib crate with |
`cargo test --all-features` does not run doc-tests. For more information see rust-lang/cargo#6669.
Merge another codecov Merge another codecov Merge another codecov Merge another codecov Place codecov config under .github Add (only) ASAN workflow Add first coverage workflow Merge another coverage.yml Merge another coverage.yml Add first features workflow Merge another features workflow Merge another features workflow Merge another features workflow Add (only) loom workflow Add (only) LSAN workflow Add first minial workflow Add (only) miri workflow Add first msrv workflow Merge another msrv workflow Merge another msrv workflow Merge another msrv workflow Add (only) no-std workflow Add first os-check workflow Merge another os-check workflow Add first style workflow Merge another style workflow Merge another style workflow Add first test workflow Merge another test workflow Merge another test workflow Merge another test workflow Make everything use checkout@v3 Standardize on 'main' as branch name Missed a submodule checkout Add TODOs from twitter thread Practice what you preach mv github .github This should make it possible to have rust-ci-conf as a remote you merge from. Merge safety workflows Catch upcoming deprecations More concise name for scheduled jobs Allow examples and binaries to require features Use dependabot, but only for major versions ignore is a list Notify if actions themselves are outdated Bump codecov/codecov-action from 2 to 3 Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 2 to 3. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](codecov/codecov-action@v2...v3) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Move to maintained rust installer See actions-rs/toolchain#216 Fix install message for msrv Get rid of most actions-rs bits Given that that project is unmaintained. actions-rs/toolchain#216 Minimal token permissions See tokio-rs/tokio#5072 Remove -Zmiri-tag-raw-pointers as it's now default Unbreak cargo hack for non-libraries (#4) Add action to run doctest. (#3) `cargo test --all-features` does not run doc-tests. For more information see rust-lang/cargo#6669. chore: automatically cancel superseded Actions runs (#5) [sanity] More robust injection of opt-level 1 (#9) Fixes #8 Quote MSRV version to avoid float parsing (#11) Put 1.70 in there (for instance if you want to pin against OnceLock stabilizing) and it will actually test 1.7 as it appears github auto converts this to a float? Putting in quotes seems to do the right thing here Install Openssl for Windows (#12) Don't install OpenSSL on Windows by default Bump actions/checkout from 3 to 4 (#13) Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](actions/checkout@v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> docs: Add documentation based on the youtube video (#10) Nit: Selecting direct minimal versions flag is -Zdirect-minimal-versions (#16) chore: fix typos (#17) Remove stray trailing whitespace replace actions-rs/clippy-check with giraffate/clippy-action (#19) Co-authored-by: rtkay123 <[email protected]> Semi-breaking: update codecov action Note: this requires adding `CODECOV_TOKEN` to your GitHub repository's secrets! See associated comment in the commit content. Uniform capitalization
`cargo test --all-features` does not run doc-tests. For more information see rust-lang/cargo#6669.
I accidentally removed execution of doc tests on CI when I added the `--all-targets` switch to `cargo test` in order to run benchmarks as tests. It turns out that `cargo test --all-targets` doesn't run doc tests (see rust-lang/cargo#6669 ). The solution for running both doc tests and benchmarks as tests seems to be to leave out the `--all-target` switch and instead mark benchmarks with `test=true` in `Cargo.toml` (see rust-lang/cargo#6669 (comment) ).
In today's @rust-lang/cargo meeting, we agreed to try the experiment of adding an |
Ah, I know that feel. I had the same problem at work with a similar option of A naming suggestion (we used a similar one as well): |
Also, when we do As for naming, one idea is to explore disambiguating the term "target" in cargo. If we rename "build target", then the We lean towards a new flag because people likely have broken doctests (as evidenced by this thread). While they would want to discover and fix them, they likely want to do it on their own timetable and not be forced to by cargo. |
Note that in a future edition we could potentially make |
`cargo test --all-features` does not run doc-tests. See rust-lang/cargo#6669 Signed-off-by: Ariel Miculas-Trif <[email protected]>
Hmm, I wonder if we can have a project-level switch (maybe in the |
I think we're leaning towards renaming "build |
Just note that there are designs needing to figure out, for the interaction between doctesting everything and a subset of doctest-able lib/example/bench/test/bin. See #6669 (comment) and the original comment #6671 (comment). |
You could maybe solve that with an alias that "does the right thing" whatever that means for you? |
@epage The idea would still be to default to the " |
It is too late to introduce 2024 Edition changes. If a solution needs an Edition, it'd be 2027. |
Ah, well, it that case it makes sense to have a new flag for "all targets and docs" 😄 . |
As per title
cargo test --all-targets
does not run the doc tests on a crate. This is very surprising behaviour. I found this and it looks like running doc tests is done byrustdoc
which is apparently not invoked when doing--all-targets
.The text was updated successfully, but these errors were encountered: