diff options
author | Junio C Hamano <gitster@pobox.com> | 2012-10-01 12:59:10 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2012-10-01 12:59:11 -0700 |
commit | abc05cbcd3fdc6e5e14daec80c00b6f51b8e4c7e (patch) | |
tree | b8099e57eb56b5c66c2250711266cb80d774c48c /t | |
parent | Merge branch 'ep/malloc-check-perturb' (diff) | |
parent | t9902: add completion tests for "odd" filenames (diff) | |
download | tgif-abc05cbcd3fdc6e5e14daec80c00b6f51b8e4c7e.tar.xz |
Merge branch 'jk/completion-tests'
* jk/completion-tests:
t9902: add completion tests for "odd" filenames
t9902: add a few basic completion tests
Diffstat (limited to 't')
-rwxr-xr-x | t/t9902-completion.sh | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh index 92d7eb47c2..cbd0fb66f9 100755 --- a/t/t9902-completion.sh +++ b/t/t9902-completion.sh @@ -61,6 +61,15 @@ test_completion () test_cmp expected out } +# Like test_completion, but reads expectation from stdin, +# which is convenient when it is multiline. We also process "_" into +# spaces to make test vectors more readable. +test_completion_long () +{ + tr _ " " >expected && + test_completion "$1" +} + newline=$'\n' test_expect_success '__gitcomp - trailing space - options' ' @@ -228,4 +237,55 @@ test_expect_success 'general options plus command' ' test_completion "git --no-replace-objects check" "checkout " ' +test_expect_success 'setup for ref completion' ' + echo content >file1 && + echo more >file2 && + git add . && + git commit -m one && + git branch mybranch && + git tag mytag +' + +test_expect_success 'checkout completes ref names' ' + test_completion_long "git checkout m" <<-\EOF + master_ + mybranch_ + mytag_ + EOF +' + +test_expect_success 'show completes all refs' ' + test_completion_long "git show m" <<-\EOF + master_ + mybranch_ + mytag_ + EOF +' + +test_expect_success '<ref>: completes paths' ' + test_completion_long "git show mytag:f" <<-\EOF + file1_ + file2_ + EOF +' + +test_expect_success 'complete tree filename with spaces' ' + echo content >"name with spaces" && + git add . && + git commit -m spaces && + test_completion_long "git show HEAD:nam" <<-\EOF + name with spaces_ + EOF +' + +test_expect_failure 'complete tree filename with metacharacters' ' + echo content >"name with \${meta}" && + git add . && + git commit -m meta && + test_completion_long "git show HEAD:nam" <<-\EOF + name with ${meta}_ + name with spaces_ + EOF +' + test_done |