From 4c74d679b6b4db9eccea94afc285176871253967 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Mon, 23 Dec 2024 16:55:27 +0100 Subject: [PATCH] test: Avoid regressing accidental use of weakly_canonical instead of makeParentCanonical I'd messed up a rebase in my previous iteration, causing `weakly_canonical` to reappear, but not trigger a test failure. These two functions behave similarly when the argument is a path that points to a broken symlink. `weakly_canonical` would not resolve it because the target doesn't exist, and `makeParentCanonical` would not resolve it, because it never resolves the final path element. This new test case now also tests a valid symlink, "differentiating" the two. --- tests/functional/hash-path.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/functional/hash-path.sh b/tests/functional/hash-path.sh index 74e319504..4894ae391 100755 --- a/tests/functional/hash-path.sh +++ b/tests/functional/hash-path.sh @@ -116,3 +116,8 @@ h=$(nix hash path --type sha256 --base32 "$TEST_ROOT/try/to/mess/with/it/simple- ln -s /non-existent-48cujwe8ndf4as0bne "$TEST_ROOT/symlink-to-nowhere" h=$(nix hash path --mode nar --type sha256 --base32 "$TEST_ROOT/symlink-to-nowhere") [[ 1bl5ry3x1fcbwgr5c2x50bn572iixh4j1p6ax5isxly2ddgn8pbp == "$h" ]] # manually verified hash +if [[ -e /bin ]]; then + ln -s /bin "$TEST_ROOT/symlink-to-bin" + h=$(nix hash path --mode nar --type sha256 --base32 "$TEST_ROOT/symlink-to-bin") + [[ 0z2mdmkd43l0ijdxfbj1y8vzli15yh9b09n3a3rrygmjshbyypsw == "$h" ]] # manually verified hash +fi