(write: bool)
| 5458 | } |
| 5459 | |
| 5460 | fn check_or_write_asset_input_fingerprint(write: bool) -> Result<()> { |
| 5461 | let fingerprint = asset_input_fingerprint()?; |
| 5462 | let path = Path::new(ASSET_INPUT_FINGERPRINT_PATH); |
| 5463 | if write { |
| 5464 | if let Some(parent) = path.parent() { |
| 5465 | fs::create_dir_all(parent).with_context(|| format!("create {}", parent.display()))?; |
| 5466 | } |
| 5467 | fs::write(path, format!("{fingerprint}\n")) |
| 5468 | .with_context(|| format!("write {}", path.display()))?; |
| 5469 | println!("wrote {}", path.display()); |
| 5470 | return Ok(()); |
| 5471 | } |
| 5472 | |
| 5473 | let expected = fs::read_to_string(path).with_context(|| { |
| 5474 | format!( |
| 5475 | "read {}; run `cargo run -p xtask -- assets input-fingerprint --write` after refreshing assets", |
| 5476 | path.display() |
| 5477 | ) |
| 5478 | })?; |
| 5479 | ensure_eq( |
| 5480 | fingerprint.as_str(), |
| 5481 | expected.trim(), |
| 5482 | "committed asset input fingerprint", |
| 5483 | ) |
| 5484 | } |
| 5485 | |
| 5486 | fn asset_input_fingerprint() -> Result<String> { |
| 5487 | let tracked = command_output( |
no test coverage detected