]> git.lizzy.rs Git - rust.git/commitdiff
Add a `build-aux-docs` directive to compiletest
authormitaa <mitaa.ceb@gmail.com>
Thu, 3 Dec 2015 21:19:58 +0000 (22:19 +0100)
committermitaa <mitaa.ceb@gmail.com>
Thu, 3 Dec 2015 21:20:29 +0000 (22:20 +0100)
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
src/compiletest/runtest.rs

index 9de46cef7455c150a681c3df228d6fbdef538d86..6efe6e608e8ad9cd83188462a2134caaffc48c9b 100644 (file)
@@ -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<String> ,
+    // 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")
 }
index 8042e2f966ca73e8582579b9f9619dbcc7968e56..833ab553a132f9d9c0dbaf7b929c1c32e5ecbf89 100644 (file)
@@ -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);
     }