2018-01-21 | Paul Boddie | raw files shortlog changelog graph | Added a helper function to count and test occurrences of a string in output. | client-editing-simplification |
tests/common.sh (file) |
1.1 --- a/tests/common.sh Sat Jan 20 18:59:40 2018 +0100 1.2 +++ b/tests/common.sh Sun Jan 21 02:04:24 2018 +0100 1.3 @@ -56,6 +56,15 @@ 1.4 echo "Success" 1.5 } 1.6 1.7 +have_occurrences() { 1.8 + # <string> <number> [ <filename> ] 1.9 + if [ "$3" ]; then 1.10 + [ `grep "$1" "$3" | wc -l` = "$2" ] 1.11 + else 1.12 + [ `grep "$1" | wc -l` = "$2" ] 1.13 + fi 1.14 +} 1.15 + 1.16 is_absent() { 1.17 # <string> [ <filename> ] 1.18 if [ "$2" ]; then