git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/2] more tests for git rev-parse --parse-opt

From
Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Date
Jun 13, 2009, 23:58 UTC
Message-ID
<1244937523-6194-1-git-send-email-u.kleine-koenig@pengutronix.de>
In-Reply-To
<20090610141614.GA20299@pengutronix.de>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 t/t1502-rev-parse-parseopt.sh |   38 ++++++++++++++++++++++++++++++++++++--
 1 files changed, 36 insertions(+), 2 deletions(-)
diff --git a/t/t1502-rev-parse-parseopt.sh b/t/t1502-rev-parse-parseopt.sh
index 997002d..be0959e 100755
--- a/t/t1502-rev-parse-parseopt.sh
+++ b/t/t1502-rev-parse-parseopt.sh
@@ -20,8 +20,7 @@ Extras
 
 EOF
 
-test_expect_success 'test --parseopt help output' '
-	git rev-parse --parseopt -- -h 2> output.err <<EOF
+cat > optionspec << EOF
 some-command [options] <args>...
 
 some-command does foo and bar!
@@ -37,7 +36,42 @@ C?        option C with an optional argument
 Extras
 extra1    line above used to cause a segfault but no longer does
 EOF
+
+test_expect_success 'test --parseopt help output' '
+	git rev-parse --parseopt -- -h 2> output.err < optionspec
 	test_cmp expect.err output.err
 '
 
+cat > expect <<EOF
+set -- --foo --bar 'ham' -- 'arg'
+EOF
+
+test_expect_success 'test --parseopt' '
+	git rev-parse --parseopt -- --foo --bar=ham arg < optionspec > output &&
+	test_cmp expect output
+'
+
+test_expect_success 'test --parseopt with mixed options and arguments' '
+	git rev-parse --parseopt -- --foo arg --bar=ham < optionspec > output &&
+	test_cmp expect output
+'
+
+cat > expect <<EOF
+set -- --foo -- 'arg' '--bar=ham'
+EOF
+
+test_expect_success 'test --parseopt with --' '
+	git rev-parse --parseopt -- --foo -- arg --bar=ham < optionspec > output &&
+	test_cmp expect output
+'
+
+cat > expect <<EOF
+set -- --foo -- '--' 'arg' '--bar=ham'
+EOF
+
+test_expect_success 'test --parseopt --keep-dashdash' '
+	git rev-parse --parseopt --keep-dashdash -- --foo -- arg --bar=ham < optionspec > output &&
+	test_cmp expect output
+'
+
 test_done
-- 
1.6.3.1
Previous: Uwe Kleine-KönigNext: Uwe Kleine-König
Message 9 of 10 in “notice: pu broken tonight”
  1. Junio C HamanoJun 9, 2009
  2. René ScharfeJun 9, 2009
  3. Uwe Kleine-KönigJun 10, 2009
  4. Junio C HamanoJun 10, 2009
  5. 1/2 more tests for git rev-parse --parse-optUwe Kleine-König, Jun 10, 2009
  6. 2/2 parse-opt: make PARSE_OPT_STOP_AT_NON_OPTION available to git rev-parseUwe Kleine-König, Jun 10, 2009
  7. Johannes SixtJun 10, 2009
  8. Uwe Kleine-KönigJun 10, 2009
  9. 1/2 more tests for git rev-parse --parse-optUwe Kleine-König, Jun 13, 2009
  10. 2/2 parse-opt: make PARSE_OPT_STOP_AT_NON_OPTION available to git rev-parseUwe Kleine-König, Jun 13, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.