[PATCH 06/12] tests: add more bash completion tests
These tests try to excercise code that deals with 'words' and 'cword'.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
t/t9902-completion.sh | 55 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 55 insertions(+)
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index ee5654d..f1b660f 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -62,6 +62,22 @@ test_completion ()
test_cmp expected out
}
+setup_repository ()
+{
+ mkdir "$1" && (
+ cd "$1" &&
+ git init &&
+ test_tick &&
+ git commit --allow-empty -m "Initial"
+ )
+}
+
+test_expect_success 'prepare' '
+ setup_repository one &&
+ git clone one test &&
+ cd test
+'
+
test_expect_success 'basic' '
cat >expected <<-\EOF &&
help
@@ -229,4 +245,43 @@ test_expect_success 'general options plus command' '
test_completion "git --no-replace-objects check" "checkout "
'
+test_expect_success 'remote or refspec' '
+ test_completion "git fetch o" "origin " &&
+ test_completion "git fetch origin m" "master:master " &&
+ test_completion "git pull o" "origin " &&
+ test_completion "git pull origin m" "master " &&
+ test_completion "git push o" "origin " &&
+ test_completion "git push origin m" "master "
+'
+
+test_expect_success 'subcomands' '
+ test_completion "git bisect st" "start "
+'
+
+test_expect_success 'has double dash' '
+ test_completion "git add -- foo" ""
+'
+
+test_expect_success 'config' '
+ git config --file=foo color.ui auto &&
+ test_completion "git config --file=foo --get c" "color.ui "
+'
+
+test_expect_success 'other' '
+ cat >expected <<-\EOF &&
+ origin/HEAD
+ origin/master
+ EOF
+ test_completion "git branch -r o" &&
+ test_completion "git bundle cr" "create " &&
+
+ echo foobar > tags &&
+ test_completion "git grep f" "foobar " &&
+
+ test_completion "git notes --ref m" "master " &&
+
+ git tag v0.1 &&
+ test_completion "git tag -d v" "v0.1 "
+'
+
test_done
--
1.7.10.3.g5a738d