diff options
| author | Guillaume Gomez <guillaume.gomez@huawei.com> | 2024-05-25 13:03:53 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume.gomez@huawei.com> | 2024-05-27 14:41:19 +0200 |
| commit | 1551fd12023e3b84d844bde2e376c407af1e9a04 (patch) | |
| tree | 7a91b9a9b069efcf270a913b666e87b06634cbe2 | |
| parent | 90fec5a0873c82674890a9f67b73a4f0a35e9d0b (diff) | |
| download | rust-1551fd12023e3b84d844bde2e376c407af1e9a04.tar.gz rust-1551fd12023e3b84d844bde2e376c407af1e9a04.zip | |
Add file path in case it cannot be read in `Diff::actual_file`
| -rw-r--r-- | src/tools/run-make-support/src/diff/mod.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/tools/run-make-support/src/diff/mod.rs b/src/tools/run-make-support/src/diff/mod.rs index 332126939c0..d864ddf4eb1 100644 --- a/src/tools/run-make-support/src/diff/mod.rs +++ b/src/tools/run-make-support/src/diff/mod.rs @@ -51,7 +51,10 @@ impl Diff { /// Specify the actual output for the diff from a file. pub fn actual_file<P: AsRef<Path>>(&mut self, path: P) -> &mut Self { let path = path.as_ref(); - let content = std::fs::read_to_string(path).expect("failed to read file"); + let content = match std::fs::read_to_string(path) { + Ok(c) => c, + Err(e) => panic!("failed to read `{}`: {:?}", path.display(), e), + }; let name = path.to_string_lossy().to_string(); self.actual = Some(content); |
