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>
Felipe Contreras committed
Apr 27, 2013 at 15:09 UTC
ddf07bddef9aac37cf54ef744452f2a9ad4e312e
1 file changed
+68
t/t9902-completion.sh
+68
@@ -347,4 +347,72 @@ test_expect_success 'send-email' '
347
test_completion "git send-email ma" "master "
348
'
349
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
+
418
test_done