diff options
| author | David Bremner <david@tethera.net> | 2022-01-20 07:48:35 -0400 |
|---|---|---|
| committer | David Bremner <david@tethera.net> | 2022-01-26 07:22:09 -0400 |
| commit | b559240bb1cbc3d0b18589bd3e5aa996ac84382d (patch) | |
| tree | 276b48b92304d19335ec2d156de635e703ee70ec /test | |
| parent | c8d292e25b9e571c0ab5274cc20e23b4f0e979d1 (diff) | |
test: define test_expect_equal_message_body
This is a relatively simple sed invocation, but rather than write a
comment everywhere, give it a descriptive name.
Diffstat (limited to 'test')
| -rw-r--r-- | test/test-lib.sh | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/test-lib.sh b/test/test-lib.sh index f1275b85..af017ec2 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -432,6 +432,20 @@ test_expect_equal_file () { test_diff_file_ "$1" "$2" } +# Like test_expect_equal_file, but compare the part of the two files after the first blank line +test_expect_equal_message_body () { + exec 1>&6 2>&7 # Restore stdout and stderr + if [ -z "$inside_subtest" ]; then + error "bug in the test script: test_expect_equal_file without test_begin_subtest" + fi + test "$#" = 2 || + error "bug in the test script: not 2 parameters to test_expect_equal_file" + + expected=$(sed '1,/^$/d' "$1") + output=$(sed '1,/^$/d' "$2") + test_expect_equal "$expected" "$output" +} + # Like test_expect_equal, but takes two filenames. Fails if either is empty test_expect_equal_file_nonempty () { exec 1>&6 2>&7 # Restore stdout and stderr |
