Skip to content

Commit 1733f5e

Browse files
committed
Added ./x.py test --no-doc option.
This enables `./x.py test --stage 0 src/libstd --no-doc` and ensures the stage2-rustc and rustdoc need to be built.
1 parent fa30ae5 commit 1733f5e

File tree

4 files changed

+38
-13
lines changed

4 files changed

+38
-13
lines changed

src/bootstrap/builder.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use compile;
2525
use install;
2626
use dist;
2727
use util::{exe, libdir, add_lib_path};
28-
use {Build, Mode};
28+
use {Build, Mode, DocTestsOption};
2929
use cache::{INTERNER, Interned, Cache};
3030
use check;
3131
use test;
@@ -591,6 +591,8 @@ impl<'a> Builder<'a> {
591591
format!("{} {}", env::var("RUSTFLAGS").unwrap_or_default(), extra_args));
592592
}
593593

594+
let want_rustdoc = self.doc_tests != DocTestsOption::No;
595+
594596
// Customize the compiler we're running. Specify the compiler to cargo
595597
// as our shim and then pass it some various options used to configure
596598
// how the actual compiler itself is called.
@@ -607,7 +609,7 @@ impl<'a> Builder<'a> {
607609
.env("RUSTC_LIBDIR", self.rustc_libdir(compiler))
608610
.env("RUSTC_RPATH", self.config.rust_rpath.to_string())
609611
.env("RUSTDOC", self.out.join("bootstrap/debug/rustdoc"))
610-
.env("RUSTDOC_REAL", if cmd == "doc" || cmd == "test" {
612+
.env("RUSTDOC_REAL", if cmd == "doc" || (cmd == "test" && want_rustdoc) {
611613
self.rustdoc(compiler.host)
612614
} else {
613615
PathBuf::from("/path/to/nowhere/rustdoc/not/required")
@@ -624,7 +626,7 @@ impl<'a> Builder<'a> {
624626
if let Some(ref error_format) = self.config.rustc_error_format {
625627
cargo.env("RUSTC_ERROR_FORMAT", error_format);
626628
}
627-
if cmd != "build" && cmd != "check" {
629+
if cmd != "build" && cmd != "check" && want_rustdoc {
628630
cargo.env("RUSTDOC_LIBDIR", self.rustc_libdir(self.compiler(2, self.config.build)));
629631
}
630632

src/bootstrap/flags.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use std::process;
1919

2020
use getopts::Options;
2121

22-
use Build;
22+
use {Build, DocTestsOption};
2323
use config::Config;
2424
use metadata;
2525
use builder::Builder;
@@ -62,7 +62,7 @@ pub enum Subcommand {
6262
test_args: Vec<String>,
6363
rustc_args: Vec<String>,
6464
fail_fast: bool,
65-
doc_tests: bool,
65+
doc_tests: DocTestsOption,
6666
},
6767
Bench {
6868
paths: Vec<PathBuf>,
@@ -171,7 +171,8 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`");
171171
"extra options to pass the compiler when running tests",
172172
"ARGS",
173173
);
174-
opts.optflag("", "doc", "run doc tests");
174+
opts.optflag("", "no-doc", "do not run doc tests");
175+
opts.optflag("", "doc", "only run doc tests");
175176
},
176177
"bench" => { opts.optmulti("", "test-args", "extra arguments", "ARGS"); },
177178
"clean" => { opts.optflag("", "all", "clean all build artifacts"); },
@@ -324,7 +325,13 @@ Arguments:
324325
test_args: matches.opt_strs("test-args"),
325326
rustc_args: matches.opt_strs("rustc-args"),
326327
fail_fast: !matches.opt_present("no-fail-fast"),
327-
doc_tests: matches.opt_present("doc"),
328+
doc_tests: if matches.opt_present("doc") {
329+
DocTestsOption::Only
330+
} else if matches.opt_present("no-doc") {
331+
DocTestsOption::No
332+
} else {
333+
DocTestsOption::Yes
334+
}
328335
}
329336
}
330337
"bench" => {
@@ -411,10 +418,10 @@ impl Subcommand {
411418
}
412419
}
413420

414-
pub fn doc_tests(&self) -> bool {
421+
pub fn doc_tests(&self) -> DocTestsOption {
415422
match *self {
416423
Subcommand::Test { doc_tests, .. } => doc_tests,
417-
_ => false,
424+
_ => DocTestsOption::Yes,
418425
}
419426
}
420427
}

src/bootstrap/lib.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,16 @@ pub struct Compiler {
210210
host: Interned<String>,
211211
}
212212

213+
#[derive(PartialEq, Eq, Copy, Clone, Debug)]
214+
pub enum DocTestsOption {
215+
// Default, run normal tests and doc tests.
216+
Yes,
217+
// Do not run any doc tests.
218+
No,
219+
// Only run doc tests.
220+
Only,
221+
}
222+
213223
/// Global configuration for the build system.
214224
///
215225
/// This structure transitively contains all configuration for the build system.
@@ -233,7 +243,7 @@ pub struct Build {
233243
rustfmt_info: channel::GitInfo,
234244
local_rebuild: bool,
235245
fail_fast: bool,
236-
doc_tests: bool,
246+
doc_tests: DocTestsOption,
237247
verbosity: usize,
238248

239249
// Targets for which to build.

src/bootstrap/test.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use dist;
3232
use native;
3333
use tool::{self, Tool};
3434
use util::{self, dylib_path, dylib_path_var};
35-
use Mode;
35+
use {Mode, DocTestsOption};
3636
use toolstate::ToolState;
3737

3838
const ADB_TEST_DIR: &str = "/data/tmp/work";
@@ -1519,8 +1519,14 @@ impl Step for Crate {
15191519
if test_kind.subcommand() == "test" && !builder.fail_fast {
15201520
cargo.arg("--no-fail-fast");
15211521
}
1522-
if builder.doc_tests {
1523-
cargo.arg("--doc");
1522+
match builder.doc_tests {
1523+
DocTestsOption::Only => {
1524+
cargo.arg("--doc");
1525+
}
1526+
DocTestsOption::No => {
1527+
cargo.args(&["--lib", "--bins", "--examples", "--tests", "--benches"]);
1528+
}
1529+
DocTestsOption::Yes => {}
15241530
}
15251531

15261532
cargo.arg("-p").arg(krate);

0 commit comments

Comments
 (0)