/// Features per package enabled during this compilation.
pub cfgs: HashMap<PackageId, HashSet<String>>,
+ /// Flags to pass to rustdoc when invoked from cargo test, per package.
+ pub rustdocflags: HashMap<PackageId, Vec<String>>,
+
pub target: String,
config: &'cfg Config,
extra_env: HashMap::new(),
to_doc_test: Vec::new(),
cfgs: HashMap::new(),
+ rustdocflags: HashMap::new(),
config: config,
target: String::new(),
target_runner: LazyCell::new(),
cx.compilation.cfgs.entry(unit.pkg.package_id().clone())
.or_insert_with(HashSet::new)
.extend(feats.iter().map(|feat| format!("feature=\"{}\"", feat)));
+ let rustdocflags = cx.rustdocflags_args(&unit)?;
+ if !rustdocflags.is_empty() {
+ cx.compilation.rustdocflags.entry(unit.pkg.package_id().clone())
+ .or_insert_with(Vec::new)
+ .extend(rustdocflags);
+ }
output_depinfo(&mut cx, unit)?;
}
p.arg("--extern").arg(&arg);
}
+ if let Some(flags) = compilation.rustdocflags.get(package.package_id()) {
+ p.args(flags);
+ }
+
config.shell().verbose(|shell| {
shell.status("Running", p.to_string())
})?;
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
"));
}
+
+#[test]
+fn rustdocflags_passed_to_rustdoc_through_cargo_test() {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.0.1"
+ "#)
+ .file("src/lib.rs", r#"
+ //! ```
+ //! assert!(cfg!(do_not_choke));
+ //! ```
+ "#)
+ .build();
+
+ assert_that(p.cargo("test").arg("--doc").env("RUSTDOCFLAGS", "--cfg do_not_choke"),
+ execs().with_status(0));
+}