| 50 | Ok(()) |
| 51 | } |
| 52 | fn record(report: &mut Value, name: &str, value: Value) { |
| 53 | report.as_object_mut().unwrap().insert(name.into(), value); |
| 54 | if let Some(root) = report["root"].as_str() { |
| 55 | // Preserve completed observations if a later stage fails. |
| 56 | let _ = serde_json::to_vec_pretty(report).and_then(|bytes| { |
| 57 | fs::write(Path::new(root).join("report.json"), bytes).map_err(serde_json::Error::io) |
| 58 | }); |
| 59 | } |
| 60 | } |
| 61 | fn run(binary: &Path, root: &Path) -> Result<Value> { |
| 62 | let config = root.join("isolated-config"); |
| 63 | fs::create_dir_all(&config)?; |