From 14f504c5b7324c77e78feffe5def4282d0f10573 Mon Sep 17 00:00:00 2001 From: mitaa Date: Thu, 3 Dec 2015 22:19:58 +0100 Subject: [PATCH] Add a `build-aux-docs` directive to compiletest This flag causes the documentation for all `aux-build` files to be built, which happens prior to running/building the parent test. --- src/compiletest/header.rs | 12 ++++++++++++ src/compiletest/runtest.rs | 25 +++++++++++++++++++------ 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/src/compiletest/header.rs b/src/compiletest/header.rs index 9de46cef745..6efe6e608e8 100644 --- a/src/compiletest/header.rs +++ b/src/compiletest/header.rs @@ -34,6 +34,8 @@ pub struct TestProps { pub exec_env: Vec<(String,String)> , // Lines to check if they appear in the expected debugger output pub check_lines: Vec , + // Build documentation for all specified aux-builds as well + pub build_aux_docs: 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 @@ -59,6 +61,7 @@ pub fn load_props(testfile: &Path) -> TestProps { let mut run_flags = None; let mut pp_exact = None; let mut check_lines = Vec::new(); + let mut build_aux_docs = false; let mut force_host = false; let mut check_stdout = false; let mut no_prefer_dynamic = false; @@ -83,6 +86,10 @@ pub fn load_props(testfile: &Path) -> TestProps { pp_exact = parse_pp_exact(ln, testfile); } + if !build_aux_docs { + build_aux_docs = parse_build_aux_docs(ln); + } + if !force_host { force_host = parse_force_host(ln); } @@ -144,6 +151,7 @@ pub fn load_props(testfile: &Path) -> TestProps { aux_builds: aux_builds, exec_env: exec_env, check_lines: check_lines, + build_aux_docs: build_aux_docs, force_host: force_host, check_stdout: check_stdout, no_prefer_dynamic: no_prefer_dynamic, @@ -284,6 +292,10 @@ fn parse_force_host(line: &str) -> bool { parse_name_directive(line, "force-host") } +fn parse_build_aux_docs(line: &str) -> bool { + parse_name_directive(line, "build-aux-docs") +} + fn parse_check_stdout(line: &str) -> bool { parse_name_directive(line, "check-stdout") } diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index 8042e2f966c..833ab553a13 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -1149,11 +1149,20 @@ fn compile_test(config: &Config, props: &TestProps, } fn document(config: &Config, props: &TestProps, - testfile: &Path) -> (ProcRes, PathBuf) { + testfile: &Path, out_dir: &Path) -> ProcRes { + if props.build_aux_docs { + for rel_ab in &props.aux_builds { + let abs_ab = config.aux_base.join(rel_ab); + let aux_props = header::load_props(&abs_ab); + + let auxres = document(config, &aux_props, &abs_ab, out_dir); + if !auxres.status.success() { + return auxres; + } + } + } + let aux_dir = aux_output_dir_name(config, testfile); - let out_dir = output_base_name(config, testfile); - let _ = fs::remove_dir_all(&out_dir); - ensure_dir(&out_dir); let mut args = vec!["-L".to_owned(), aux_dir.to_str().unwrap().to_owned(), "-o".to_owned(), @@ -1164,7 +1173,7 @@ fn document(config: &Config, props: &TestProps, prog: config.rustdoc_path.to_str().unwrap().to_owned(), args: args, }; - (compose_and_run_compiler(config, props, testfile, args, None), out_dir) + compose_and_run_compiler(config, props, testfile, args, None) } fn exec_compiled_test(config: &Config, props: &TestProps, @@ -1723,7 +1732,11 @@ fn charset() -> &'static str { } fn run_rustdoc_test(config: &Config, props: &TestProps, testfile: &Path) { - let (proc_res, out_dir) = document(config, props, testfile); + let out_dir = output_base_name(config, testfile); + let _ = fs::remove_dir_all(&out_dir); + ensure_dir(&out_dir); + + let proc_res = document(config, props, testfile, &out_dir); if !proc_res.status.success() { fatal_proc_rec("rustdoc failed!", &proc_res); } -- 2.44.0