|
| 1 | +use anyhow::Context; |
1 | 2 | use std::env;
|
2 | 3 | use std::ffi::OsString;
|
3 | 4 | use std::fs;
|
@@ -113,7 +114,7 @@ fn main() {
|
113 | 114 | let filename = profile_data.file_name().unwrap().to_str().unwrap();
|
114 | 115 | let json = run_summarize("summarize", &prof_out_dir, filename)
|
115 | 116 | .or_else(|_| run_summarize("summarize-9.0", &prof_out_dir, filename))
|
116 |
| - .expect("able to run summarize or summarize-0.7"); |
| 117 | + .expect("able to run summarize or summarize-9.0"); |
117 | 118 | println!("!self-profile-output:{}", json);
|
118 | 119 | } else {
|
119 | 120 | let prefix = prefix.expect(&format!("found prefix {:?}", prof_out_dir));
|
@@ -343,19 +344,22 @@ fn print_time(dur: Duration) {
|
343 | 344 | );
|
344 | 345 | }
|
345 | 346 |
|
346 |
| -fn run_summarize(name: &str, prof_out_dir: &Path, prefix: &str) -> std::io::Result<String> { |
| 347 | +fn run_summarize(name: &str, prof_out_dir: &Path, prefix: &str) -> anyhow::Result<String> { |
347 | 348 | let mut cmd = Command::new(name);
|
348 | 349 | cmd.current_dir(&prof_out_dir);
|
349 | 350 | cmd.arg("summarize").arg("--json");
|
350 | 351 | cmd.arg(&prefix);
|
351 | 352 | let status = cmd.status()?;
|
352 | 353 | if !status.success() {
|
353 |
| - return Err(std::io::Error::new( |
354 |
| - std::io::ErrorKind::Other, |
355 |
| - "Failed to run successfully", |
356 |
| - )); |
| 354 | + anyhow::bail!( |
| 355 | + "failed to run {} in {:?} with prefix {:?}", |
| 356 | + name, |
| 357 | + prof_out_dir, |
| 358 | + prefix |
| 359 | + ) |
357 | 360 | }
|
358 |
| - fs::read_to_string(prof_out_dir.join(&format!("{}.json", prefix))) |
| 361 | + let json = prof_out_dir.join(&format!("{}.json", prefix)); |
| 362 | + fs::read_to_string(&json).with_context(|| format!("failed to read {:?}", json)) |
359 | 363 | }
|
360 | 364 |
|
361 | 365 | #[cfg(windows)]
|
|
0 commit comments