FIX: Call rustdoc test with the correct cfg flags of a package.#3242
FIX: Call rustdoc test with the correct cfg flags of a package.#3242bors merged 4 commits intorust-lang:masterfrom jhbabon:cfgs-flags-per-package
Conversation
There was a situation in which if you you had a lib that depends on a package with features, whenever you ran the tests for the package the `rustdoc test` call was failing because rustdoc was called with the root cfg flags, not the package cfg flags. This fix solves the issue by keeping track of the cfg flags per package, so the rustdoc command will be generated with the correct cfg flags.
|
(rust_highfive has picked a reviewer for you, use r? to override) |
|
Great! Thanks. |
src/cargo/ops/cargo_rustc/mod.rs
Outdated
| cx.compilation.cfgs.entry(unit.pkg.package_id().clone()) | ||
| .or_insert(HashSet::new()) | ||
| .insert(format!("feature=\"{}\"", feat)); | ||
| } |
There was a problem hiding this comment.
You can call entry just once. Something like that should work.
cx.compilation.cfgs.entry(unit.pkg.package_id().clone())
.or_insert(HashSet::new())
.extend(feats.iter().map(|feat| format!("feature=\"{}\"", feat));There was a problem hiding this comment.
@TeXitoi that looks better, I'll check it out.
|
I really don't know why the tests in travis are failing. It doesn't seem related to my changes, or it is? Also, how can I make the tests better so the pass in appveyor? Looks like the windows version is setting extra |
tests/test.rs
Outdated
| execs().with_status(0) | ||
| .with_stderr_contains("\ | ||
| [DOCTEST] a | ||
| [RUNNING] `rustdoc --test [..]--cfg feature=\\\"serde_codegen\\\"[..]`")); |
There was a problem hiding this comment.
Ah yeah the escaping here is subtly different on Windows (different shell), so it's fine to just match the word serde_codegen being passed here
There was a problem hiding this comment.
@alexcrichton sounds good. I'll change it.
|
Oh it looks like Travis is failing when trying to render https://github.com/rust-lang/cargo/blob/master/src/doc/machine-readable-output.md. Could you actually modify that file as well to change the code blocks to be tagged with the The code here looks great, thanks @jhbabon! |
In Windows the rustdoc test output sets more double quotes, so the test doesn't pass. We need to relax the test so it pass in *NIX and Windows environments.
Travis fails when running `make doc` because of this file. This should fix the issue.
|
@alexcrichton changes done! |
|
📌 Commit 665aa7f has been approved by |
FIX: Call rustdoc test with the correct cfg flags of a package. There was a situation in which if you you had a lib that depends on a package with features, whenever you ran the tests for the package the `rustdoc test` call was failing because it was called with the root `cfg` flags, not the package `cfg` flags. This fix solves the issue by keeping track of the `cfg` flags per package, so the `rustdoc` command will be generated with the correct `cfg` flags. Closes #3172
|
☀️ Test successful - cargo-cross-linux, cargo-linux-32, cargo-linux-64, cargo-mac-32, cargo-mac-64, cargo-win-gnu-32, cargo-win-gnu-64, cargo-win-msvc-32, cargo-win-msvc-64 |
There was a situation in which if you you had a lib that depends on a package with features, whenever you ran the tests for the package the
rustdoc testcall was failing because it was called with the rootcfgflags, not the packagecfgflags.This fix solves the issue by keeping track of the
cfgflags per package, so therustdoccommand will be generated with the correctcfgflags.Closes #3172