From a7bf5b975f3980677458c8cc5302393343d05fda Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Tue, 11 Jun 2024 16:47:09 +0300 Subject: [PATCH] test(tvix/glue/fetchurl): add output path tests for fetchurl These are all derived from the FOD representation of the ATerm serialization, so no new code necessary to calculate these hashes correctly. Change-Id: I8c5dacd2a8de3d5042c9dd56910511c19e1b9b31 Reviewed-on: https://cl.tvl.fyi/c/depot/+/11788 Reviewed-by: Connor Brewster Autosubmit: flokli Tested-by: BuildkiteCI --- .../tests/tvix_tests/eval-okay-fetchurl.exp | 2 +- .../tests/tvix_tests/eval-okay-fetchurl.nix | 40 +++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/tvix/glue/src/tests/tvix_tests/eval-okay-fetchurl.exp b/tvix/glue/src/tests/tvix_tests/eval-okay-fetchurl.exp index 37a04d577..50d8e3574 100644 --- a/tvix/glue/src/tests/tvix_tests/eval-okay-fetchurl.exp +++ b/tvix/glue/src/tests/tvix_tests/eval-okay-fetchurl.exp @@ -1 +1 @@ -[ /nix/store/y0r1p1cqmlvm0yqkz3gxvkc1p8kg2sz8-null /nix/store/06qi00hylriyfm0nl827crgjvbax84mz-notmuch-extract-patch /nix/store/06qi00hylriyfm0nl827crgjvbax84mz-notmuch-extract-patch /nix/store/06qi00hylriyfm0nl827crgjvbax84mz-notmuch-extract-patch ] +[ /nix/store/y0r1p1cqmlvm0yqkz3gxvkc1p8kg2sz8-null /nix/store/06qi00hylriyfm0nl827crgjvbax84mz-notmuch-extract-patch /nix/store/06qi00hylriyfm0nl827crgjvbax84mz-notmuch-extract-patch /nix/store/06qi00hylriyfm0nl827crgjvbax84mz-notmuch-extract-patch "/nix/store/06qi00hylriyfm0nl827crgjvbax84mz-notmuch-extract-patch" "/nix/store/b40vjphshq4fdgv8s3yrp0bdlafi4920-0r8nqa1klm5v17ifc6z96m9wywxkjvgbnqq9pmy0sgqj53wj3n12.nar.xz" "/nix/store/8kx7fdkdbzs4fkfb57xq0cbhs20ymq2n-0r8nqa1klm5v17ifc6z96m9wywxkjvgbnqq9pmy0sgqj53wj3n12.nar.xz" "/nix/store/y92hm2xfk1009hrq0ix80j4m5k4j4w21-0r8nqa1klm5v17ifc6z96m9wywxkjvgbnqq9pmy0sgqj53wj3n12.nar.xz" ] diff --git a/tvix/glue/src/tests/tvix_tests/eval-okay-fetchurl.nix b/tvix/glue/src/tests/tvix_tests/eval-okay-fetchurl.nix index 8a3910152..a3e9c5486 100644 --- a/tvix/glue/src/tests/tvix_tests/eval-okay-fetchurl.nix +++ b/tvix/glue/src/tests/tvix_tests/eval-okay-fetchurl.nix @@ -22,4 +22,44 @@ name = "notmuch-extract-patch"; sha256 = "sha256-Xa1Jbl2Eq5+L0ww+Ph1osA3Z/Dxe/RkN1/dITQCdXFk="; }) + + # The following tests use . + # This is a piece of Nix code producing a "fake derivation" which gets + # handled by a "custom builder" that does the actual fetching. + # We access `.outPath` here, as the current string output of a Derivation + # still differs from the way nix presents it. + # It behaves similar to builtins.fetchurl, except it requires a hash to be + # provided upfront. + # If `unpack` is set to true, it can unpack NAR files (decompressing if + # necessary) + # If `executable` is set to true, it will place the fetched file at the root, + # but make it executable, and the hash is on the NAR representation. + + # Fetch a URL. + (import { + url = "https://test.example/owo"; + name = "notmuch-extract-patch"; + sha256 = "Xa1Jbl2Eq5+L0ww+Ph1osA3Z/Dxe/RkN1/dITQCdXFk="; + }).outPath + + # Fetch a NAR and unpack it, specifying the sha256 of its NAR representation. + (import { + url = "https://cache.nixos.org/nar/0r8nqa1klm5v17ifc6z96m9wywxkjvgbnqq9pmy0sgqj53wj3n12.nar.xz"; + sha256 = "sha256-oj6yfWKbcEerK8D9GdPJtIAOveNcsH1ztGeSARGypRA="; + unpack = true; + }).outPath + + # Fetch a NAR and unpack it, specifying its *sha1* of its NAR representation. + (import { + url = "https://cache.nixos.org/nar/0r8nqa1klm5v17ifc6z96m9wywxkjvgbnqq9pmy0sgqj53wj3n12.nar.xz"; + hash = "sha1-F/fMsgwkXF8fPCg1v9zPZ4yOFIA="; + unpack = true; + }).outPath + + # Fetch a URL, specifying the *sha1* of a NAR describing it as executable at the root. + (import { + url = "https://cache.nixos.org/nar/0r8nqa1klm5v17ifc6z96m9wywxkjvgbnqq9pmy0sgqj53wj3n12.nar.xz"; + hash = "sha1-NKNeU1csW5YJ4lCeWH3Z/apppNU="; + executable = true; + }).outPath ]