diff src/testdir/test_help.vim @ 19289:2f0f308c069c v8.2.0203

patch 8.2.0203: :helptags and some other functionality not tested Commit: https://github.com/vim/vim/commit/e20b9ececa37a81c0340a78f61e57fa1bf46b06d Author: Bram Moolenaar <Bram@vim.org> Date: Mon Feb 3 21:40:04 2020 +0100 patch 8.2.0203: :helptags and some other functionality not tested Problem: :helptags and some other functionality not tested. Solution: Add more tests. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/5567)
author Bram Moolenaar <Bram@vim.org>
date Mon, 03 Feb 2020 21:45:03 +0100
parents 1b02482e6a61
children 7096af834c42
line wrap: on
line diff
--- a/src/testdir/test_help.vim
+++ b/src/testdir/test_help.vim
@@ -72,3 +72,41 @@ func Test_help_completion()
   call feedkeys(":help :undo\<C-A>\<C-B>\"\<CR>", 'tx')
   call assert_equal('"help :undo :undoj :undol :undojoin :undolist', @:)
 endfunc
+
+" Test for the :helptags command
+func Test_helptag_cmd()
+  call mkdir('Xdir/a/doc', 'p')
+
+  " No help file to process in the directory
+  call assert_fails('helptags Xdir', 'E151:')
+
+  call writefile([], 'Xdir/a/doc/sample.txt')
+
+  " Test for ++t argument
+  helptags ++t Xdir
+  call assert_equal(["help-tags\ttags\t1"], readfile('Xdir/tags'))
+  call delete('Xdir/tags')
+
+  " The following tests fail on FreeBSD for some reason
+  if has('unix') && !has('bsd')
+    " Read-only tags file
+    call writefile([''], 'Xdir/tags')
+    call setfperm('Xdir/tags', 'r-xr--r--')
+    call assert_fails('helptags Xdir', 'E152:', getfperm('Xdir/tags'))
+    call delete('Xdir/tags')
+
+    " No permission to read the help file
+    call setfperm('Xdir/a/doc/sample.txt', '-w-------')
+    call assert_fails('helptags Xdir', 'E153:', getfperm('Xdir/a/doc/sample.txt'))
+    call delete('Xdir/a/doc/sample.txt')
+    call delete('Xdir/tags')
+  endif
+
+  " Duplicate tags in the help file
+  call writefile(['*tag1*', '*tag1*', '*tag2*'], 'Xdir/a/doc/sample.txt')
+  call assert_fails('helptags Xdir', 'E154:')
+
+  call delete('Xdir', 'rf')
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab