Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run doctests via out-of-process rustc #63827

Merged
merged 2 commits into from
Aug 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/librustc_driver/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,15 @@ fn make_input(free_matches: &[String]) -> Option<(Input, Option<PathBuf>, Option
} else {
None
};
if let Ok(path) = env::var("UNSTABLE_RUSTDOC_TEST_PATH") {
let line = env::var("UNSTABLE_RUSTDOC_TEST_LINE").
expect("when UNSTABLE_RUSTDOC_TEST_PATH is set \
UNSTABLE_RUSTDOC_TEST_LINE also needs to be set");
let line = isize::from_str_radix(&line, 10).
expect("UNSTABLE_RUSTDOC_TEST_LINE needs to be an number");
let file_name = FileName::doc_test_source_code(PathBuf::from(path), line);
return Some((Input::Str { name: file_name, input: src }, None, err));
}
Some((Input::Str { name: FileName::anon_source_code(&src), input: src },
None, err))
} else {
Expand Down
12 changes: 12 additions & 0 deletions src/librustdoc/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,18 @@ pub struct Options {
pub error_format: ErrorOutputType,
/// Library search paths to hand to the compiler.
pub libs: Vec<SearchPath>,
/// Library search paths strings to hand to the compiler.
pub lib_strs: Vec<String>,
/// The list of external crates to link against.
pub externs: Externs,
/// The list of external crates strings to link against.
pub extern_strs: Vec<String>,
/// List of `cfg` flags to hand to the compiler. Always includes `rustdoc`.
pub cfgs: Vec<String>,
/// Codegen options to hand to the compiler.
pub codegen_options: CodegenOptions,
/// Codegen options strings to hand to the compiler.
pub codegen_options_strs: Vec<String>,
/// Debugging (`-Z`) options to pass to the compiler.
pub debugging_options: DebuggingOptions,
/// The target used to compile the crate against.
Expand Down Expand Up @@ -461,6 +467,9 @@ 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 codegen_options_strs = matches.opt_strs("C");
let lib_strs = matches.opt_strs("L");
let extern_strs = matches.opt_strs("extern");
Mark-Simulacrum marked this conversation as resolved.
Show resolved Hide resolved

let (lint_opts, describe_lints, lint_cap) = get_cmd_lint_options(matches, error_format);

Expand All @@ -470,9 +479,12 @@ impl Options {
proc_macro_crate,
error_format,
libs,
lib_strs,
externs,
extern_strs,
cfgs,
codegen_options,
codegen_options_strs,
debugging_options,
target,
edition,
Expand Down
7 changes: 2 additions & 5 deletions src/librustdoc/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,8 @@ pub fn test(mut options: Options, diag: &errors::Handler) -> i32 {
let mut opts = TestOptions::default();
opts.no_crate_inject = true;
opts.display_warnings = options.display_warnings;
let mut collector = Collector::new(options.input.display().to_string(), options.cfgs,
options.libs, options.codegen_options, options.externs,
true, opts, options.maybe_sysroot, None,
Some(options.input),
options.linker, options.edition, options.persist_doctests);
let mut collector = Collector::new(options.input.display().to_string(), options.clone(),
true, opts, None, Some(options.input));
collector.set_position(DUMMY_SP);
let codes = ErrorCodes::from(UnstableFeatures::from_environment().is_nightly_build());

Expand Down
Loading