Skip to content

Commit 824af25

Browse files
Uwe Kleine-Königgitster
authored andcommitted
more tests for git rev-parse --parse-opt
Signed-off-by: Uwe Kleine-König <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b836490 commit 824af25

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

t/t1502-rev-parse-parseopt.sh

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ Extras
2020
2121
EOF
2222

23-
test_expect_success 'test --parseopt help output' '
24-
git rev-parse --parseopt -- -h 2> output.err <<EOF
23+
cat > optionspec << EOF
2524
some-command [options] <args>...
2625
2726
some-command does foo and bar!
@@ -37,7 +36,42 @@ C? option C with an optional argument
3736
Extras
3837
extra1 line above used to cause a segfault but no longer does
3938
EOF
39+
40+
test_expect_success 'test --parseopt help output' '
41+
git rev-parse --parseopt -- -h 2> output.err < optionspec
4042
test_cmp expect.err output.err
4143
'
4244

45+
cat > expect <<EOF
46+
set -- --foo --bar 'ham' -- 'arg'
47+
EOF
48+
49+
test_expect_success 'test --parseopt' '
50+
git rev-parse --parseopt -- --foo --bar=ham arg < optionspec > output &&
51+
test_cmp expect output
52+
'
53+
54+
test_expect_success 'test --parseopt with mixed options and arguments' '
55+
git rev-parse --parseopt -- --foo arg --bar=ham < optionspec > output &&
56+
test_cmp expect output
57+
'
58+
59+
cat > expect <<EOF
60+
set -- --foo -- 'arg' '--bar=ham'
61+
EOF
62+
63+
test_expect_success 'test --parseopt with --' '
64+
git rev-parse --parseopt -- --foo -- arg --bar=ham < optionspec > output &&
65+
test_cmp expect output
66+
'
67+
68+
cat > expect <<EOF
69+
set -- --foo -- '--' 'arg' '--bar=ham'
70+
EOF
71+
72+
test_expect_success 'test --parseopt --keep-dashdash' '
73+
git rev-parse --parseopt --keep-dashdash -- --foo -- arg --bar=ham < optionspec > output &&
74+
test_cmp expect output
75+
'
76+
4377
test_done

0 commit comments

Comments
 (0)