test-parse-options: --expect=<string> option to simplify tests
commitab6b28b02f4db52ab5bad342592399f2559b4d81
authorJunio C Hamano <gitster@pobox.com>
Thu, 5 May 2016 21:36:55 +0000 (5 14:36 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 10 May 2016 19:57:48 +0000 (10 12:57 -0700)
tree1fe44b709db0eef9590f63b0de7af6ac257ff71e
parentaccac4199c1d28dfd6c860b32d7111c3de8df7a6
test-parse-options: --expect=<string> option to simplify tests

Existing tests in t0040 follow a rather verbose pattern:

        cat >expect <<\EOF
        boolean: 0
        integer: 0
        magnitude: 0
        timestamp: 0
        string: (not set)
        abbrev: 7
        verbose: 0
        quiet: 3
        dry run: no
        file: (not set)
        EOF

        test_expect_success 'multiple quiet levels' '
                test-parse-options -q -q -q >output 2>output.err &&
                test_must_be_empty output.err &&
                test_cmp expect output
        '

But the only thing this test cares about is if "quiet: 3" is in the
output.  We should be able to write the above 18 lines with just
four lines, like this:

test_expect_success 'multiple quiet levels' '
test-parse-options --expect="quiet: 3" -q -q -q
'

Teach the new --expect=<string> option to test-parse-options helper.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t0040-parse-options.sh
test-parse-options.c