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

[PATCH 2/7] completion: fix args of run_completion() test helper

From
SZEDER Gábor <szeder@ira.uka.de>
Date
Nov 17, 2012, 11:05 UTC
Message-ID
<1353150353-29874-3-git-send-email-szeder@ira.uka.de>
In-Reply-To
<1353150353-29874-1-git-send-email-szeder@ira.uka.de>

To simulate that the user hit 'git <TAB>, the 'basic' test sets up the rather strange command line containing the two words

  git ""

i.e. the second word on the command line consists of two double quotes. This is not what happens for real, however, because after 'git <TAB>' the second word on the command line is just an empty string. Luckily, the test works nevertheless.

Fix this by passing the command line to run_completion() as separate words.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
---
 t/t9902-completion.sh | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index b56759f7..3af75872 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -49,7 +49,7 @@ run_completion ()
 {
 	local -a COMPREPLY _words
 	local _cword
-	_words=( $1 )
+	_words=( "$@" )
 	(( _cword = ${#_words[@]} - 1 ))
 	__git_wrap__git_main && print_comp
 }
@@ -57,7 +57,7 @@ run_completion ()
 test_completion ()
 {
 	test $# -gt 1 && echo "$2" > expected
-	run_completion "$@" &&
+	run_completion $1 &&
 	test_cmp expected out
 }
 
@@ -156,7 +156,7 @@ test_expect_success '__gitcomp - suffix' '
 '
 
 test_expect_success 'basic' '
-	run_completion "git \"\"" &&
+	run_completion git "" &&
 	# built-in
 	echo "add " >expected &&
 	sed -n "/^add \$/p" out >out2 &&
@@ -170,7 +170,7 @@ test_expect_success 'basic' '
 	sed -n "/^ls-files \$/p" out >out2 &&
 	test_cmp expected out2 &&
 
-	run_completion "git f" &&
+	run_completion git f &&
 	>expected &&
 	sed -n "/^[^f]/p" out >out2 &&
 	test_cmp expected out2
-- 
1.8.0.220.g4d14ece
Previous: Felipe ContrerasNext: Jonathan Nieder
Message 6 of 26 in “completion: fix expansion issues with compgen”
  1. 0/7 completion: fix expansion issues with compgenSZEDER Gábor, Nov 17, 2012
  2. 1/7 completion: make the 'basic' test more tester-friendlySZEDER Gábor, Nov 17, 2012
  3. Jonathan NiederNov 17, 2012
  4. Felipe ContrerasNov 18, 2012
  5. Felipe ContrerasNov 18, 2012
  6. 2/7 completion: fix args of run_completion() test helperSZEDER Gábor, Nov 17, 2012
  7. Jonathan NiederNov 17, 2012
  8. Felipe ContrerasNov 18, 2012
  9. 3/7 completion: add tests for the __gitcomp_nl() completion helper functionSZEDER Gábor, Nov 17, 2012
  10. Jonathan NiederNov 17, 2012
  11. Felipe ContrerasNov 18, 2012
  12. 4/7 completion: add tests for invalid variable name among completion wordsSZEDER Gábor, Nov 17, 2012
  13. Jonathan NiederNov 17, 2012
  14. Felipe ContrerasNov 18, 2012
  15. Felipe ContrerasNov 18, 2012
  16. 5/7 completion: fix expansion issues in __gitcomp_nl()SZEDER Gábor, Nov 17, 2012
  17. Felipe ContrerasNov 17, 2012
  18. SZEDER GáborNov 17, 2012
  19. Felipe ContrerasNov 17, 2012
  20. Felipe ContrerasNov 17, 2012
  21. Felipe ContrerasNov 18, 2012
  22. Felipe ContrerasNov 18, 2012
  23. 6/7 completion: fix expansion issue in __gitcomp()SZEDER Gábor, Nov 17, 2012
  24. Felipe ContrerasNov 17, 2012
  25. SZEDER GáborNov 17, 2012
  26. 7/7 completion: remove the now unused __gitcomp_1() internal helper functionSZEDER Gábor, Nov 17, 2012

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.