about summary refs log tree commit diff
path: root/lib/fileset/tests.sh
diff options
context:
space:
mode:
authorRobert Hensing <roberth@users.noreply.github.com>2023-11-16 00:34:04 +0100
committerGitHub <noreply@github.com>2023-11-16 00:34:04 +0100
commit060c4ad37757223b6dc38cdd2e1aadeb7ae42e73 (patch)
tree9bf9feb1d62196eac5e5e1e80a84030731eac841 /lib/fileset/tests.sh
parent4a46b20424232db6795600db5ceb683acf37e2ce (diff)
parent1c3eb9eff1b864bf49c3661558b495235fc3b3b4 (diff)
Merge pull request #267384 from tweag/fileset.fileFilter-path2
`fileset.fileFilter`: Restrict second argument to paths
Diffstat (limited to 'lib/fileset/tests.sh')
-rwxr-xr-xlib/fileset/tests.sh15
1 files changed, 4 insertions, 11 deletions
diff --git a/lib/fileset/tests.sh b/lib/fileset/tests.sh
index 5ef155d25a881..ebf9b6c37bf23 100755
--- a/lib/fileset/tests.sh
+++ b/lib/fileset/tests.sh
@@ -813,14 +813,15 @@ checkFileset 'difference ./. ./b'
 # 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.'
+# The second argument needs to be an existing path
+expectFailure 'fileFilter (file: abort "this is not needed") _emptyWithoutBase' 'lib.fileset.fileFilter: Second argument is a file set, but it should be a path instead.
+\s*If you need to filter files in a file set, use `intersection fileset \(fileFilter pred \./\.\)` instead.'
+expectFailure 'fileFilter (file: abort "this is not needed") null' 'lib.fileset.fileFilter: Second argument is of type null, but it should be 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") ./.'
-checkFileset 'fileFilter (file: abort "this is not needed") _emptyWithoutBase'
 
 # The predicate must be able to handle extra attributes
 touch a
@@ -882,14 +883,6 @@ 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