about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbinarycat <binarycat@envs.net>2025-08-09 11:32:24 -0500
committerbinarycat <binarycat@envs.net>2025-08-16 13:36:29 -0500
commit6a51eef11b0d43bc7a0f0e20142649fe2783d9f3 (patch)
tree5f9d2ba850a26669e99b2924c2d2d4a5561f2358
parent1cb4fd7dd12be93465a55d56622c52002e3b050b (diff)
downloadrust-6a51eef11b0d43bc7a0f0e20142649fe2783d9f3.tar.gz
rust-6a51eef11b0d43bc7a0f0e20142649fe2783d9f3.zip
tidy: run typos check in src root, not current dir
-rw-r--r--src/tools/tidy/src/extra_checks/mod.rs21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/tools/tidy/src/extra_checks/mod.rs b/src/tools/tidy/src/extra_checks/mod.rs
index 604b5d1e37c..d44fc3999f7 100644
--- a/src/tools/tidy/src/extra_checks/mod.rs
+++ b/src/tools/tidy/src/extra_checks/mod.rs
@@ -295,7 +295,7 @@ fn check_impl(
         } else {
             eprintln!("spellcheck files");
         }
-        spellcheck_runner(&outdir, &cargo, &args)?;
+        spellcheck_runner(root_path, &outdir, &cargo, &args)?;
     }
 
     if js_lint || js_typecheck {
@@ -579,12 +579,25 @@ fn shellcheck_runner(args: &[&OsStr]) -> Result<(), Error> {
 }
 
 /// Ensure that spellchecker is installed then run it at the given path
-fn spellcheck_runner(outdir: &Path, cargo: &Path, args: &[&str]) -> Result<(), Error> {
+fn spellcheck_runner(
+    src_root: &Path,
+    outdir: &Path,
+    cargo: &Path,
+    args: &[&str],
+) -> Result<(), Error> {
     let bin_path =
         crate::ensure_version_or_cargo_install(outdir, cargo, "typos-cli", "typos", "1.34.0")?;
 
-    let status = Command::new(bin_path).args(args).status()?;
-    if status.success() { Ok(()) } else { Err(Error::FailedCheck("typos")) }
+    match Command::new(bin_path).current_dir(src_root).args(args).status() {
+        Ok(status) => {
+            if status.success() {
+                Ok(())
+            } else {
+                Err(Error::FailedCheck("typos"))
+            }
+        }
+        Err(err) => Err(Error::Generic(format!("failed to run typos tool: {err:?}"))),
+    }
 }
 
 /// Check git for tracked files matching an extension