the_silver_searcher/tests/max_count.t
Adam Dinwoodie 1f2d79ebee Use printf in place of echo in tests
The behaviour of echo is inconsistent between implementations, in
particular regarding whether it expands escapes like `\n`.  Use printf
consistently in test scripts to avoid test failures from inconsistent
echo behaviour.

Fixes #866.
2016-03-15 03:42:19 +00:00

34 lines
913 B
Raku

Setup:
$ . $TESTDIR/setup.sh
$ printf "blah\n" > blah.txt
$ printf "blah2\n" >> blah.txt
$ printf "blah2\n" > blah2.txt
$ printf "blah2\n" >> blah2.txt
$ printf "blah2\n" >> blah2.txt
$ printf "blah2\n" >> blah2.txt
$ printf "blah2\n" >> blah2.txt
$ printf "blah2\n" >> blah2.txt
$ printf "blah2\n" >> blah2.txt
$ printf "blah2\n" >> blah2.txt
$ printf "blah2\n" >> blah2.txt
$ printf "blah2\n" >> blah2.txt # 10 lines
Max match of 1:
$ ag --max-count 1 blah blah.txt
ERR: Too many matches in blah.txt. Skipping the rest of this file.
1:blah
Max match of 10, one file:
$ ag --count --max-count 10 blah blah2.txt
ERR: Too many matches in blah2.txt. Skipping the rest of this file.
10
Max match of 10, multiple files:
$ ag --count --max-count 10 blah blah.txt blah2.txt
ERR: Too many matches in blah2.txt. Skipping the rest of this file.
blah.txt:2
blah2.txt:10