Writes one JSON artifact and ensures its parent directory exists.
(path: &Path, value: &T, artifact: &str)
| 641 | |
| 642 | /// Writes one JSON artifact and ensures its parent directory exists. |
| 643 | pub fn write_json<T: Serialize>(path: &Path, value: &T, artifact: &str) -> Result<()> { |
| 644 | let parent = path.parent().ok_or_else(|| { |
| 645 | eyre::eyre!("{artifact} path has no parent directory: {}", path.display()) |
| 646 | })?; |
| 647 | fs::create_dir_all(parent).wrap_err_with(|| { |
| 648 | format!("failed to create {artifact} directory {}", parent.display()) |
| 649 | })?; |
| 650 | fs::write(path, serde_json::to_vec_pretty(value)?) |
| 651 | .wrap_err_with(|| format!("failed to write {artifact} {}", path.display())) |
| 652 | } |
| 653 | |
| 654 | /// Returns whether a workload needs Base Beryl enabled in its empty devnet. |
| 655 | pub fn requires_beryl(test_config: &TestConfig) -> bool { |