diff options
| author | Silvan Mosberger <silvan.mosberger@tweag.io> | 2023-09-14 21:41:03 +0200 |
|---|---|---|
| committer | Silvan Mosberger <silvan.mosberger@tweag.io> | 2023-09-21 00:21:01 +0200 |
| commit | 7ab764e575135586cb8ac496702663a40a2bfa56 (patch) | |
| tree | 9cd36f6abb8f19314b4a7d32d6697cbd952986e2 /lib/fileset/tests.sh | |
| parent | lib.fileset: Optimise tests (diff) | |
| download | nixpkgs-7ab764e575135586cb8ac496702663a40a2bfa56.tar.gz | |
lib.fileset.unions: Don't stack overflow for many files
Diffstat (limited to 'lib/fileset/tests.sh')
| -rwxr-xr-x | lib/fileset/tests.sh | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/fileset/tests.sh b/lib/fileset/tests.sh index cee93615d56f..1a8f1372ebfa 100755 --- a/lib/fileset/tests.sh +++ b/lib/fileset/tests.sh @@ -457,6 +457,19 @@ checkFileset 'unions [ ./x/a ./x/b ./y/a ./z/b ]' checkFileset 'union (union ./x/a ./x/b) (union ./y/a ./z/b)' checkFileset 'union (union (union ./x/a ./x/b) ./y/a) ./z/b' +# unions should not stack overflow, even if many elements are passed +tree=() +for i in $(seq 1000); do + tree[$i/a]=1 + tree[$i/b]=0 +done +( + # Locally limit the maximum stack size to 100 * 1024 bytes + # If unions was implemented recursively, this would stack overflow + ulimit -s 100 + checkFileset 'unions (mapAttrsToList (name: _: ./. + "/${name}/a") (builtins.readDir ./.))' +) + # TODO: Once we have combinators and a property testing library, derive property tests from https://en.wikipedia.org/wiki/Algebra_of_sets echo >&2 tests ok |
