Skip to content

Commit

Permalink
fix incorrect path resolution in tidy
Browse files Browse the repository at this point in the history
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`.

Signed-off-by: onur-ozkan <[email protected]>
  • Loading branch information
onur-ozkan committed Mar 8, 2024
1 parent 7b790ad commit 3c67ab6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/tools/tidy/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/tools/tidy/src/ui_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ 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;
Expand Down Expand Up @@ -100,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`
Expand Down Expand Up @@ -185,7 +185,7 @@ pub fn check(path: &Path, bless: bool, bad: &mut bool) {
*/
[
"#;
let tidy_src = PathBuf::from(env::args_os().nth(1).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");
Expand Down

0 comments on commit 3c67ab6

Please sign in to comment.