diff options
Diffstat (limited to 't/t0040-parse-options.sh')
-rwxr-xr-x | t/t0040-parse-options.sh | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/t/t0040-parse-options.sh b/t/t0040-parse-options.sh index 705a136ed9..ad4746d899 100755 --- a/t/t0040-parse-options.sh +++ b/t/t0040-parse-options.sh @@ -23,6 +23,8 @@ usage: test-tool parse-options <options> -j <n> get a integer, too -m, --magnitude <n> get a magnitude --set23 set integer to 23 + --mode1 set integer to 1 (cmdmode option) + --mode2 set integer to 2 (cmdmode option) -L, --length <str> get length of <str> -F, --file <file> set file to <file> @@ -42,7 +44,7 @@ Magic arguments --no-ambiguous negative ambiguity Standard options - --abbrev[=<n>] use <n> digits to display SHA-1s + --abbrev[=<n>] use <n> digits to display object names -v, --verbose be verbose -n, --dry-run dry run -q, --quiet be quiet @@ -52,14 +54,14 @@ Alias -A, --alias-source <string> get a string -Z, --alias-target <string> - get a string + alias of --alias-source EOF test_expect_success 'test help' ' test_must_fail test-tool parse-options -h >output 2>output.err && test_must_be_empty output.err && - test_i18ncmp expect output + test_cmp expect output ' mv expect expect.err @@ -82,7 +84,7 @@ check_unknown_i18n() { cat expect.err >>expect && test_must_fail test-tool parse-options $* >output 2>output.err && test_must_be_empty output && - test_i18ncmp expect output.err + test_cmp expect output.err } test_expect_success 'OPT_BOOL() #1' 'check boolean: 1 --yes' @@ -242,23 +244,23 @@ test_expect_success 'Alias options do not contribute to abbreviation' ' ' cat >typo.err <<\EOF -error: did you mean `--boolean` (with two dashes ?) +error: did you mean `--boolean` (with two dashes)? EOF test_expect_success 'detect possible typos' ' test_must_fail test-tool parse-options -boolean >output 2>output.err && test_must_be_empty output && - test_i18ncmp typo.err output.err + test_cmp typo.err output.err ' cat >typo.err <<\EOF -error: did you mean `--ambiguous` (with two dashes ?) +error: did you mean `--ambiguous` (with two dashes)? EOF test_expect_success 'detect possible typos' ' test_must_fail test-tool parse-options -ambiguous >output 2>output.err && test_must_be_empty output && - test_i18ncmp typo.err output.err + test_cmp typo.err output.err ' test_expect_success 'keep some options as arguments' ' @@ -324,6 +326,22 @@ test_expect_success 'OPT_NEGBIT() works' ' test-tool parse-options --expect="boolean: 6" -bb --no-neg-or4 ' +test_expect_success 'OPT_CMDMODE() works' ' + test-tool parse-options --expect="integer: 1" --mode1 +' + +test_expect_success 'OPT_CMDMODE() detects incompatibility' ' + test_must_fail test-tool parse-options --mode1 --mode2 >output 2>output.err && + test_must_be_empty output && + test_i18ngrep "incompatible with --mode" output.err +' + +test_expect_success 'OPT_CMDMODE() detects incompatibility with something else' ' + test_must_fail test-tool parse-options --set23 --mode2 >output 2>output.err && + test_must_be_empty output && + test_i18ngrep "incompatible with something else" output.err +' + test_expect_success 'OPT_COUNTUP() with PARSE_OPT_NODASH works' ' test-tool parse-options --expect="boolean: 6" + + + + + + ' |