3 # Copyright (c) 2007 Johannes Schindelin
6 test_description='our own option parser'
10 cat > expect.err << EOF
11 usage: test-parse-options <options>
13 -b, --boolean get a boolean
14 -i, --integer <n> get a integer
15 -j <n> get a integer, too
20 --string2 <str> get another string
21 --st <st> get another string (pervert ordering)
25 test_expect_success 'test help' '
26 ! test-parse-options -h > output 2> output.err &&
28 git diff expect.err output.err
37 test_expect_success 'short options' '
38 test-parse-options -s123 -b -i 1729 -b > output 2> output.err &&
39 git diff expect output &&
48 test_expect_success 'long options' '
49 test-parse-options --boolean --integer 1729 --boolean --string2=321 \
50 > output 2> output.err &&
51 test ! -s output.err &&
52 git diff expect output
64 test_expect_success 'intermingled arguments' '
65 test-parse-options a1 --string 123 b1 --boolean -j 13 -- --boolean \
66 > output 2> output.err &&
67 test ! -s output.err &&
68 git diff expect output
77 test_expect_success 'unambiguously abbreviated option' '
78 test-parse-options --int 2 --boolean --no-bo > output 2> output.err &&
79 test ! -s output.err &&
80 git diff expect output
83 test_expect_success 'unambiguously abbreviated option with "="' '
84 test-parse-options --int=2 > output 2> output.err &&
85 test ! -s output.err &&
86 git diff expect output
89 test_expect_failure 'ambiguously abbreviated option' '
90 test-parse-options --strin 123;
100 test_expect_success 'non ambiguous option (after two options it abbreviates)' '
101 test-parse-options --st 123 > output 2> output.err &&
102 test ! -s output.err &&
103 git diff expect output