From 356b812b1804010fd28905a41fdaa1a95e73b20d Mon Sep 17 00:00:00 2001 From: onur-ozkan Date: Fri, 8 Mar 2024 23:36:36 +0300 Subject: [PATCH] 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 reading the second argument, which always equals to the source root (see https://github.com/rust-lang/rust/blob/a655e648a9f94d74263108366b83e677af56e35d/src/bootstrap/src/core/build_steps/test.rs#L1081). Signed-off-by: onur-ozkan --- src/tools/tidy/src/ui_tests.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs index 1a53637ad42f9..f7309730a1317 100644 --- a/src/tools/tidy/src/ui_tests.rs +++ b/src/tools/tidy/src/ui_tests.rs @@ -5,6 +5,7 @@ use ignore::Walk; use lazy_static::lazy_static; use regex::Regex; use std::collections::{BTreeSet, HashMap}; +use std::env; use std::ffi::OsStr; use std::fs; use std::io::Write; @@ -184,7 +185,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 = PathBuf::from(env::args_os().nth(1).unwrap()).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");