diff options
author | Junio C Hamano <gitster@pobox.com> | 2016-05-23 14:54:32 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-05-23 14:54:32 -0700 |
commit | 2997ea960f7da94d74742ed41006f0afdb2164e7 (patch) | |
tree | e63adff736a593686e3a67192fddfe727821967d /t/t0040-parse-options.sh | |
parent | 5d5f1c236b63596a59293a893d914dab1c8dd377 (diff) | |
parent | 8ca65aebad55790d675f1eaead2dfc15fae60847 (diff) | |
download | git-2997ea960f7da94d74742ed41006f0afdb2164e7.tar.gz |
Merge branch 'jc/test-parse-options-expect'
t0040 had too many unnecessary repetitions in its test data. Teach
test-parse-options program so that a caller can tell what it
expects in its output, so that these repetitions can be cleaned up.
* jc/test-parse-options-expect:
t0040: convert a few tests to use test-parse-options --expect
t0040: remove unused test helpers
test-parse-options: --expect=<string> option to simplify tests
test-parse-options: fix output when callback option fails
Diffstat (limited to 't/t0040-parse-options.sh')
-rwxr-xr-x | t/t0040-parse-options.sh | 49 |
1 files changed, 4 insertions, 45 deletions
diff --git a/t/t0040-parse-options.sh b/t/t0040-parse-options.sh index fec3fef9a1..db5f60d0c5 100755 --- a/t/t0040-parse-options.sh +++ b/t/t0040-parse-options.sh @@ -45,6 +45,7 @@ Standard options -v, --verbose be verbose -n, --dry-run dry run -q, --quiet be quiet + --expect <string> expected output in the variable dump EOF @@ -56,52 +57,12 @@ test_expect_success 'test help' ' mv expect expect.err -cat >expect.template <<\EOF -boolean: 0 -integer: 0 -magnitude: 0 -timestamp: 0 -string: (not set) -abbrev: 7 -verbose: -1 -quiet: 0 -dry run: no -file: (not set) -EOF - -check() { +check () { what="$1" && shift && expect="$1" && shift && - sed "s/^$what .*/$what $expect/" <expect.template >expect && - test-parse-options $* >output 2>output.err && - test_must_be_empty output.err && - test_cmp expect output -} - -check_i18n() { - what="$1" && - shift && - expect="$1" && - shift && - sed "s/^$what .*/$what $expect/" <expect.template >expect && - test-parse-options $* >output 2>output.err && - test_must_be_empty output.err && - test_i18ncmp expect output -} - -check_unknown() { - case "$1" in - --*) - echo error: unknown option \`${1#--}\' >expect ;; - -*) - echo error: unknown switch \`${1#-}\' >expect ;; - esac && - cat expect.err >>expect && - test_must_fail test-parse-options $* >output 2>output.err && - test_must_be_empty output && - test_cmp expect output.err + test-parse-options --expect="$what $expect" "$@" } check_unknown_i18n() { @@ -356,9 +317,7 @@ test_expect_success 'OPT_CALLBACK() and OPT_BIT() work' ' test_cmp expect output ' -cat >expect <<\EOF -Callback: "not set", 1 -EOF +>expect test_expect_success 'OPT_CALLBACK() and callback errors work' ' test_must_fail test-parse-options --no-length >output 2>output.err && |