From add254658af2e2904af0ee644a1b44b89f6c973a Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Wed, 1 Nov 2023 18:56:03 +0100 Subject: [PATCH] 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. --- lib/tests/filesystem.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/tests/filesystem.sh b/lib/tests/filesystem.sh index cfd333d0001b..7e7e03bc667d 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"