git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC/PATCH] tests: add initial bash completion tests
@ 2012-04-06 19:28 Felipe Contreras
  2012-04-06 20:19 ` Jeff King
  0 siblings, 1 reply; 18+ messages in thread
From: Felipe Contreras @ 2012-04-06 19:28 UTC (permalink / raw)
  To: git; +Cc: Felipe Contreras

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---

Something is better than nothing.

 t/t9902-completion.sh |  198 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 198 insertions(+)
 create mode 100755 t/t9902-completion.sh

diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
new file mode 100755
index 0000000..a037dff
--- /dev/null
+++ b/t/t9902-completion.sh
@@ -0,0 +1,198 @@
+#!/bin/bash
+#
+# Copyright (c) 2012 Felipe Contreras
+#
+
+test_description='test bash completion'
+
+. ./test-lib.sh
+
+complete ()
+{
+	# do nothing
+	return 0
+}
+
+. "$GIT_BUILD_DIR/contrib/completion/git-completion.bash"
+
+print_comp ()
+{
+	local IFS=$'\n'
+	echo "${COMPREPLY[*]}" > out
+}
+
+print_words ()
+{
+	local w=(foo foo. --foo=bar)
+	local IFS=$'\n'
+	echo "${w[*]}"
+}
+
+_get_comp_words_by_ref ()
+{
+	while [ $# -gt 0 ]; do
+		case "$1" in
+		cur)
+			cur=${_words[_cword]}
+			;;
+		prev)
+			prev=${_words[_cword-1]}
+			;;
+		words)
+			words=("${_words[@]}")
+			;;
+		cword)
+			cword=$_cword
+			;;
+		esac
+		shift
+	done
+}
+
+test_completion ()
+{
+	local -a COMPREPLY _words
+	local _cword
+	_words=( $1 )
+	(( _cword = ${#_words[@]} - 1 ))
+	_git && print_comp &&
+	test_cmp expected out
+}
+
+test_expect_success 'git' '
+	cat >expected <<-\EOF &&
+	help 
+	add 
+	gc 
+	reflog 
+	get-tar-commit-id 
+	relink 
+	grep 
+	relink.perl 
+	am 
+	remote 
+	am.sh 
+	help 
+	annotate 
+	apply 
+	archimport.perl 
+	imap-send 
+	archive 
+	bisect 
+	init 
+	repack 
+	bisect.sh 
+	instaweb 
+	repack.sh 
+	blame 
+	instaweb.sh 
+	replace 
+	branch 
+	log 
+	bundle 
+	request-pull 
+	lost-found.sh 
+	request-pull.sh 
+	reset 
+	checkout 
+	cherry 
+	revert 
+	cherry-pick 
+	merge 
+	rm 
+	clean 
+	send-email 
+	clone 
+	send-email.perl 
+	commit 
+	config 
+	shortlog 
+	credential-cache 
+	show 
+	show-branch 
+	credential-store 
+	cvsexportcommit.perl 
+	stage 
+	stash 
+	cvsimport.perl 
+	stash.sh 
+	mergetool 
+	status 
+	cvsserver.perl 
+	mergetool.sh 
+	submodule 
+	describe 
+	submodule.sh 
+	diff 
+	mv 
+	svn 
+	name-rev 
+	svn.perl 
+	notes 
+	tag 
+	difftool 
+	difftool.perl 
+	fetch 
+	pull 
+	pull.sh 
+	filter-branch 
+	push 
+	filter-branch.sh 
+	quiltimport.sh 
+	format-patch 
+	rebase 
+	fsck 
+	rebase.sh 
+	whatchanged 
+	cccmd 
+	proxy 
+	send-pull 
+	EOF
+	test_completion "git" &&
+
+	cat >expected <<-\EOF &&
+	help 
+	help 
+	EOF
+	test_completion "git he"
+
+	cat >expected <<-\EOF &&
+	fetch 
+	filter-branch 
+	filter-branch.sh 
+	format-patch 
+	fsck 
+	EOF
+	test_completion "git f"
+'
+
+test_expect_success 'git (double dash)' '
+	cat >expected <<-\EOF &&
+	--paginate 
+	--no-pager 
+	--git-dir=
+	--bare 
+	--version 
+	--exec-path 
+	--html-path 
+	--work-tree=
+	--namespace=
+	--help 
+	EOF
+	test_completion "git --"
+
+	cat >expected <<-\EOF &&
+	--quiet 
+	--ours 
+	--theirs 
+	--track 
+	--no-track 
+	--merge 
+	--conflict=
+	--orphan 
+	--patch 
+	EOF
+	test_completion "git checkout --"
+'
+
+test_done
-- 
1.7.9.6

^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2012-04-07  0:02 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-06 19:28 [RFC/PATCH] tests: add initial bash completion tests Felipe Contreras
2012-04-06 20:19 ` Jeff King
2012-04-06 20:24   ` Junio C Hamano
2012-04-06 21:28     ` Felipe Contreras
2012-04-06 21:42       ` Jeff King
2012-04-06 22:22         ` Felipe Contreras
2012-04-06 21:42       ` Junio C Hamano
2012-04-06 21:21   ` Felipe Contreras
2012-04-06 21:34     ` Jeff King
2012-04-06 22:05       ` Felipe Contreras
2012-04-06 22:46         ` Junio C Hamano
2012-04-06 23:30           ` Felipe Contreras
2012-04-06 23:45         ` Jeff King
2012-04-06 23:12   ` Felipe Contreras
2012-04-06 23:22     ` Junio C Hamano
2012-04-06 23:33       ` Junio C Hamano
2012-04-07  0:02         ` Felipe Contreras
2012-04-06 23:52     ` Jeff King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).