Add parsing and finding the failed derivation
Signed-off-by: Marcel Müller <neikos@neikos.email>
This commit is contained in:
parent
a7986584d5
commit
85c6a8f169
9 changed files with 985 additions and 76 deletions
37
nix-json/tests/sample-logs.rs
Normal file
37
nix-json/tests/sample-logs.rs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
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(())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue