fix(nix-compat/src/derivation/validate): remove break

If the output was fixed, we broke out of the for loop too early, before
actually validating individual outputs.

Change-Id: I2259697dfa2a157764358f6d326a1f7f6610647c
Reviewed-on: https://cl.tvl.fyi/c/depot/+/9815
Tested-by: BuildkiteCI
Reviewed-by: raitobezarius <tvl@lahfa.xyz>
This commit is contained in:
Florian Klink 2023-10-21 18:50:47 +01:00 committed by flokli
parent 34fc4637eb
commit 6fe7684832

View file

@ -43,8 +43,6 @@ impl Derivation {
output_name.to_string(),
));
}
break;
}
if let Err(e) = output.validate(validate_output_paths) {
@ -127,3 +125,34 @@ impl Derivation {
Ok(())
}
}
#[cfg(test)]
mod test {
use std::collections::BTreeMap;
use crate::derivation::{CAHash, Derivation, Output};
/// Regression test: produce a Derivation that's almost valid, except its
/// fixed-output output has the wrong hash specified.
#[test]
fn output_validate() {
let mut outputs = BTreeMap::new();
outputs.insert(
"out".to_string(),
Output {
path: "".to_string(),
ca_hash: Some(CAHash::Text(Box::new([0; 32]))), // This is disallowed
},
);
let drv = Derivation {
arguments: vec![],
builder: "/bin/sh".to_string(),
outputs,
system: "x86_64-linux".to_string(),
..Default::default()
};
drv.validate(false).expect_err("must fail");
}
}