diff options
author | Théophane Hufschmitt <7226587+thufschmitt@users.noreply.github.com> | 2022-01-24 13:02:51 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-24 13:02:51 +0100 |
commit | 45305743634e11053b5b9428b7b1d09df2d47856 (patch) | |
tree | dc978678ff91ddb930180551b014bfa6f68c4b80 /tests | |
parent | edf0cde1a7f733d473e68ba5be996f07e86ab08d (diff) | |
parent | ffb28eaa1e15f85d3fbf6bfc3a04a4010f9c80c9 (diff) |
Merge pull request #5945 from afishhh/master
Make `nix search` highlight all regexes and matches
Diffstat (limited to 'tests')
-rw-r--r-- | tests/search.sh | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/search.sh b/tests/search.sh index ee3261687..52e12f381 100644 --- a/tests/search.sh +++ b/tests/search.sh @@ -23,3 +23,16 @@ clearCache nix search -f search.nix '' |grep -q foo nix search -f search.nix '' |grep -q bar nix search -f search.nix '' |grep -q hello + +## Tests for multiple regex/match highlighting + +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 )) + +# 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 )) +# Searching for 'b' should yield the 'b' in bar and the two 'b's in 'broken bar' +(( $(nix search -f search.nix '' 'b' | grep -Eo "$e\[32;1mb$e\[(0|0;1)m" | wc -l) == 3 )) |