[PATCH v7 01/49] test: completion add test for __git_cmd_idx

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When __git_func_wrap was fixed to set correctly __git_cmd_idx in
cea232194d (completion: bash: fix late declaration of __git_cmd_idx,
2021-06-18) no test was added, therefore we could hit the same bug in
the future.

To ensure that doesn't happen add a test which adds an alias for 'git
add' with __git_complete, and then pretend the user typed this alias.

To make sure __git_cmd_idx is correct we add the --update option to
ensure the result of __git_find_on_cmdline (which uses __git_cmd_idx) is
correct. When __git_cmd_idx isn't correct __git_find_on_cmdline fails,
and therefore the --update option isn't interpreted correctly.

Signed-off-by: Felipe Contreras <felipe.contreras@xxxxxxxxx>
---
 t/t9902-completion.sh | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index d6c0478d98..561f06b46a 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -2689,4 +2689,13 @@ test_expect_success '__git_complete' '
 	test_must_fail __git_complete ga missing
 '
 
+test_expect_success '__git_complete has correct __git_cmd_idx' '
+	__git_complete ga _git_add &&
+	echo modified > file1 &&
+	touch file3 &&
+	_words=(ga --update f) _cword=2 &&
+	__git_wrap_git_add &&
+	test "${COMPREPLY[*]}" = "file1"
+'
+
 test_done
-- 
2.33.0




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux