Skip to content

Commit 623acd9

Browse files
Append .json to mm_profdata filename appropiately
1 parent 00502c7 commit 623acd9

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

collector/src/rustc-fake.rs

+18-5
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,17 @@ fn main() {
112112
// measureme 0.8 has a single file
113113
println!("!self-profile-file:{}", profile_data.to_str().unwrap());
114114
let filename = profile_data.file_name().unwrap().to_str().unwrap();
115-
let json = run_summarize("summarize", &prof_out_dir, filename)
116-
.or_else(|_| run_summarize("summarize-9.0", &prof_out_dir, filename))
117-
.expect("able to run summarize or summarize-9.0");
115+
let json = match run_summarize("summarize", &prof_out_dir, filename) {
116+
Ok(s) => s,
117+
Err(e1) => {
118+
match run_summarize("summarize-9.0", &prof_out_dir, filename) {
119+
Ok(s) => s,
120+
Err(e2) => {
121+
panic!("failed to run summarize and summarize-9.0. Errors:\nsummarize: {:?}\nsummarize-9.0: {:?}", e1, e2);
122+
}
123+
}
124+
}
125+
};
118126
println!("!self-profile-output:{}", json);
119127
} else {
120128
let prefix = prefix.expect(&format!("found prefix {:?}", prof_out_dir));
@@ -349,7 +357,9 @@ fn run_summarize(name: &str, prof_out_dir: &Path, prefix: &str) -> anyhow::Resul
349357
cmd.current_dir(&prof_out_dir);
350358
cmd.arg("summarize").arg("--json");
351359
cmd.arg(&prefix);
352-
let status = cmd.status()?;
360+
let status = cmd
361+
.status()
362+
.with_context(|| format!("Command::new({}).status() failed", name))?;
353363
if !status.success() {
354364
anyhow::bail!(
355365
"failed to run {} in {:?} with prefix {:?}",
@@ -358,7 +368,10 @@ fn run_summarize(name: &str, prof_out_dir: &Path, prefix: &str) -> anyhow::Resul
358368
prefix
359369
)
360370
}
361-
let json = prof_out_dir.join(&format!("{}.json", prefix));
371+
let json = prof_out_dir.join(&format!(
372+
"{}.json",
373+
prefix.strip_suffix(".mm_profdata").unwrap_or(prefix)
374+
));
362375
fs::read_to_string(&json).with_context(|| format!("failed to read {:?}", json))
363376
}
364377

0 commit comments

Comments
 (0)