From 9f63776121db2f5cb8833e2f7d2fac37165dde87 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sat, 26 Aug 2023 12:23:31 +0000 Subject: [PATCH] Give an error instead of a panic if the lockfile is missing --- src/tools/tidy/src/deps.rs | 5 +++++ src/tools/tidy/src/extdeps.rs | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index 87f07f232bb2..2f7440cba88c 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -436,6 +436,11 @@ pub fn check(root: &Path, cargo: &Path, bad: &mut bool) { let mut rust_metadata = None; for &(workspace, exceptions, permitted_deps) in WORKSPACES { + if !root.join(workspace).join("Cargo.lock").exists() { + tidy_error!(bad, "the `{workspace}` workspace doesn't have a Cargo.lock"); + continue; + } + let mut cmd = cargo_metadata::MetadataCommand::new(); cmd.cargo_path(cargo) .manifest_path(root.join(workspace).join("Cargo.toml")) diff --git a/src/tools/tidy/src/extdeps.rs b/src/tools/tidy/src/extdeps.rs index 2556b19a7d6b..44d13043e461 100644 --- a/src/tools/tidy/src/extdeps.rs +++ b/src/tools/tidy/src/extdeps.rs @@ -14,6 +14,11 @@ pub fn check(root: &Path, bad: &mut bool) { // `Cargo.lock` of rust. let path = root.join(workspace).join("Cargo.lock"); + if !path.exists() { + tidy_error!(bad, "the `{workspace}` workspace doesn't have a Cargo.lock"); + continue; + } + // Open and read the whole file. let cargo_lock = t!(fs::read_to_string(&path));