about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDylan DPC <99973273+Dylan-DPC@users.noreply.github.com>2022-04-07 06:04:51 +0200
committerGitHub <noreply@github.com>2022-04-07 06:04:51 +0200
commitf7499a892ea5dde8057fce3f92d4398adf57255d (patch)
tree54501a1e96727f24bb449ae66102962a462bcf88
parent2310da432ca1c3e87f1d17e069f2336f2d4939e5 (diff)
parentd0a326044ec21fa22828beaedeb9b23b856ea592 (diff)
downloadrust-f7499a892ea5dde8057fce3f92d4398adf57255d.tar.gz
rust-f7499a892ea5dde8057fce3f92d4398adf57255d.zip
Rollup merge of #95352 - jyn514:full-relative-path, r=Mark-Simulacrum
[bootstrap] Print the full relative path to failed tests

Before:
```
failures:
    [ui] rustdoc-ui/intra-doc/feature-gate-intra-doc-pointers.rs

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 163 filtered out; finished in 0.45s
```

After:
```
failures:
    [ui] src/test/rustdoc-ui/intra-doc/feature-gate-intra-doc-pointers.rs

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 163 filtered out; finished in 0.45s
```

This allows copy pasting the path or using Ctrl+Click in IDEs to go directly to the file, instead of having to edit the filename first.
-rw-r--r--src/tools/compiletest/src/main.rs10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs
index 503b624114a..8c1f28f1407 100644
--- a/src/tools/compiletest/src/main.rs
+++ b/src/tools/compiletest/src/main.rs
@@ -744,12 +744,10 @@ fn make_test_name(
     testpaths: &TestPaths,
     revision: Option<&String>,
 ) -> test::TestName {
-    // Convert a complete path to something like
-    //
-    //    ui/foo/bar/baz.rs
-    let path = PathBuf::from(config.src_base.file_name().unwrap())
-        .join(&testpaths.relative_dir)
-        .join(&testpaths.file.file_name().unwrap());
+    // Print the name of the file, relative to the repository root.
+    // `src_base` looks like `/path/to/rust/src/test/ui`
+    let root_directory = config.src_base.parent().unwrap().parent().unwrap().parent().unwrap();
+    let path = testpaths.file.strip_prefix(root_directory).unwrap();
     let debugger = match config.debugger {
         Some(d) => format!("-{}", d),
         None => String::new(),