refactor(nix-compat/derivation): use ATerm for output_paths test
Due to the lack of a ATerm parser, we were previously loading the JSON fixtures to construct our Derivation structs to run the output path calculations with. However, as we now have a ATerm parser, we can load the ATerm representation directly. This also means we can test the output path calculation for non-UTF8 Derivations. Change-Id: I0e53f41a23566b5ad5f0fed12724e02a10b02707 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9731 Autosubmit: flokli <flokli@flokli.de> Tested-by: BuildkiteCI Reviewed-by: Connor Brewster <cbrewster@hey.com>
This commit is contained in:
parent
8934b34489
commit
398cf8e7ce
1 changed files with 12 additions and 4 deletions
|
@ -196,6 +196,9 @@ fn derivation_or_fod_hash(drv_path: &str, expected_nix_hash_string: &str) {
|
|||
assert_eq!(expected_nix_hash_string, actual.to_nix_hash_string());
|
||||
}
|
||||
|
||||
/// This reads a Derivation (in A-Term), trims out all fields containing
|
||||
/// calculated output paths, then triggers the output path calculation and
|
||||
/// compares the struct to match what was originally read in.
|
||||
#[test_case("bar","0hm2f1psjpcwg8fijsmr4wwxrx59s092-bar.drv"; "fixed_sha256")]
|
||||
#[test_case("foo", "4wvvbi4jwn0prsdxb7vs673qa5h9gr7x-foo.drv"; "simple-sha256")]
|
||||
#[test_case("bar", "ss2p4wmxijn652haqyd7dckxwl4c7hxx-bar.drv"; "fixed-sha1")]
|
||||
|
@ -203,12 +206,17 @@ fn derivation_or_fod_hash(drv_path: &str, expected_nix_hash_string: &str) {
|
|||
#[test_case("has-multi-out", "h32dahq0bx5rp1krcdx3a53asj21jvhk-has-multi-out.drv"; "multiple-outputs")]
|
||||
#[test_case("structured-attrs", "9lj1lkjm2ag622mh4h9rpy6j607an8g2-structured-attrs.drv"; "structured-attrs")]
|
||||
#[test_case("unicode", "52a9id8hx688hvlnz4d1n25ml1jdykz0-unicode.drv"; "unicode")]
|
||||
#[test_case("cp1252", "m1vfixn8iprlf0v9abmlrz7mjw1xj8kp-cp1252.drv"; "cp1252")]
|
||||
#[test_case("latin1", "x6p0hg79i3wg0kkv7699935f7rrj9jf3-latin1.drv"; "latin1")]
|
||||
fn output_paths(name: &str, drv_path: &str) {
|
||||
// read in the fixture
|
||||
let json_bytes = read_file(&format!("{}/ok/{}.json", RESOURCES_PATHS, drv_path));
|
||||
let expected_derivation: Derivation =
|
||||
serde_json::from_slice(&json_bytes).expect("must deserialize");
|
||||
// read in the derivation
|
||||
let expected_derivation = Derivation::from_aterm_bytes(
|
||||
read_file(&format!("{}/ok/{}", RESOURCES_PATHS, drv_path)).as_ref(),
|
||||
)
|
||||
.expect("must succeed");
|
||||
|
||||
// create a version with trimmed output paths, simulating we constructed
|
||||
// the struct.
|
||||
let mut derivation = derivation_with_trimmed_output_paths(&expected_derivation);
|
||||
|
||||
// calculate the derivation_or_fod_hash of derivation
|
||||
|
|
Loading…
Reference in a new issue