diff options
| author | Silvan Mosberger <contact@infinisil.com> | 2023-11-14 07:42:59 +0100 |
|---|---|---|
| committer | Silvan Mosberger <silvan.mosberger@tweag.io> | 2023-11-15 01:20:36 +0100 |
| commit | 1c3eb9eff1b864bf49c3661558b495235fc3b3b4 (patch) | |
| tree | 8d72c4ef51a603588ec1c9dab6fde4a323369872 /lib/fileset/tests.sh | |
| parent | terraform-providers.baiducloud: 1.19.19 -> 1.19.20 (diff) | |
| download | nixpkgs-1c3eb9eff1b864bf49c3661558b495235fc3b3b4.tar.gz | |
lib.fileset.fileFilter: Restrict second argument to paths
While this change is backwards-incompatible, I think it's okay because:
- The `fileFilter` function is not yet in a stable NixOS release, it was only merged about [a month ago](https://github.com/NixOS/nixpkgs/pull/257356).
- All public uses of the function on GitHub only pass a path
- Any `fileFilter pred fileset` can also be expressed as `intersection fileset (fileFilter pred path)` without loss of functionality.
- This is furthermore pointed out in the new error message when a file set is passed
Diffstat (limited to 'lib/fileset/tests.sh')
| -rwxr-xr-x | lib/fileset/tests.sh | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/lib/fileset/tests.sh b/lib/fileset/tests.sh index 5ef155d25a88..ebf9b6c37bf2 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 |
