Skip to content

Commit

Permalink
Auto merge of #65190 - GuillaumeGomez:dont-pass-doctest-feature-by-de…
Browse files Browse the repository at this point in the history
…fault, r=Mark-Simulacrum

Don't pass doctest feature by default

As asked in #63803 (comment).

r? @QuietMisdreavus
  • Loading branch information
bors committed Oct 12, 2019
2 parents 026447b + 3e376f5 commit 152527f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
5 changes: 1 addition & 4 deletions src/librustdoc/config.rs
Expand Up @@ -343,10 +343,7 @@ impl Options {
let output = matches.opt_str("o")
.map(|s| PathBuf::from(&s))
.unwrap_or_else(|| PathBuf::from("doc"));
let mut cfgs = matches.opt_strs("cfg");
if should_test {
cfgs.push("doctest".to_string());
}
let cfgs = matches.opt_strs("cfg");

let extension_css = matches.opt_str("e").map(|s| PathBuf::from(&s));

Expand Down
1 change: 1 addition & 0 deletions src/librustdoc/test.rs
Expand Up @@ -64,6 +64,7 @@ pub fn run(options: Options) -> i32 {

let mut cfgs = options.cfgs.clone();
cfgs.push("rustdoc".to_owned());
cfgs.push("doctest".to_owned());
let config = interface::Config {
opts: sessopts,
crate_cfg: config::parse_cfgspecs(cfgs),
Expand Down
15 changes: 15 additions & 0 deletions src/test/rustdoc-ui/doc-test-doctest-feature.rs
@@ -0,0 +1,15 @@
// build-pass
// compile-flags:--test
// normalize-stdout-test: "src/test/rustdoc-ui" -> "$$DIR"

#![feature(cfg_doctest)]

// Make sure `cfg(doctest)` is set when finding doctests but not inside
// the doctests.

/// ```
/// #![feature(cfg_doctest)]
/// assert!(!cfg!(doctest));
/// ```
#[cfg(doctest)]
pub struct Foo;
6 changes: 6 additions & 0 deletions src/test/rustdoc-ui/doc-test-doctest-feature.stdout
@@ -0,0 +1,6 @@

running 1 test
test $DIR/doc-test-doctest-feature.rs - Foo (line 10) ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

0 comments on commit 152527f

Please sign in to comment.