about summary refs log tree commit diff
path: root/lib/tests/filesystem.sh
diff options
context:
space:
mode:
authorSilvan Mosberger <silvan.mosberger@tweag.io>2023-05-25 22:39:28 +0200
committerSilvan Mosberger <silvan.mosberger@tweag.io>2023-05-25 22:39:28 +0200
commit04db3589a8150c0a97869b10e269d6d5c516f3e9 (patch)
treef254e0998ec272f8be94c9ab29c9ff8a8603ea58 /lib/tests/filesystem.sh
parent499cad7a722caf0bebb2a382a67fa39c992acebd (diff)
downloadnixlib-04db3589a8150c0a97869b10e269d6d5c516f3e9.tar
nixlib-04db3589a8150c0a97869b10e269d6d5c516f3e9.tar.gz
nixlib-04db3589a8150c0a97869b10e269d6d5c516f3e9.tar.bz2
nixlib-04db3589a8150c0a97869b10e269d6d5c516f3e9.tar.lz
nixlib-04db3589a8150c0a97869b10e269d6d5c516f3e9.tar.xz
nixlib-04db3589a8150c0a97869b10e269d6d5c516f3e9.tar.zst
nixlib-04db3589a8150c0a97869b10e269d6d5c516f3e9.zip
lib.filesystem.pathType: Fix tests for Nix >= 2.14
Diffstat (limited to 'lib/tests/filesystem.sh')
-rwxr-xr-xlib/tests/filesystem.sh5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/tests/filesystem.sh b/lib/tests/filesystem.sh
index 4a5ffeb12431..1e33174429b8 100755
--- a/lib/tests/filesystem.sh
+++ b/lib/tests/filesystem.sh
@@ -41,7 +41,7 @@ checkPathType() {
     local actualPathType=$(nix-instantiate --eval --strict --json 2>&1 \
         -E '{ path }: let lib = import <nixpkgs/lib>; in lib.filesystem.pathType path' \
         --argstr path "$path")
-    if [[ "$actualPathType" != "$expectedPathType" ]]; then
+    if [[ ! "$actualPathType" =~ $expectedPathType ]]; then
         die "lib.filesystem.pathType \"$path\" == $actualPathType, but $expectedPathType was expected"
     fi
 }
@@ -51,7 +51,8 @@ checkPathType "$PWD/directory" '"directory"'
 checkPathType "$PWD/regular" '"regular"'
 checkPathType "$PWD/symlink" '"symlink"'
 checkPathType "$PWD/fifo" '"unknown"'
-checkPathType "$PWD/non-existent" "error: evaluation aborted with the following error message: 'lib.filesystem.pathType: Path $PWD/non-existent does not exist.'"
+# Different errors depending on whether the builtins.readFilePath primop is available or not
+checkPathType "$PWD/non-existent" "error: (evaluation aborted with the following error message: 'lib.filesystem.pathType: Path $PWD/non-existent does not exist.'|getting status of '$PWD/non-existent': No such file or directory)"
 
 checkPathIsDirectory() {
     local path=$1