]> git.lizzy.rs Git - rust.git/commitdiff
Add tested item in the rustdoc --test output
authorGuillaume Gomez <guillaume1.gomez@gmail.com>
Sat, 11 Feb 2017 15:36:31 +0000 (16:36 +0100)
committerGuillaume Gomez <guillaume1.gomez@gmail.com>
Sat, 11 Feb 2017 15:36:31 +0000 (16:36 +0100)
src/librustdoc/test.rs
src/test/run-make/issue-22131/Makefile
src/tools/compiletest/src/runtest.rs

index 930cf401e74501b202a0f49b404c07301b34cf7e..349bddc87405cbeb2331a714bd8b738f4b0caa67 100644 (file)
@@ -418,8 +418,12 @@ pub fn add_test(&mut self, test: String,
                     should_panic: bool, no_run: bool, should_ignore: bool,
                     as_test_harness: bool, compile_fail: bool, error_codes: Vec<String>,
                     line: usize, filename: String) {
-        let name = format!("{} - line {}", filename, line);
-        self.cnt += 1;
+        let name = if self.use_headers {
+            let s = self.current_header.as_ref().map(|s| &**s).unwrap_or("");
+            format!("{} - {} (line {})", filename, s, line)
+        } else {
+            format!("{} - {} (line {})", filename, self.names.join("::"), line)
+        };
         let cfgs = self.cfgs.clone();
         let libs = self.libs.clone();
         let externs = self.externs.clone();
index f65cc9e06a329486e467e2071605dd08cbfb1684..64af91b487b322f82e913337175eca6a3091de75 100644 (file)
@@ -4,4 +4,4 @@ all: foo.rs
        $(RUSTC) --cfg 'feature="bar"' --crate-type lib foo.rs
        $(HOST_RPATH_ENV) '$(RUSTDOC)' --test --cfg 'feature="bar"' \
                -L $(TMPDIR) foo.rs |\
-               grep -q 'foo.rs - line 11 ... ok'
+               grep -q 'foo.rs - foo (line 11) ... ok'
index 1a3d7a190be366bb1d655a1da9d88fc768252a5f..d0aba8a0b0a7eb0d427dcae5b254113c70894d85 100644 (file)
@@ -1998,16 +1998,20 @@ fn check_rustdoc_test_option(&self, res: ProcRes) {
         for _ in res.stdout.split("\n")
                            .filter(|s| s.starts_with("test "))
                            .inspect(|s| {
-                               let tmp: Vec<&str> = s.split(" - line ").collect();
+                               let tmp: Vec<&str> = s.split(" - ").collect();
                                if tmp.len() == 2 {
                                    let path = tmp[0].rsplit("test ").next().unwrap();
                                    if let Some(ref mut v) = files.get_mut(path) {
                                        tested += 1;
-                                       let line = tmp[1].split(" ...")
-                                                        .next()
-                                                        .unwrap_or("0")
-                                                        .parse()
-                                                        .unwrap_or(0);
+                                       let mut iter = tmp[1].split("(line ");
+                                       iter.next();
+                                       let line = iter.next()
+                                                      .unwrap_or(")")
+                                                      .split(")")
+                                                      .next()
+                                                      .unwrap_or("0")
+                                                      .parse()
+                                                      .unwrap_or(0);
                                        if let Ok(pos) = v.binary_search(&line) {
                                            v.remove(pos);
                                        } else {