about summary refs log tree commit diff
path: root/src/bootstrap
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2016-04-14 18:00:35 -0700
committerAlex Crichton <alex@alexcrichton.com>2016-04-19 09:52:56 -0700
commitede8944ea778e33b0c268fdd0545cb2b15b9cf24 (patch)
treea778ca6b0af1d09113fde88b1dfbccf841b046d1 /src/bootstrap
parent478a33dabc4e6f2f501f476c79b56178d9df4f37 (diff)
rustbuild: Run all markdown documentation tests
This commit adds support to rustbuild to run all documentation tests, basically
running `rustdoc --test` over all our documentation. This also includes support
for running the error index tests.
Diffstat (limited to 'src/bootstrap')
-rw-r--r--src/bootstrap/build/check.rs42
-rw-r--r--src/bootstrap/build/mod.rs6
-rw-r--r--src/bootstrap/build/step.rs11
3 files changed, 58 insertions, 1 deletions
diff --git a/src/bootstrap/build/check.rs b/src/bootstrap/build/check.rs
index f145a7149fb..4e03be342aa 100644
--- a/src/bootstrap/build/check.rs
+++ b/src/bootstrap/build/check.rs
@@ -9,7 +9,8 @@
 // except according to those terms.
 
 use std::fs;
-use std::path::PathBuf;
+use std::path::{PathBuf, Path};
+use std::process::Command;
 
 use build::{Build, Compiler};
 
@@ -102,3 +103,42 @@ pub fn compiletest(build: &Build,
 
     build.run(&mut cmd);
 }
+
+pub fn docs(build: &Build, compiler: &Compiler) {
+    let mut stack = vec![build.src.join("src/doc")];
+
+    while let Some(p) = stack.pop() {
+        if p.is_dir() {
+            stack.extend(t!(p.read_dir()).map(|p| t!(p).path()));
+            continue
+        }
+
+        if p.extension().and_then(|s| s.to_str()) != Some("md") {
+            continue
+        }
+
+        println!("doc tests for: {}", p.display());
+        markdown_test(build, compiler, &p);
+    }
+}
+
+pub fn error_index(build: &Build, compiler: &Compiler) {
+    println!("Testing error-index stage{}", compiler.stage);
+
+    let output = testdir(build, compiler.host).join("error-index.md");
+    build.run(build.tool_cmd(compiler, "error_index_generator")
+                   .arg("markdown")
+                   .arg(&output)
+                   .env("CFG_BUILD", &build.config.build));
+
+    markdown_test(build, compiler, &output);
+}
+
+fn markdown_test(build: &Build, compiler: &Compiler, markdown: &Path) {
+    let mut cmd = Command::new(build.rustdoc(compiler));
+    build.add_rustc_lib_path(compiler, &mut cmd);
+    cmd.arg("--test");
+    cmd.arg(markdown);
+    cmd.arg("--test-args").arg(build.flags.args.join(" "));
+    build.run(&mut cmd);
+}
diff --git a/src/bootstrap/build/mod.rs b/src/bootstrap/build/mod.rs
index e755416f17f..a35bdae9795 100644
--- a/src/bootstrap/build/mod.rs
+++ b/src/bootstrap/build/mod.rs
@@ -306,6 +306,12 @@ impl Build {
                     check::compiletest(self, &compiler, target.target,
                                        "compile-fail", "compile-fail-fulldeps")
                 }
+                CheckDocs { compiler } => {
+                    check::docs(self, &compiler);
+                }
+                CheckErrorIndex { compiler } => {
+                    check::error_index(self, &compiler);
+                }
 
                 DistDocs { stage } => dist::docs(self, stage, target.target),
                 DistMingw { _dummy } => dist::mingw(self, target.target),
diff --git a/src/bootstrap/build/step.rs b/src/bootstrap/build/step.rs
index a22b28a6cdd..5f02f233d47 100644
--- a/src/bootstrap/build/step.rs
+++ b/src/bootstrap/build/step.rs
@@ -96,6 +96,8 @@ macro_rules! targets {
             (check_rpass_valgrind, CheckRPassValgrind { compiler: Compiler<'a> }),
             (check_rpass_full, CheckRPassFull { compiler: Compiler<'a> }),
             (check_cfail_full, CheckCFailFull { compiler: Compiler<'a> }),
+            (check_docs, CheckDocs { compiler: Compiler<'a> }),
+            (check_error_index, CheckErrorIndex { compiler: Compiler<'a> }),
 
             // Distribution targets, creating tarballs
             (dist, Dist { stage: u32 }),
@@ -341,7 +343,10 @@ impl<'a> Step<'a> {
                     self.check_rpass_valgrind(compiler),
                     self.check_rpass_full(compiler),
                     self.check_cfail_full(compiler),
+                    self.check_error_index(compiler),
+                    self.check_docs(compiler),
                     self.check_linkcheck(stage),
+                    self.check_tidy(stage),
                     self.dist(stage),
                 ]
             }
@@ -383,6 +388,12 @@ impl<'a> Step<'a> {
                 vec![self.librustc(compiler),
                      self.tool_compiletest(compiler.stage)]
             }
+            Source::CheckDocs { compiler } => {
+                vec![self.libstd(compiler)]
+            }
+            Source::CheckErrorIndex { compiler } => {
+                vec![self.libstd(compiler), self.tool_error_index(compiler.stage)]
+            }
 
             Source::ToolLinkchecker { stage } |
             Source::ToolTidy { stage } => {