forked from lix-project/lix
Use grep -c
instead of grep|wc -l
in some nix search
tests
This commit is contained in:
parent
0338cf5539
commit
9ae22b1fde
|
@ -28,13 +28,14 @@ nix search -f search.nix '' |grep -q hello
|
||||||
|
|
||||||
e=$'\x1b' # grep doesn't support \e, \033 or even \x1b
|
e=$'\x1b' # grep doesn't support \e, \033 or even \x1b
|
||||||
# Multiple overlapping regexes
|
# 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 '' 'oo' 'foo' 'oo' | grep -c "$e\[32;1mfoo$e\\[0;1m") == 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 '' 'broken b' 'en bar' | grep -c "$e\[32;1mbroken bar$e\\[0m") == 1 ))
|
||||||
|
|
||||||
# Multiple matches
|
# Multiple matches
|
||||||
# Searching for 'o' should yield the 'o' in 'broken bar', the 'oo' in foo and 'o' in hello
|
# 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'
|
# 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 ))
|
(( $(nix search -f search.nix '' 'b' | grep -Eo "$e\[32;1mb$e\[(0|0;1)m" | wc -l) == 3 ))
|
||||||
|
|
||||||
## Tests for --exclude
|
## Tests for --exclude
|
||||||
|
|
Loading…
Reference in a new issue