Skip to content

Check the search-index generated by rustdoc tests #31483

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

Closed
wants to merge 8 commits into from
Closed
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
12 changes: 12 additions & 0 deletions src/compiletest/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ pub struct TestProps {
pub check_lines: Vec<String> ,
// Build documentation for all specified aux-builds as well
pub build_aux_docs: bool,
// Check the generated search-index against a embedded reference
pub check_search_index: bool,
// Flag to force a crate to be built with the host architecture
pub force_host: bool,
// Check stdout for error-pattern output as well as stderr
Expand All @@ -62,6 +64,7 @@ pub fn load_props(testfile: &Path) -> TestProps {
let mut pp_exact = None;
let mut check_lines = Vec::new();
let mut build_aux_docs = false;
let mut check_search_index = false;
let mut force_host = false;
let mut check_stdout = false;
let mut no_prefer_dynamic = false;
Expand Down Expand Up @@ -90,6 +93,10 @@ pub fn load_props(testfile: &Path) -> TestProps {
build_aux_docs = parse_build_aux_docs(ln);
}

if !check_search_index {
check_search_index = parse_check_search_index(ln);
}

if !force_host {
force_host = parse_force_host(ln);
}
Expand Down Expand Up @@ -152,6 +159,7 @@ pub fn load_props(testfile: &Path) -> TestProps {
exec_env: exec_env,
check_lines: check_lines,
build_aux_docs: build_aux_docs,
check_search_index: check_search_index,
force_host: force_host,
check_stdout: check_stdout,
no_prefer_dynamic: no_prefer_dynamic,
Expand Down Expand Up @@ -296,6 +304,10 @@ fn parse_build_aux_docs(line: &str) -> bool {
parse_name_directive(line, "build-aux-docs")
}

fn parse_check_search_index(line: &str) -> bool {
parse_name_directive(line, "check-search-index")
}

fn parse_check_stdout(line: &str) -> bool {
parse_name_directive(line, "check-stdout")
}
Expand Down
15 changes: 14 additions & 1 deletion src/compiletest/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1765,11 +1765,24 @@ fn run_rustdoc_test(config: &Config, props: &TestProps, testfile: &Path) {
testfile,
Command::new(&config.python)
.arg(root.join("src/etc/htmldocck.py"))
.arg(out_dir)
.arg(out_dir.clone())
.arg(testfile));
if !res.status.success() {
fatal_proc_rec("htmldocck failed!", &res);
}

if props.check_search_index {
let res = cmd2procres(config,
testfile,
Command::new(&config.python)
.arg(root.join("src/etc/search-index.py"))
.arg("check")
.arg(out_dir.join("search-index.js"))
.arg(testfile));
if !res.status.success() {
fatal_proc_rec("search-index check failed!", &res);
}
}
}

fn run_codegen_units_test(config: &Config, props: &TestProps, testfile: &Path) {
Expand Down
Loading