From d8ac71ce95703c9dff55abba05850108cbc1707b Mon Sep 17 00:00:00 2001 From: Yueh-Shun Li Date: Thu, 18 Dec 2025 08:41:40 +0800 Subject: [PATCH] tests.fetchurl: add urls-mirrors --- pkgs/build-support/fetchurl/tests.nix | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pkgs/build-support/fetchurl/tests.nix b/pkgs/build-support/fetchurl/tests.nix index 0610aaf805a0..ab8a3acefe27 100644 --- a/pkgs/build-support/fetchurl/tests.nix +++ b/pkgs/build-support/fetchurl/tests.nix @@ -3,6 +3,7 @@ testers, fetchurl, writeShellScriptBin, + writeText, jq, moreutils, emptyFile, @@ -148,4 +149,23 @@ in ]; hash = hello.src.outputHash; }; + + urls-mirrors = testers.invalidateFetcherByDrvHash fetchurl rec { + name = "test-fetchurl-urls-simple"; + urls = [ + "http://broken" + ] + ++ hello.src.urls; + hash = hello.src.outputHash; + postFetch = hello.postFetch or "" + '' + if ! diff -u ${ + builtins.toFile "urls-resolved-by-eval" ( + lib.concatStringsSep "\n" (lib.concatMap fetchurl.resolveUrl urls) + "\n" + ) + } <(printf '%s\n' "''${resolvedUrls[@]}"); then + echo "ERROR: fetchurl: build-time-resolved URLs \`urls' differ from the evaluation-resolved URLs." >&2 + exit 1 + fi + ''; + }; }