Skip to content

Commit c951ed7

Browse files
Add tested item in the rustdoc --test output
1 parent bae454e commit c951ed7

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

Diff for: src/librustdoc/test.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -418,8 +418,12 @@ impl Collector {
418418
should_panic: bool, no_run: bool, should_ignore: bool,
419419
as_test_harness: bool, compile_fail: bool, error_codes: Vec<String>,
420420
line: usize, filename: String) {
421-
let name = format!("{} - line {}", filename, line);
422-
self.cnt += 1;
421+
let name = if self.use_headers {
422+
let s = self.current_header.as_ref().map(|s| &**s).unwrap_or("");
423+
format!("{} - {} (line {})", filename, s, line)
424+
} else {
425+
format!("{} - {} (line {})", filename, self.names.join("::"), line)
426+
};
423427
let cfgs = self.cfgs.clone();
424428
let libs = self.libs.clone();
425429
let externs = self.externs.clone();

Diff for: src/test/run-make/issue-22131/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ all: foo.rs
44
$(RUSTC) --cfg 'feature="bar"' --crate-type lib foo.rs
55
$(HOST_RPATH_ENV) '$(RUSTDOC)' --test --cfg 'feature="bar"' \
66
-L $(TMPDIR) foo.rs |\
7-
grep -q 'foo.rs - line 11 ... ok'
7+
grep -q 'foo.rs - foo (line 11) ... ok'

Diff for: src/tools/compiletest/src/runtest.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -1998,16 +1998,20 @@ actual:\n\
19981998
for _ in res.stdout.split("\n")
19991999
.filter(|s| s.starts_with("test "))
20002000
.inspect(|s| {
2001-
let tmp: Vec<&str> = s.split(" - line ").collect();
2001+
let tmp: Vec<&str> = s.split(" - ").collect();
20022002
if tmp.len() == 2 {
20032003
let path = tmp[0].rsplit("test ").next().unwrap();
20042004
if let Some(ref mut v) = files.get_mut(path) {
20052005
tested += 1;
2006-
let line = tmp[1].split(" ...")
2007-
.next()
2008-
.unwrap_or("0")
2009-
.parse()
2010-
.unwrap_or(0);
2006+
let mut iter = tmp[1].split("(line ");
2007+
iter.next();
2008+
let line = iter.next()
2009+
.unwrap_or(")")
2010+
.split(")")
2011+
.next()
2012+
.unwrap_or("0")
2013+
.parse()
2014+
.unwrap_or(0);
20112015
if let Ok(pos) = v.binary_search(&line) {
20122016
v.remove(pos);
20132017
} else {

0 commit comments

Comments
 (0)