diff options
| author | Mark Rousskov <mark.simulacrum@gmail.com> | 2019-09-09 21:11:27 -0400 |
|---|---|---|
| committer | Mark Rousskov <mark.simulacrum@gmail.com> | 2019-09-10 16:59:31 -0400 |
| commit | 093cbd60fc331e9aab63fc4cdd8b8c9a043eaa3e (patch) | |
| tree | cafb41535d8efb68b27127cc4d3e259766ccb93a | |
| parent | 2fc32b9e727f0ac372348b9de9016c9311a387dc (diff) | |
| download | rust-093cbd60fc331e9aab63fc4cdd8b8c9a043eaa3e.tar.gz rust-093cbd60fc331e9aab63fc4cdd8b8c9a043eaa3e.zip | |
Add unstable --test-builder to rustdoc
This allows overriding the rustc binary used to build tests; it should not generally be necessary as we fallback to the sysroot.
| -rw-r--r-- | src/librustdoc/config.rs | 6 | ||||
| -rw-r--r-- | src/librustdoc/lib.rs | 5 | ||||
| -rw-r--r-- | src/librustdoc/test.rs | 5 |
3 files changed, 15 insertions, 1 deletions
diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index 995a340143f..19ea7814300 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -86,6 +86,10 @@ pub struct Options { /// contains "foo" as a substring pub enable_per_target_ignores: bool, + /// The path to a rustc-like binary to build tests with. If not set, we + /// default to loading from $sysroot/bin/rustc. + pub test_builder: Option<PathBuf>, + // Options that affect the documentation process /// The selected default set of passes to use. @@ -476,6 +480,7 @@ impl Options { let generate_search_filter = !matches.opt_present("disable-per-crate-search"); let persist_doctests = matches.opt_str("persist-doctests").map(PathBuf::from); let generate_redirect_pages = matches.opt_present("generate-redirect-pages"); + let test_builder = matches.opt_str("test-builder").map(PathBuf::from); let codegen_options_strs = matches.opt_strs("C"); let lib_strs = matches.opt_strs("L"); let extern_strs = matches.opt_strs("extern"); @@ -515,6 +520,7 @@ impl Options { runtool, runtool_args, enable_per_target_ignores, + test_builder, render_options: RenderOptions { output, external_html, diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 88da1b16686..d77e790d4a4 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -373,6 +373,11 @@ fn opts() -> Vec<RustcOptGroup> { "", "One (of possibly many) arguments to pass to the runtool") }), + unstable("test-builder", |o| { + o.optflag("", + "test-builder", + "specified the rustc-like binary to use as the test builder") + }), ] } diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index 30ed725ad20..816b7836fb1 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -248,7 +248,10 @@ fn run_test( }; let output_file = outdir.path().join("rust_out"); - let mut compiler = Command::new(rustc_interface::util::rustc_path().expect("found rustc")); + let rustc_binary = options.test_builder.as_ref().map(|v| &**v).unwrap_or_else(|| { + rustc_interface::util::rustc_path().expect("found rustc") + }); + let mut compiler = Command::new(&rustc_binary); compiler.arg("--crate-type").arg("bin"); for cfg in &options.cfgs { compiler.arg("--cfg").arg(&cfg); |
