about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-03-09 16:21:18 +0100
committerGitHub <noreply@github.com>2024-03-09 16:21:18 +0100
commita5adac0ea3fb487ebb254e2e79350ad12236c634 (patch)
treefd67d6ae303517490d358bca8e82ff3761f6dd97
parent9ac5cc86d7ffcedb37ce52c43a6baca6bdf24df0 (diff)
parent7c13421dc0498e05624946327b1a022f2fa7b294 (diff)
downloadrust-a5adac0ea3fb487ebb254e2e79350ad12236c634.tar.gz
rust-a5adac0ea3fb487ebb254e2e79350ad12236c634.zip
Rollup merge of #122209 - onur-ozkan:fix-tidy-path-resolution, r=compiler-errors
fix incorrect path resolution in tidy

Previously, reading the current path from the environment led to failure when invoking x from outside the source root. This change fixes this issue by passing the already resolved root path into `ui_tests::check`.

Fixes #122202
-rw-r--r--src/tools/tidy/src/main.rs2
-rw-r--r--src/tools/tidy/src/ui_tests.rs5
2 files changed, 4 insertions, 3 deletions
diff --git a/src/tools/tidy/src/main.rs b/src/tools/tidy/src/main.rs
index 4b98c91319d..2bce246c308 100644
--- a/src/tools/tidy/src/main.rs
+++ b/src/tools/tidy/src/main.rs
@@ -102,7 +102,7 @@ fn main() {
         check!(tests_placement, &root_path);
         check!(tests_revision_unpaired_stdout_stderr, &tests_path);
         check!(debug_artifacts, &tests_path);
-        check!(ui_tests, &tests_path, bless);
+        check!(ui_tests, &root_path, bless);
         check!(mir_opt_tests, &tests_path, bless);
         check!(rustdoc_gui_tests, &tests_path);
         check!(rustdoc_css_themes, &librustdoc_path);
diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs
index 39b14adfea4..c946554b98f 100644
--- a/src/tools/tidy/src/ui_tests.rs
+++ b/src/tools/tidy/src/ui_tests.rs
@@ -99,7 +99,8 @@ fn check_entries(tests_path: &Path, bad: &mut bool) {
     }
 }
 
-pub fn check(path: &Path, bless: bool, bad: &mut bool) {
+pub fn check(root_path: &Path, bless: bool, bad: &mut bool) {
+    let path = &root_path.join("tests");
     check_entries(&path, bad);
 
     // the list of files in ui tests that are allowed to start with `issue-XXXX`
@@ -193,7 +194,7 @@ pub fn check(path: &Path, bless: bool, bad: &mut bool) {
 */
 [
 "#;
-        let tidy_src = std::env::current_dir().unwrap().join("src/tools/tidy/src");
+        let tidy_src = root_path.join("src/tools/tidy/src");
         // instead of overwriting the file, recreate it and use an "atomic rename"
         // so we don't bork things on panic or a contributor using Ctrl+C
         let blessed_issues_path = tidy_src.join("issues_blessed.txt");