Skip to content

Commit ddf07bd

Browse files
Felipe Contrerasgitster
authored andcommitted
completion: add file completion tests
The commit fea16b4 (git-completion.bash: add support for path completion) introduced quite a few changes, without the usual tests. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent b75cdfa commit ddf07bd

1 file changed

Lines changed: 68 additions & 0 deletions

File tree

t/t9902-completion.sh

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,4 +347,72 @@ test_expect_success 'send-email' '
347347
test_completion "git send-email ma" "master "
348348
'
349349

350+
test_expect_success 'complete files' '
351+
git init tmp && cd tmp &&
352+
test_when_finished "cd .. && rm -rf tmp" &&
353+
354+
echo "expected" > .gitignore &&
355+
echo "out" >> .gitignore &&
356+
357+
git add .gitignore &&
358+
test_completion "git commit " ".gitignore" &&
359+
360+
git commit -m ignore &&
361+
362+
touch new &&
363+
test_completion "git add " "new" &&
364+
365+
git add new &&
366+
git commit -a -m new &&
367+
test_completion "git add " "" &&
368+
369+
git mv new modified &&
370+
echo modify > modified &&
371+
test_completion "git add " "modified" &&
372+
373+
touch untracked &&
374+
375+
: TODO .gitignore should not be here &&
376+
test_completion "git rm " <<-\EOF &&
377+
.gitignore
378+
modified
379+
EOF
380+
381+
test_completion "git clean " "untracked" &&
382+
383+
: TODO .gitignore should not be here &&
384+
test_completion "git mv " <<-\EOF &&
385+
.gitignore
386+
modified
387+
EOF
388+
389+
mkdir dir &&
390+
touch dir/file-in-dir &&
391+
git add dir/file-in-dir &&
392+
git commit -m dir &&
393+
394+
mkdir untracked-dir &&
395+
396+
: TODO .gitignore should not be here &&
397+
test_completion "git mv modified " <<-\EOF &&
398+
.gitignore
399+
dir
400+
modified
401+
untracked
402+
untracked-dir
403+
EOF
404+
405+
test_completion "git commit " "modified" &&
406+
407+
: TODO .gitignore should not be here &&
408+
test_completion "git ls-files " <<-\EOF
409+
.gitignore
410+
dir
411+
modified
412+
EOF
413+
414+
touch momified &&
415+
test_completion "git add mom" "momified"
416+
'
417+
350418
test_done

0 commit comments

Comments
 (0)