about summary refs log tree commit diff
path: root/lib/fileset/tests.sh
diff options
context:
space:
mode:
authorVladimír Čunát <v@cunat.cz>2023-11-15 07:33:10 +0100
committerVladimír Čunát <v@cunat.cz>2023-11-15 07:33:10 +0100
commitc46eae0f3572fbe7af42e5d40648b7b4a1d1317b (patch)
tree84e748e6477734c4826b4d6b34152b1958e5627a /lib/fileset/tests.sh
parent9297b620bb86624e6cf4b6ae54fc4ae1da98bb83 (diff)
parente8ad54f562b4621c7c080b4a3ddbafe4735bcb86 (diff)
downloadnixlib-c46eae0f3572fbe7af42e5d40648b7b4a1d1317b.tar
nixlib-c46eae0f3572fbe7af42e5d40648b7b4a1d1317b.tar.gz
nixlib-c46eae0f3572fbe7af42e5d40648b7b4a1d1317b.tar.bz2
nixlib-c46eae0f3572fbe7af42e5d40648b7b4a1d1317b.tar.lz
nixlib-c46eae0f3572fbe7af42e5d40648b7b4a1d1317b.tar.xz
nixlib-c46eae0f3572fbe7af42e5d40648b7b4a1d1317b.tar.zst
nixlib-c46eae0f3572fbe7af42e5d40648b7b4a1d1317b.zip
Merge branch 'master' into staging-next
Diffstat (limited to 'lib/fileset/tests.sh')
-rwxr-xr-xlib/fileset/tests.sh27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/fileset/tests.sh b/lib/fileset/tests.sh
index 796a03b52f0e..5ef155d25a88 100755
--- a/lib/fileset/tests.sh
+++ b/lib/fileset/tests.sh
@@ -810,6 +810,13 @@ checkFileset 'difference ./. ./b'
 
 ## File filter
 
+# The first argument needs to be a function
+expectFailure 'fileFilter null (abort "this is not needed")' 'lib.fileset.fileFilter: First argument is of type null, but it should be a function instead.'
+
+# The second argument can be a file set or an existing path
+expectFailure 'fileFilter (file: abort "this is not needed") null' 'lib.fileset.fileFilter: Second argument is of type null, but it should be a file set or a path instead.'
+expectFailure 'fileFilter (file: abort "this is not needed") ./a' 'lib.fileset.fileFilter: Second argument \('"$work"'/a\) is a path that does not exist.'
+
 # The predicate is not called when there's no files
 tree=()
 checkFileset 'fileFilter (file: abort "this is not needed") ./.'
@@ -875,6 +882,26 @@ checkFileset 'union ./c/a (fileFilter (file: assert file.name != "a"; true) ./.)
 # but here we need to use ./c
 checkFileset 'union (fileFilter (file: assert file.name != "a"; true) ./.) ./c'
 
+# Also lazy, the filter isn't called on a filtered out path
+tree=(
+    [a]=1
+    [b]=0
+    [c]=0
+)
+checkFileset 'fileFilter (file: assert file.name != "c"; file.name == "a") (difference ./. ./c)'
+
+# Make sure single files are filtered correctly
+tree=(
+    [a]=1
+    [b]=0
+)
+checkFileset 'fileFilter (file: assert file.name == "a"; true) ./a'
+tree=(
+    [a]=0
+    [b]=0
+)
+checkFileset 'fileFilter (file: assert file.name == "a"; false) ./a'
+
 ## Tracing
 
 # The second trace argument is returned