summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
authorSilvan Mosberger <silvan.mosberger@tweag.io>2023-11-01 18:56:03 +0100
committerSilvan Mosberger <silvan.mosberger@tweag.io>2023-11-01 18:56:03 +0100
commitadd254658af2e2904af0ee644a1b44b89f6c973a (patch)
tree1c53ee89ef432db28d63a1ad4df13a87c10216f1 /lib
parent6b6bb56d412fec32860dbd35310a622f84119f5f (diff)
lib.filesystem: Don't test Nix-specific error messages
In https://github.com/NixOS/nix/pull/9269 the error messages change
which would've broken this test.
Diffstat (limited to 'lib')
-rwxr-xr-xlib/tests/filesystem.sh10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/tests/filesystem.sh b/lib/tests/filesystem.sh
index cfd333d0001b8..7e7e03bc667d2 100755
--- a/lib/tests/filesystem.sh
+++ b/lib/tests/filesystem.sh
@@ -64,8 +64,14 @@ expectSuccess "pathType $PWD/directory" '"directory"'
 expectSuccess "pathType $PWD/regular" '"regular"'
 expectSuccess "pathType $PWD/symlink" '"symlink"'
 expectSuccess "pathType $PWD/fifo" '"unknown"'
-# Different errors depending on whether the builtins.readFilePath primop is available or not
-expectFailure "pathType $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)"
+
+# Only check error message when a Nixpkgs-specified error is thrown,
+# which is only the case when `readFileType` is not available
+# and the fallback implementation needs to be used.
+if [[ "$(nix-instantiate --eval --expr 'builtins ? readFileType')" == false ]]; then
+    expectFailure "pathType $PWD/non-existent" \
+        "error: evaluation aborted with the following error message: 'lib.filesystem.pathType: Path $PWD/non-existent does not exist.'"
+fi
 
 expectSuccess "pathIsDirectory /." "true"
 expectSuccess "pathIsDirectory $PWD/directory" "true"