Skip to content

Commit 8c5fc20

Browse files
authored
Rollup merge of #115943 - ehuss:compiletest-errors, r=compiler-errors
compiletest: Don't swallow some error messages. This updates some error handling in compiletest to display the underlying error rather than discarding it. There have been cases where the lack of error information makes it difficult to understand what went wrong.
2 parents 3ddad37 + 10a5b9a commit 8c5fc20

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Diff for: src/tools/compiletest/src/runtest.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ impl<'test> TestCx<'test> {
695695
}
696696

697697
fn run_command_to_procres(&self, cmd: &mut Command) -> ProcRes {
698-
let output = cmd.output().unwrap_or_else(|_| panic!("failed to exec `{cmd:?}`"));
698+
let output = cmd.output().unwrap_or_else(|e| panic!("failed to exec `{cmd:?}`: {e:?}"));
699699

700700
let proc_res = ProcRes {
701701
status: output.status,
@@ -1216,12 +1216,12 @@ impl<'test> TestCx<'test> {
12161216
.arg(&exe_file)
12171217
.arg(&self.config.adb_test_dir)
12181218
.status()
1219-
.unwrap_or_else(|_| panic!("failed to exec `{:?}`", adb_path));
1219+
.unwrap_or_else(|e| panic!("failed to exec `{adb_path:?}`: {e:?}"));
12201220

12211221
Command::new(adb_path)
12221222
.args(&["forward", "tcp:5039", "tcp:5039"])
12231223
.status()
1224-
.unwrap_or_else(|_| panic!("failed to exec `{:?}`", adb_path));
1224+
.unwrap_or_else(|e| panic!("failed to exec `{adb_path:?}`: {e:?}"));
12251225

12261226
let adb_arg = format!(
12271227
"export LD_LIBRARY_PATH={}; \
@@ -1238,7 +1238,7 @@ impl<'test> TestCx<'test> {
12381238
.stdout(Stdio::piped())
12391239
.stderr(Stdio::inherit())
12401240
.spawn()
1241-
.unwrap_or_else(|_| panic!("failed to exec `{:?}`", adb_path));
1241+
.unwrap_or_else(|e| panic!("failed to exec `{adb_path:?}`: {e:?}"));
12421242

12431243
// Wait for the gdbserver to print out "Listening on port ..."
12441244
// at which point we know that it's started and then we can
@@ -1263,7 +1263,7 @@ impl<'test> TestCx<'test> {
12631263
let Output { status, stdout, stderr } = Command::new(&gdb_path)
12641264
.args(debugger_opts)
12651265
.output()
1266-
.unwrap_or_else(|_| panic!("failed to exec `{:?}`", gdb_path));
1266+
.unwrap_or_else(|e| panic!("failed to exec `{gdb_path:?}`: {e:?}"));
12671267
let cmdline = {
12681268
let mut gdb = Command::new(&format!("{}-gdb", self.config.target));
12691269
gdb.args(debugger_opts);
@@ -2277,7 +2277,7 @@ impl<'test> TestCx<'test> {
22772277
add_dylib_path(&mut command, iter::once(lib_path).chain(aux_path));
22782278

22792279
let mut child = disable_error_reporting(|| command.spawn())
2280-
.unwrap_or_else(|_| panic!("failed to exec `{:?}`", &command));
2280+
.unwrap_or_else(|e| panic!("failed to exec `{command:?}`: {e:?}"));
22812281
if let Some(input) = input {
22822282
child.stdin.as_mut().unwrap().write_all(input.as_bytes()).unwrap();
22832283
}
@@ -3847,8 +3847,8 @@ impl<'test> TestCx<'test> {
38473847
.open(coverage_file_path.as_path())
38483848
.expect("could not create or open file");
38493849

3850-
if writeln!(file, "{}", self.testpaths.file.display()).is_err() {
3851-
panic!("couldn't write to {}", coverage_file_path.display());
3850+
if let Err(e) = writeln!(file, "{}", self.testpaths.file.display()) {
3851+
panic!("couldn't write to {}: {e:?}", coverage_file_path.display());
38523852
}
38533853
}
38543854
} else if self.props.run_rustfix {

0 commit comments

Comments
 (0)