37 lines
964 B
Rust
37 lines
964 B
Rust
use std::path::Path;
|
|
|
|
use serde::Deserialize;
|
|
|
|
datatest_stable::harness! {
|
|
{
|
|
test = test_failures, root = "tests/logs", pattern = r".*.failure.log"
|
|
},
|
|
}
|
|
|
|
#[derive(Debug, Deserialize)]
|
|
struct FailureInfoHeader {
|
|
failed_derivations: Vec<String>,
|
|
}
|
|
|
|
fn test_failures(_path: &Path, content: String) -> datatest_stable::Result<()> {
|
|
let (header, content) = content.split_once("------").unwrap();
|
|
|
|
let header: FailureInfoHeader = serde_json::from_str(header).unwrap();
|
|
|
|
let build_state = nix_json::helpers::NixBuildState::from_log_lines(content)?;
|
|
|
|
assert!(build_state.is_failed());
|
|
|
|
for drv in header.failed_derivations {
|
|
let state = build_state
|
|
.get_derivation(&drv)
|
|
.unwrap_or_else(|| panic!("Expected {drv} to be present in build state"));
|
|
|
|
assert!(
|
|
state.is_failed(),
|
|
"derivation {drv} was found, but it was not marked as failed"
|
|
);
|
|
}
|
|
|
|
Ok(())
|
|
}
|