parse-options tests: test optname() output
There were no tests for checking the specific output that we'll
generate in optname(), let's add some. That output was added back in
4a59fd1312
(Add a simple option parser., 2007-10-15).
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
28794ec72e
commit
62f2ffc563
@ -168,9 +168,45 @@ test_expect_success 'long options' '
|
||||
'
|
||||
|
||||
test_expect_success 'missing required value' '
|
||||
test_expect_code 129 test-tool parse-options -s &&
|
||||
test_expect_code 129 test-tool parse-options --string &&
|
||||
test_expect_code 129 test-tool parse-options --file
|
||||
cat >expect <<-\EOF &&
|
||||
error: switch `s'\'' requires a value
|
||||
EOF
|
||||
test_expect_code 129 test-tool parse-options -s 2>actual &&
|
||||
test_cmp expect actual &&
|
||||
|
||||
cat >expect <<-\EOF &&
|
||||
error: option `string'\'' requires a value
|
||||
EOF
|
||||
test_expect_code 129 test-tool parse-options --string 2>actual &&
|
||||
test_cmp expect actual &&
|
||||
|
||||
cat >expect <<-\EOF &&
|
||||
error: option `file'\'' requires a value
|
||||
EOF
|
||||
test_expect_code 129 test-tool parse-options --file 2>actual &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'superfluous value provided: boolean' '
|
||||
cat >expect <<-\EOF &&
|
||||
error: option `yes'\'' takes no value
|
||||
EOF
|
||||
test_expect_code 129 test-tool parse-options --yes=hi 2>actual &&
|
||||
test_cmp expect actual &&
|
||||
|
||||
cat >expect <<-\EOF &&
|
||||
error: option `no-yes'\'' takes no value
|
||||
EOF
|
||||
test_expect_code 129 test-tool parse-options --no-yes=hi 2>actual &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'superfluous value provided: cmdmode' '
|
||||
cat >expect <<-\EOF &&
|
||||
error: option `mode1'\'' takes no value
|
||||
EOF
|
||||
test_expect_code 129 test-tool parse-options --mode1=hi 2>actual &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
cat >expect <<\EOF
|
||||
|
Loading…
Reference in New Issue
Block a user