Changeset 782 for git/branches/dmik/t/t1502-rev-parse-parseopt.sh
- Timestamp:
- Jun 23, 2014, 9:45:51 PM (11 years ago)
- Location:
- git/branches/dmik
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
git/branches/dmik ¶
- Property svn:mergeinfo changed
/git/vendor/2.0.0 (added) merged: 777 /git/vendor/current merged: 772,774,776
- Property svn:mergeinfo changed
-
TabularUnified git/branches/dmik/t/t1502-rev-parse-parseopt.sh ¶
r347 r782 4 4 . ./test-lib.sh 5 5 6 cat > expect <<\END_EXPECT 7 cat <<\EOF 8 usage: some-command [options] <args>... 9 10 some-command does foo and bar! 11 12 -h, --help show the help 13 --foo some nifty option --foo 14 --bar ... some cool option --bar with an argument 15 16 An option group Header 17 -C[...] option C with an optional argument 18 19 Extras 20 --extra1 line above used to cause a segfault but no longer does 21 22 EOF 6 sed -e 's/^|//' >expect <<\END_EXPECT 7 |cat <<\EOF 8 |usage: some-command [options] <args>... 9 | 10 | some-command does foo and bar! 11 | 12 | -h, --help show the help 13 | --foo some nifty option --foo 14 | --bar ... some cool option --bar with an argument 15 | -b, --baz a short and long option 16 | 17 |An option group Header 18 | -C[...] option C with an optional argument 19 | -d, --data[=...] short and long option with an optional argument 20 | 21 |Argument hints 22 | -b <arg> short option required argument 23 | --bar2 <arg> long option required argument 24 | -e, --fuz <with-space> 25 | short and long option required argument 26 | -s[<some>] short option optional argument 27 | --long[=<data>] long option optional argument 28 | -g, --fluf[=<path>] short and long option optional argument 29 | --longest <very-long-argument-hint> 30 | a very long argument hint 31 | 32 |Extras 33 | --extra1 line above used to cause a segfault but no longer does 34 | 35 |EOF 23 36 END_EXPECT 24 37 25 cat > optionspec << EOF 26 some-command [options] <args>... 27 28 some-command does foo and bar! 29 -- 30 h,help show the help 31 32 foo some nifty option --foo 33 bar= some cool option --bar with an argument 34 35 An option group Header 36 C? option C with an optional argument 37 38 Extras 39 extra1 line above used to cause a segfault but no longer does 38 sed -e 's/^|//' >optionspec <<\EOF 39 |some-command [options] <args>... 40 | 41 |some-command does foo and bar! 42 |-- 43 |h,help show the help 44 | 45 |foo some nifty option --foo 46 |bar= some cool option --bar with an argument 47 |b,baz a short and long option 48 | 49 | An option group Header 50 |C? option C with an optional argument 51 |d,data? short and long option with an optional argument 52 | 53 | Argument hints 54 |b=arg short option required argument 55 |bar2=arg long option required argument 56 |e,fuz=with-space short and long option required argument 57 |s?some short option optional argument 58 |long?data long option optional argument 59 |g,fluf?path short and long option optional argument 60 |longest=very-long-argument-hint a very long argument hint 61 | 62 |Extras 63 |extra1 line above used to cause a segfault but no longer does 40 64 EOF 41 65 42 66 test_expect_success 'test --parseopt help output' ' 43 67 test_expect_code 129 git rev-parse --parseopt -- -h > output < optionspec && 44 test_ cmp expect output68 test_i18ncmp expect output 45 69 ' 46 70 47 71 cat > expect <<EOF 48 set -- --foo --bar 'ham' - - 'arg'72 set -- --foo --bar 'ham' -b -- 'arg' 49 73 EOF 50 74 51 75 test_expect_success 'test --parseopt' ' 52 git rev-parse --parseopt -- --foo --bar=ham arg < optionspec > output &&76 git rev-parse --parseopt -- --foo --bar=ham --baz arg < optionspec > output && 53 77 test_cmp expect output 54 78 ' 55 79 56 80 test_expect_success 'test --parseopt with mixed options and arguments' ' 57 git rev-parse --parseopt -- --foo arg --bar=ham < optionspec > output &&81 git rev-parse --parseopt -- --foo arg --bar=ham --baz < optionspec > output && 58 82 test_cmp expect output 59 83 ' … … 100 124 ' 101 125 126 cat > expect <<EOF 127 set -- --foo --bar='z' --baz -C'Z' --data='A' -- 'arg' 128 EOF 129 130 test_expect_success 'test --parseopt --stuck-long' ' 131 git rev-parse --parseopt --stuck-long -- --foo --bar=z -b arg -CZ -dA <optionspec >output && 132 test_cmp expect output 133 ' 134 135 cat > expect <<EOF 136 set -- --data='' -C --baz -- 'arg' 137 EOF 138 139 test_expect_success 'test --parseopt --stuck-long and empty optional argument' ' 140 git rev-parse --parseopt --stuck-long -- --data= arg -C -b <optionspec >output && 141 test_cmp expect output 142 ' 143 144 cat > expect <<EOF 145 set -- --data --baz -- 'arg' 146 EOF 147 148 test_expect_success 'test --parseopt --stuck-long and long option with unset optional argument' ' 149 git rev-parse --parseopt --stuck-long -- --data arg -b <optionspec >output && 150 test_cmp expect output 151 ' 152 153 test_expect_success 'test --parseopt --stuck-long and short option with unset optional argument' ' 154 git rev-parse --parseopt --stuck-long -- -d arg -b <optionspec >output && 155 test_cmp expect output 156 ' 157 102 158 test_done
Note:
See TracChangeset
for help on using the changeset viewer.