@matheusbsbs / matheus-bagliano / commits / 824af25ace
Fork 0

more tests for git rev-parse --parse-opt

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Uwe Kleine-König committed Jun 14, 2009 at 01:58 UTC 824af25ace464177820fc69c19fc03ae4fc9e4b1
1 file changed +36 -2
t/t1502-rev-parse-parseopt.sh
+36 -2
@@ -20,8 +20,7 @@ Extras
20
21 EOF
22
23 -test_expect_success 'test --parseopt help output' '
24 - git rev-parse --parseopt -- -h 2> output.err <<EOF
23 +cat > optionspec << EOF
24 some-command [options] <args>...
25
26 some-command does foo and bar!
@@ -37,7 +36,42 @@ C? option C with an optional argument
36 Extras
37 extra1 line above used to cause a segfault but no longer does
38 EOF
39 +
40 +test_expect_success 'test --parseopt help output' '
41 + git rev-parse --parseopt -- -h 2> output.err < optionspec
42 test_cmp expect.err output.err
43 '
44
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 +
77 test_done