From 3dec37f1cc0d2dc30a47116678ebfe69165ea600 Mon Sep 17 00:00:00 2001
From: Jieyou Xu <jieyouxu@outlook.com>
Date: Tue, 8 Apr 2025 16:09:03 +0800
Subject: [PATCH 1/2] compiletest: sort dependencies alphabetically

---
 src/tools/compiletest/Cargo.toml | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/tools/compiletest/Cargo.toml b/src/tools/compiletest/Cargo.toml
index 4f8e475e7625f..4c661207bf457 100644
--- a/src/tools/compiletest/Cargo.toml
+++ b/src/tools/compiletest/Cargo.toml
@@ -7,25 +7,27 @@ edition = "2021"
 doctest = false
 
 [dependencies]
+# tidy-alphabetical-start
 anstyle-svg = "0.1.3"
+anyhow = "1"
+build_helper = { path = "../../build_helper" }
 colored = "2"
 diff = "0.1.10"
-unified-diff = "0.2.1"
 getopts = "0.2"
+glob = "0.3.0"
+home = "0.5.5"
 indexmap = "2.0.0"
 miropt-test-tools = { path = "../miropt-test-tools" }
-build_helper = { path = "../../build_helper" }
-tracing = "0.1"
-tracing-subscriber = { version = "0.3.3", default-features = false, features = ["ansi", "env-filter", "fmt", "parking_lot", "smallvec"] }
 regex = "1.0"
+rustfix = "0.8.1"
 semver = { version = "1.0.23", features = ["serde"] }
 serde = { version = "1.0", features = ["derive"] }
 serde_json = "1.0"
-rustfix = "0.8.1"
+tracing = "0.1"
+tracing-subscriber = { version = "0.3.3", default-features = false, features = ["ansi", "env-filter", "fmt", "parking_lot", "smallvec"] }
+unified-diff = "0.2.1"
 walkdir = "2"
-glob = "0.3.0"
-anyhow = "1"
-home = "0.5.5"
+# tidy-alphabetical-end
 
 [target.'cfg(unix)'.dependencies]
 libc = "0.2"

From 603685cd7469265a014e9865b4fb840f713453eb Mon Sep 17 00:00:00 2001
From: Jieyou Xu <jieyouxu@outlook.com>
Date: Tue, 8 Apr 2025 16:11:26 +0800
Subject: [PATCH 2/2] compiletest: drop dependency on `anyhow`

Currently `compiletest` panics all over the place but doesn't really use
`anyhow` anyway. I'd like to introduce some more principled error
handling and disciplined diagnostic reporting in the near future.
---
 Cargo.lock                           |  1 -
 src/tools/compiletest/Cargo.toml     |  1 -
 src/tools/compiletest/src/runtest.rs | 11 +++++------
 3 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock
index 52c9269fa87f0..0d184fa280bd5 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -676,7 +676,6 @@ name = "compiletest"
 version = "0.0.0"
 dependencies = [
  "anstyle-svg",
- "anyhow",
  "build_helper",
  "colored",
  "diff",
diff --git a/src/tools/compiletest/Cargo.toml b/src/tools/compiletest/Cargo.toml
index 4c661207bf457..06e618c2d254b 100644
--- a/src/tools/compiletest/Cargo.toml
+++ b/src/tools/compiletest/Cargo.toml
@@ -9,7 +9,6 @@ doctest = false
 [dependencies]
 # tidy-alphabetical-start
 anstyle-svg = "0.1.3"
-anyhow = "1"
 build_helper = { path = "../../build_helper" }
 colored = "2"
 diff = "0.1.10"
diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
index c8a60b68da8b2..6446f9b11ae76 100644
--- a/src/tools/compiletest/src/runtest.rs
+++ b/src/tools/compiletest/src/runtest.rs
@@ -10,7 +10,6 @@ use std::process::{Child, Command, ExitStatus, Output, Stdio};
 use std::sync::Arc;
 use std::{env, iter, str};
 
-use anyhow::Context;
 use colored::Colorize;
 use regex::{Captures, Regex};
 use tracing::*;
@@ -143,11 +142,11 @@ pub fn run(config: Arc<Config>, testpaths: &TestPaths, revision: Option<&str>) {
     }
 
     let cx = TestCx { config: &config, props: &props, testpaths, revision };
-    create_dir_all(&cx.output_base_dir())
-        .with_context(|| {
-            format!("failed to create output base directory {}", cx.output_base_dir().display())
-        })
-        .unwrap();
+
+    if let Err(e) = create_dir_all(&cx.output_base_dir()) {
+        panic!("failed to create output base directory {}: {e}", cx.output_base_dir().display());
+    }
+
     if props.incremental {
         cx.init_incremental_test();
     }