diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2022-06-07 19:01:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-07 19:01:36 +0200 |
commit | b2dea231cf61d8d10cef89991571f57976b77f06 (patch) | |
tree | b3cb47145e5aa2ac858966f3468b099a35833059 /tests | |
parent | 8977cdee6aac8ef3238b28543199572150929bab (diff) | |
parent | 9ae22b1fdeaf6cc7541a66d981ecf7b6038739cc (diff) |
Merge pull request #6618 from afishhh/search-exclude
Add `-e`/`--exclude` flag to `nix search`
Diffstat (limited to 'tests')
-rw-r--r-- | tests/search.sh | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/tests/search.sh b/tests/search.sh index 52e12f381..41b706ac6 100644 --- a/tests/search.sh +++ b/tests/search.sh @@ -28,11 +28,18 @@ nix search -f search.nix '' |grep -q hello e=$'\x1b' # grep doesn't support \e, \033 or even \x1b # Multiple overlapping regexes -(( $(nix search -f search.nix '' 'oo' 'foo' 'oo' | grep "$e\[32;1mfoo$e\\[0;1m" | wc -l) == 1 )) -(( $(nix search -f search.nix '' 'broken b' 'en bar' | grep "$e\[32;1mbroken bar$e\\[0m" | wc -l) == 1 )) +(( $(nix search -f search.nix '' 'oo' 'foo' 'oo' | grep -c "$e\[32;1mfoo$e\\[0;1m") == 1 )) +(( $(nix search -f search.nix '' 'broken b' 'en bar' | grep -c "$e\[32;1mbroken bar$e\\[0m") == 1 )) # Multiple matches # Searching for 'o' should yield the 'o' in 'broken bar', the 'oo' in foo and 'o' in hello -(( $(nix search -f search.nix '' 'o' | grep -Eo "$e\[32;1mo{1,2}$e\[(0|0;1)m" | wc -l) == 3 )) +(( $(nix search -f search.nix '' 'o' | grep -Eoc "$e\[32;1mo{1,2}$e\[(0|0;1)m") == 3 )) # Searching for 'b' should yield the 'b' in bar and the two 'b's in 'broken bar' +# NOTE: This does not work with `grep -c` because it counts the two 'b's in 'broken bar' as one matched line (( $(nix search -f search.nix '' 'b' | grep -Eo "$e\[32;1mb$e\[(0|0;1)m" | wc -l) == 3 )) + +## Tests for --exclude +(( $(nix search -f search.nix -e hello | grep -c hello) == 0 )) + +(( $(nix search -f search.nix foo --exclude 'foo|bar' | grep -Ec 'foo|bar') == 0 )) +(( $(nix search -f search.nix foo -e foo --exclude bar | grep -Ec 'foo|bar') == 0 )) |