-
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 doesn't compile doc tests for target != host #6460
Comments
I think this is intentional, see rust-lang/rust#31907. I wonder, how much risk there is that doc tests will fail to just compile on host? See also rust-lang/rust#44404 for a request to have rustdoc support |
Yes this is currently intentional that we don't run rustdoc at all, but it makes sense to me that we could have an option to try to at least compile examples even if we can't run them! I suspect that we can't do this in a backwards compatible fashion by default, but at least having an option in the maniest for something like this seems reasonable to me |
@alexcrichton I fear that the inability to compile doc tests will have a major (negative) quality impact for embedded because there's no other way to build software but via cross-compilation. Thus it would be great if this feature would be given appropriate consideration and priority. |
This also impacts developers using pc-windows-gnu target on a system where pc-windows-msvc is the default. I discovered a bug in my documentation thanks to a CI build running on linux, but I wish I discovered this earlier in my pipeline. |
At the very least, I think cargo should error if you explicitly pass |
Allow cross-compiling doctests This PR allows doctest to receive a --runtool argument, as well as possibly many --runtool-arg arguments, which are then used to run cross compiled doctests. Also, functionality has been added to rustdoc to allow it to skip testing doctests on a per-target basis, in the same way that compiletest does it. For example, tagging the doctest with "ignore-sgx" disables testing on any targets that contain "sgx". A plain "ignore" still skips testing on all targets. See [here](rust-lang/cargo#6892) for the companion PR in the cargo project that extends functionality in Cargo so that it passes the appropriate parameters to rustdoc when cross compiling and testing doctests. Part of [#6460](rust-lang/cargo#6460)
Added ability to crosscompile doctests This commit adds the ability to cross-compile and run doctests. Like before cargo checks if target == host, the difference is that if there is a runtool defined in config.toml, it passes the information forward to rustdoc so that it can run the doctests with that tool. If no tool is defined and the target != host, cargo instead displays a message that doctests will not be compiled because of the missing runtool. See [here](rust-lang/rust#60387) for the companion PR in the rust project that modifies rustdoc to accept the relevant options as well as allow ignoring doctests on a per target level. Partially resolves [#6460](#6460) See [here](#7040) for the tracking issue.
Woohoo! |
Problem
We'd like to have no_run doc tests for embedded HAL impl crates to ensure that the crate is sufficiently and accurately documented. However cargo doc completely ignores those tests when running with the
--doc
flag:while creating an error when trying to run all tests:
I would expect that
no_run
tests are correctly compiled in the current environment (as are docs, libraries, executables and examples) and compile errors flagged as test failures. In the future it would be even nicer if I could define a test runner environment (like qemu or docker) to test the executables as well.Steps
Possible Solution(s)
Attempt to compile doctests even when target != host, especially
no_run
ones.Notes
Output of
cargo version
:cargo 1.33.0-nightly (2cf1f5d 2018-12-11)
cargo 1.31.0 (339d9f9 2018-11-16)
The text was updated successfully, but these errors were encountered: