|
1 | 1 | use std::env; |
| 2 | +use std::path::Path; |
2 | 3 | use std::process::Command; |
3 | 4 | use std::time::{Duration, Instant}; |
4 | 5 |
|
@@ -82,26 +83,9 @@ fn main() { |
82 | 83 | } |
83 | 84 | } |
84 | 85 | let prefix = prefix.expect(&format!("found prefix {:?}", prof_out_dir)); |
85 | | - // FIXME: it'd be great to have a less generic name for this; |
86 | | - // we should think about renaming the binary in measureme to measureme, such |
87 | | - // that the command is `measureme summarize ...`. |
88 | | - let mut cmd = Command::new("summarize"); |
89 | | - cmd.current_dir(&prof_out_dir); |
90 | | - cmd.arg("summarize").arg("--json"); |
91 | | - cmd.arg(&prefix); |
92 | | - let status = cmd.status().expect(&format!( |
93 | | - "summarize spawned successfully in {:?}", |
94 | | - prof_out_dir |
95 | | - )); |
96 | | - assert!( |
97 | | - status.success(), |
98 | | - "summarize failed in {:?}; prefix is {:?}", |
99 | | - prof_out_dir, |
100 | | - prefix |
101 | | - ); |
102 | | - let json = |
103 | | - std::fs::read_to_string(prof_out_dir.join(&format!("{}.json", prefix))) |
104 | | - .expect("able to read JSON output"); |
| 86 | + let json = run_summarize("summarize", &prof_out_dir, &prefix) |
| 87 | + .or_else(|_| run_summarize("summarize-0.7", &prof_out_dir, &prefix)) |
| 88 | + .expect("able to run summarize or summarize-0.7"); |
105 | 89 | println!("!self-profile-output:{}", json); |
106 | 90 | } |
107 | 91 | } |
@@ -282,6 +266,21 @@ fn print_time(dur: Duration) { |
282 | 266 | ); |
283 | 267 | } |
284 | 268 |
|
| 269 | +fn run_summarize(name: &str, prof_out_dir: &Path, prefix: &str) -> std::io::Result<String> { |
| 270 | + let mut cmd = Command::new(name); |
| 271 | + cmd.current_dir(&prof_out_dir); |
| 272 | + cmd.arg("summarize").arg("--json"); |
| 273 | + cmd.arg(&prefix); |
| 274 | + let status = cmd.status()?; |
| 275 | + if !status.success() { |
| 276 | + return Err(std::io::Error::new( |
| 277 | + std::io::ErrorKind::Other, |
| 278 | + "Failed to run successfully", |
| 279 | + )); |
| 280 | + } |
| 281 | + std::fs::read_to_string(prof_out_dir.join(&format!("{}.json", prefix))) |
| 282 | +} |
| 283 | + |
285 | 284 | #[cfg(windows)] |
286 | 285 | fn raise_priority() {} |
287 | 286 |
|
|
0 commit comments