From 8c78f328bf7a1a4b97f26e5f5bb25f2d8b462f24 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 12 Nov 2026 20:48:11 +0000 Subject: tests: check output, test rsync versions, close gaps in what's asserted Several checks would pass with the feature they cover broken, or cover it only by chance: - Phases can state what a succeeding populate prints. That covers the warnings of insecureLinks, the lines pruning prints, the one about a replaced symlink, and what rsync logs about each item. - The insecureLinks scenarios take their expectations from the version of rsync, so with an rsync older than 3.5.0 they pass without the check ever running. New tests, rsync-3-4-1 and rsync-3-5-0, run them with these versions, which tests/rsync.nix builds from their release tarballs, with ACLs and extended attributes, which backups use. - Pruning has a leftover upload to remove, and a source that stops having inputs to root leaves no empty directory of roots. - A full clone has every commit from the start, so the fetch for a commit it lacks never runs. A git scenario deploys a commit that appears on the server after cloning. - The jq test also runs the Nix function that finds a flake's subdirectory on the target, over both shapes of nix flake metadata's output. --- tests/jq.sh | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'tests/jq.sh') diff --git a/tests/jq.sh b/tests/jq.sh index a62d6cb..3794ce2 100755 --- a/tests/jq.sh +++ b/tests/jq.sh @@ -5,7 +5,7 @@ # usage: jq.sh DIR # # DIR contains the programs as selected.jq, selfIsRemote.jq, and -# selfLocked.jq. +# selfLocked.jq, and the Nix function for the target as metadataSubdir.nix. set -efu programs=$1 @@ -119,4 +119,31 @@ expect "locked reference of the flake itself" "$( --from-file "$programs"/selfLocked.jq )" "$mono" +# The Nix function finding the subdirectory on the target, which may lack +# jq. +# usage: metadata_subdir METADATA +metadata_subdir() { + METADATA=$1 nix-instantiate --eval --strict --json --store dummy:// --expr " + (import $programs/metadataSubdir.nix) + (builtins.fromJSON (builtins.getEnv \"METADATA\")) + " 2>&1 || : +} +export HOME=${TMPDIR:-/tmp} +export NIX_STATE_DIR=$HOME/nix-state +expect "subdirectory as attribute, on the target" "$(metadata_subdir '{ + "locked": { "type": "tarball", "url": "http://x/mono.tar.gz", "dir": "sub" }, + "original": { "type": "tarball", "url": "http://x/mono.tar.gz", "dir": "sub" } +}')" '"sub"' +expect "subdirectory in the URL, on the target" "$(metadata_subdir '{ + "locked": { "type": "tarball", "url": "http://x/mono.tar.gz?dir=sub&narHash=sha256-mono" }, + "original": { "type": "tarball", "url": "http://x/mono.tar.gz?dir=sub" } +}')" '"sub"' +expect "subdirectory in the original reference only, on the target" "$(metadata_subdir '{ + "locked": { "type": "tarball", "url": "http://x/mono.tar.gz" }, + "original": { "type": "tarball", "url": "http://x/mono.tar.gz?rev=1&dir=sub" } +}')" '"sub"' +expect "no subdirectory, on the target" "$(metadata_subdir '{ + "locked": { "type": "path", "path": "/src/top" } +}')" '""' + exit "$failed" -- cgit v1.3.1