summaryrefslogtreecommitdiffstats
path: root/t/t0040-parse-options.sh
diff options
context:
space:
mode:
authorBrandon Casey <drafnel@gmail.com>2017-09-25 06:08:03 +0200
committerJunio C Hamano <gitster@pobox.com>2017-09-25 07:35:50 +0200
commitc97ee171a6b5a7e41234d46341b496146fa08bf1 (patch)
tree8a4817d7c870c98c622c23a90cfe8927d742ce5b /t/t0040-parse-options.sh
parentgit-rebase: don't ignore unexpected command line arguments (diff)
downloadgit-c97ee171a6b5a7e41234d46341b496146fa08bf1.tar.xz
git-c97ee171a6b5a7e41234d46341b496146fa08bf1.zip
t0040,t1502: Demonstrate parse_options bugs
When the option spec contains no switches or only hidden switches, parse_options will emit an extra blank line at the end of help output so that the help text will end in two blank lines instead of one. When parse_options produces internal help output after an error has occurred it will emit blank lines within the usage string to stdout instead of stderr. Update t/helper/test-parse-options.c to have a description body in the usage string to exercise this second bug and mark tests as failing in t0040. Add tests to t1502 to demonstrate both of these problems. Signed-off-by: Brandon Casey <drafnel@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t0040-parse-options.sh')
-rwxr-xr-xt/t0040-parse-options.sh8
1 files changed, 5 insertions, 3 deletions
diff --git a/t/t0040-parse-options.sh b/t/t0040-parse-options.sh
index 74d2cd76fe..a36434bd10 100755
--- a/t/t0040-parse-options.sh
+++ b/t/t0040-parse-options.sh
@@ -10,6 +10,8 @@ test_description='our own option parser'
cat >expect <<\EOF
usage: test-parse-options <options>
+ A helper function for the parse-options API.
+
--yes get a boolean
-D, --no-doubt begins with 'no-'
-B, --no-fear be brave
@@ -90,8 +92,8 @@ test_expect_success 'OPT_BOOL() is idempotent #2' 'check boolean: 1 -DB'
test_expect_success 'OPT_BOOL() negation #1' 'check boolean: 0 -D --no-yes'
test_expect_success 'OPT_BOOL() negation #2' 'check boolean: 0 -D --no-no-doubt'
-test_expect_success 'OPT_BOOL() no negation #1' 'check_unknown_i18n --fear'
-test_expect_success 'OPT_BOOL() no negation #2' 'check_unknown_i18n --no-no-fear'
+test_expect_failure 'OPT_BOOL() no negation #1' 'check_unknown_i18n --fear'
+test_expect_failure 'OPT_BOOL() no negation #2' 'check_unknown_i18n --no-no-fear'
test_expect_success 'OPT_BOOL() positivation' 'check boolean: 0 -D --doubt'
@@ -286,7 +288,7 @@ test_expect_success 'OPT_CALLBACK() and OPT_BIT() work' '
>expect
-test_expect_success 'OPT_CALLBACK() and callback errors work' '
+test_expect_failure 'OPT_CALLBACK() and callback errors work' '
test_must_fail test-parse-options --no-length >output 2>output.err &&
test_i18ncmp expect output &&
test_i18ncmp expect.err output.err