diff --git a/t/README b/t/README index 2aceb67c78..1a78982da1 100644 --- a/t/README +++ b/t/README @@ -500,6 +500,10 @@ library for your script to use. file. This behaves like "cmp" but produces more helpful output when the test is run with "-v" option. + - test_line_count (= | -lt | -ge | ...) + + Check whether a file has the length it is expected to. + - test_path_is_file [] test_path_is_dir [] test_path_is_missing [] diff --git a/t/test-lib.sh b/t/test-lib.sh index 87308f5a9b..a417bdfed1 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -598,6 +598,28 @@ test_path_is_missing () { fi } +# test_line_count checks that a file has the number of lines it +# ought to. For example: +# +# test_expect_success 'produce exactly one line of output' ' +# do something >output && +# test_line_count = 1 output +# ' +# +# is like "test $(wc -l