]> granicus.if.org Git - vim/commitdiff
patch 8.1.1203: some autocmd tests are old style v8.1.1203
authorBram Moolenaar <Bram@vim.org>
Thu, 25 Apr 2019 18:29:00 +0000 (20:29 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 25 Apr 2019 18:29:00 +0000 (20:29 +0200)
Problem:    Some autocmd tests are old style.
Solution:   Turn the tests into new style. (Yegappan Lakshmanan, closes #4295)

src/Makefile
src/testdir/Make_all.mak
src/testdir/Make_amiga.mak
src/testdir/Make_vms.mms
src/testdir/test11.in [deleted file]
src/testdir/test11.ok [deleted file]
src/testdir/test_autocmd.vim
src/version.c

index bdb89259557c9dffdf88238ff3cbca15e6449ea0..40f4b1b90d7211b4e03836db979763101fedb79f 100644 (file)
@@ -2172,7 +2172,7 @@ test_libvterm:
 # These do not depend on the executable, compile it when needed.
 test1 \
        test_eval \
-       test3 test11 test14 test17 \
+       test3 test14 test17 \
        test29 test30 test37 test39 \
        test42 test44 test48 test49 \
        test52 test59 \
index e5ef45dffdc38516a0862c8aa55299ab225e6051..276bbeec527a21b635f5741af3e6e8492b16fc44 100644 (file)
@@ -33,7 +33,6 @@ SCRIPTS_ALL = \
 
 # Tests that run on most systems, but not on Amiga.
 SCRIPTS_MORE1 = \
-       test11.out \
        test52.out \
        test86.out \
        test87.out
index b71b2204aa22904a95138e5b8caa487b78997257..a5855c3cb889ed3f2be205fad96e782a77cc29d9 100644 (file)
@@ -12,7 +12,6 @@ include Make_all.mak
 # These tests don't work (yet):
 # test2                "\\tmp" doesn't work
 # test10       'errorformat' is different
-# test11       "cat" doesn't work properly
 # test52       only for Win32
 # test86, 87   no Python interface
 
index a4c69362937b31b0cc8a9f0058e9a8fdd8b06dd9..4155923d5e4bd1e77d6498e8001a1b4eea1ac830 100644 (file)
@@ -122,10 +122,6 @@ SCRIPT_MZSCH = test70.out
 SCRIPT_ODS5 = test102.out
 .ENDIF
 
-.IFDEF HAVE_GZIP
-SCRIPT_GZIP = test11.out
-.ENDIF
-
 .IFDEF HAVE_GDIFF
 SCRIPT_GDIFF = test47.out
 .ENDIF
@@ -154,7 +150,7 @@ SCRIPT_PYTHON = test86.out test87.out
        -@ if "''F$SEARCH("Xdotest.*")'"  .NES. "" then delete/noconfirm/nolog Xdotest.*.*
        -@ if "''F$SEARCH("Xtest.*")'"    .NES. "" then delete/noconfirm/nolog Xtest.*.*
 
-all : clean nolog $(START_WITH) $(SCRIPT) $(SCRIPT_GUI) $(SCRIPT_UNIX) $(SCRIPT_WIN) $(SCRIPT_SPELL) $(SCRIPT_ODS5) $(SCRIPT_GZIP) \
+all : clean nolog $(START_WITH) $(SCRIPT) $(SCRIPT_GUI) $(SCRIPT_UNIX) $(SCRIPT_WIN) $(SCRIPT_SPELL) $(SCRIPT_ODS5) \
     $(SCRIPT_GDIFF) $(SCRIPT_MZSCH) $(SCRIPT_LUA) $(SCRIPT_PYTHON) nolog 
        -@ write sys$output " "
        -@ write sys$output "-----------------------------------------------"
diff --git a/src/testdir/test11.in b/src/testdir/test11.in
deleted file mode 100644 (file)
index 9e9e257..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-Tests for autocommands:
-- FileWritePre         writing a compressed file
-- FileReadPost         reading a compressed file
-- BufNewFile           reading a file template
-- BufReadPre           decompressing the file to be read
-- FilterReadPre                substituting characters in the temp file
-- FilterReadPost       substituting characters after filtering
-- FileReadPre          set options for decompression
-- FileReadPost         decompress the file
-
-Note: This test is skipped if "gzip" is not available.
-$GZIP is made empty, "-v" would cause trouble.
-Use a FileChangedShell autocommand to avoid a prompt for "Xtestfile.gz" being
-modified outside of Vim (noticed on Solaris).
-
-STARTTEST
-:so small.vim
-:" drop out when there is no gzip program
-:if !executable("gzip")
-: e! test.ok
-: w! test.out
-: qa!
-:endif
-:let $GZIP = ""
-:au FileChangedShell * echo "caught FileChangedShell"
-:set bin
-:au FileWritePre    *.gz   '[,']!gzip
-:au FileWritePost   *.gz   undo
-:/^start of testfile/,/^end of testfile/w! Xtestfile.gz
-:au FileReadPost    *.gz   '[,']!gzip -d
-:$r Xtestfile.gz                " Read and decompress the testfile
-:?startstart?,$w! test.out      " Write contents of this file
-:au BufNewFile      *.c    read Xtest.c
-:/^start of test.c/+1,/^end of test.c/-1w! Xtest.c
-:e! foo.c                       " Will load Xtest.c
-:au FileAppendPre   *.out  '[,']s/new/NEW/
-:au FileAppendPost  *.out  !cat Xtest.c >>test.out
-:w>>test.out                    " Append it to the output file
-:au! FileAppendPre
-:" setup autocommands to decompress before reading and re-compress afterwards
-:au BufReadPre      *.gz   exe '!gzip -d ' . shellescape(expand("<afile>"))
-:au BufReadPre      *.gz   call rename(expand("<afile>:r"), expand("<afile>"))
-:au BufReadPost     *.gz   call rename(expand("<afile>"), expand("<afile>:r"))
-:au BufReadPost     *.gz   exe '!gzip ' . shellescape(expand("<afile>:r"))
-:e! Xtestfile.gz                " Edit compressed file
-:w>>test.out                    " Append it to the output file
-:set shelltemp                  " need temp files here
-:au FilterReadPre   *.out  call rename(expand("<afile>"), expand("<afile>") . ".t")
-:au FilterReadPre   *.out  exe 'silent !sed s/e/E/ ' . shellescape(expand("<afile>")) . ".t >" . shellescape(expand("<afile>"))
-:au FilterReadPre   *.out  exe 'silent !rm ' . shellescape(expand("<afile>")) . '.t'
-:au FilterReadPost  *.out  '[,']s/x/X/g
-:e! test.out                    " Edit the output file
-:23,$!cat
-:23,$s/\r$//                 " remove CR for when sed adds them
-:au! FileReadPre    *.gz   exe 'silent !gzip -d ' . shellescape(expand("<afile>"))
-:au  FileReadPre    *.gz   call rename(expand("<afile>:r"), expand("<afile>"))
-:au! FileReadPost   *.gz   '[,']s/l/L/
-:$r Xtestfile.gz             " Read compressed file
-:w                           " write it, after filtering
-:au!             " remove all autocommands
-:e               " Edit test.out again
-:set nobin ff&   " use the default fileformat for writing
-:w
-:qa!
-ENDTEST
-
-startstart
-start of testfile
-line 2 Abcdefghijklmnopqrstuvwxyz
-line 3 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-line 4 Abcdefghijklmnopqrstuvwxyz
-line 5 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-line 6 Abcdefghijklmnopqrstuvwxyz
-line 7 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-line 8 Abcdefghijklmnopqrstuvwxyz
-line 9 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-line 10 Abcdefghijklmnopqrstuvwxyz
-end of testfile
-
-start of test.c
-/*
- * Here is a new .c file
- */
-end of test.c
diff --git a/src/testdir/test11.ok b/src/testdir/test11.ok
deleted file mode 100644 (file)
index af8c5ce..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-startstart
-start of testfile
-line 2 Abcdefghijklmnopqrstuvwxyz
-line 3 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-line 4 Abcdefghijklmnopqrstuvwxyz
-line 5 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-line 6 Abcdefghijklmnopqrstuvwxyz
-line 7 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-line 8 Abcdefghijklmnopqrstuvwxyz
-line 9 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-line 10 Abcdefghijklmnopqrstuvwxyz
-end of testfile
-
-start of test.c
-/*
- * Here is a new .c file
- */
-end of test.c
-start of testfile
-line 2 Abcdefghijklmnopqrstuvwxyz
-line 3 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-line 4 Abcdefghijklmnopqrstuvwxyz
-linE 5 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
-linE 6 AbcdefghijklmnopqrstuvwXyz
-linE 7 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
-linE 8 AbcdefghijklmnopqrstuvwXyz
-linE 9 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
-linE 10 AbcdefghijklmnopqrstuvwXyz
-End of testfile
-
-/*
- * HEre is a NEW .c file
- */
-/*
- * HEre is a new .c file
- */
-start of tEstfile
-linE 2 AbcdefghijklmnopqrstuvwXyz
-linE 3 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
-linE 4 AbcdefghijklmnopqrstuvwXyz
-linE 5 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
-linE 6 AbcdefghijklmnopqrstuvwXyz
-linE 7 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
-linE 8 AbcdefghijklmnopqrstuvwXyz
-linE 9 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
-linE 10 AbcdefghijklmnopqrstuvwXyz
-End of testfile
-/*
- * HEre is a new .c file
- */
-start of testfiLe
-Line 2 Abcdefghijklmnopqrstuvwxyz
-Line 3 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-Line 4 Abcdefghijklmnopqrstuvwxyz
-Line 5 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-Line 6 Abcdefghijklmnopqrstuvwxyz
-Line 7 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-Line 8 Abcdefghijklmnopqrstuvwxyz
-Line 9 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-Line 10 Abcdefghijklmnopqrstuvwxyz
-end of testfiLe
index b89af1849f2742a265eadefb5e05b6d68048ba78..8db06d08319cb3620f6249bed6395dfdbb4d70c3 100644 (file)
@@ -1486,3 +1486,205 @@ func Test_autocmd_once()
 endfunc
 
 " FileChangedShell tested in test_filechanged.vim
+
+" Tests for the following autocommands:
+" - FileWritePre       writing a compressed file
+" - FileReadPost       reading a compressed file
+" - BufNewFile         reading a file template
+" - BufReadPre         decompressing the file to be read
+" - FilterReadPre      substituting characters in the temp file
+" - FilterReadPost     substituting characters after filtering
+" - FileReadPre                set options for decompression
+" - FileReadPost       decompress the file
+func Test_ReadWrite_Autocmds()
+  " Run this test only on Unix-like systems and if gzip is available
+  if !has('unix') || !executable("gzip")
+    return
+  endif
+
+  " Make $GZIP empty, "-v" would cause trouble.
+  let $GZIP = ""
+
+  " Use a FileChangedShell autocommand to avoid a prompt for 'Xtestfile.gz'
+  " being modified outside of Vim (noticed on Solaris).
+  au FileChangedShell * echo 'caught FileChangedShell'
+
+  " Test for the FileReadPost, FileWritePre and FileWritePost autocmds
+  augroup Test1
+    au!
+    au FileWritePre    *.gz   '[,']!gzip
+    au FileWritePost   *.gz   undo
+    au FileReadPost    *.gz   '[,']!gzip -d
+  augroup END
+
+  new
+  set bin
+  call append(0, [
+             \ 'line 2 Abcdefghijklmnopqrstuvwxyz',
+             \ 'line 3 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
+             \ 'line 4 Abcdefghijklmnopqrstuvwxyz',
+             \ 'line 5 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
+             \ 'line 6 Abcdefghijklmnopqrstuvwxyz',
+             \ 'line 7 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
+             \ 'line 8 Abcdefghijklmnopqrstuvwxyz',
+             \ 'line 9 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
+             \ 'line 10 Abcdefghijklmnopqrstuvwxyz'
+             \ ])
+  1,9write! Xtestfile.gz
+  enew! | close
+
+  new
+  " Read and decompress the testfile
+  0read Xtestfile.gz
+  call assert_equal([
+             \ 'line 2 Abcdefghijklmnopqrstuvwxyz',
+             \ 'line 3 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
+             \ 'line 4 Abcdefghijklmnopqrstuvwxyz',
+             \ 'line 5 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
+             \ 'line 6 Abcdefghijklmnopqrstuvwxyz',
+             \ 'line 7 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
+             \ 'line 8 Abcdefghijklmnopqrstuvwxyz',
+             \ 'line 9 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
+             \ 'line 10 Abcdefghijklmnopqrstuvwxyz'
+             \ ], getline(1, 9))
+  enew! | close
+
+  augroup Test1
+    au!
+  augroup END
+
+  " Test for the FileAppendPre and FileAppendPost autocmds
+  augroup Test2
+    au!
+    au BufNewFile      *.c    read Xtest.c
+    au FileAppendPre   *.out  '[,']s/new/NEW/
+    au FileAppendPost  *.out  !cat Xtest.c >> test.out
+  augroup END
+
+  call writefile(['/*', ' * Here is a new .c file', ' */'], 'Xtest.c')
+  new foo.c                    " should load Xtest.c
+  call assert_equal(['/*', ' * Here is a new .c file', ' */'], getline(2, 4))
+  w! >> test.out               " append it to the output file
+
+  let contents = readfile('test.out')
+  call assert_equal(' * Here is a NEW .c file', contents[2])
+  call assert_equal(' * Here is a new .c file', contents[5])
+
+  call delete('test.out')
+  enew! | close
+  augroup Test2
+    au!
+  augroup END
+
+  " Test for the BufReadPre and BufReadPost autocmds
+  augroup Test3
+    au!
+    " setup autocommands to decompress before reading and re-compress
+    " afterwards
+    au BufReadPre  *.gz  exe '!gzip -d ' . shellescape(expand("<afile>"))
+    au BufReadPre  *.gz  call rename(expand("<afile>:r"), expand("<afile>"))
+    au BufReadPost *.gz  call rename(expand("<afile>"), expand("<afile>:r"))
+    au BufReadPost *.gz  exe '!gzip ' . shellescape(expand("<afile>:r"))
+  augroup END
+
+  e! Xtestfile.gz              " Edit compressed file
+  call assert_equal([
+             \ 'line 2 Abcdefghijklmnopqrstuvwxyz',
+             \ 'line 3 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
+             \ 'line 4 Abcdefghijklmnopqrstuvwxyz',
+             \ 'line 5 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
+             \ 'line 6 Abcdefghijklmnopqrstuvwxyz',
+             \ 'line 7 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
+             \ 'line 8 Abcdefghijklmnopqrstuvwxyz',
+             \ 'line 9 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
+             \ 'line 10 Abcdefghijklmnopqrstuvwxyz'
+             \ ], getline(1, 9))
+
+  w! >> test.out               " Append it to the output file
+
+  augroup Test3
+    au!
+  augroup END
+
+  " Test for the FilterReadPre and FilterReadPost autocmds.
+  set shelltemp                        " need temp files here
+  augroup Test4
+    au!
+    au FilterReadPre   *.out  call rename(expand("<afile>"), expand("<afile>") . ".t")
+    au FilterReadPre   *.out  exe 'silent !sed s/e/E/ ' . shellescape(expand("<afile>")) . ".t >" . shellescape(expand("<afile>"))
+    au FilterReadPre   *.out  exe 'silent !rm ' . shellescape(expand("<afile>")) . '.t'
+    au FilterReadPost  *.out  '[,']s/x/X/g
+  augroup END
+
+  e! test.out                  " Edit the output file
+  1,$!cat
+  call assert_equal([
+             \ 'linE 2 AbcdefghijklmnopqrstuvwXyz',
+             \ 'linE 3 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
+             \ 'linE 4 AbcdefghijklmnopqrstuvwXyz',
+             \ 'linE 5 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
+             \ 'linE 6 AbcdefghijklmnopqrstuvwXyz',
+             \ 'linE 7 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
+             \ 'linE 8 AbcdefghijklmnopqrstuvwXyz',
+             \ 'linE 9 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
+             \ 'linE 10 AbcdefghijklmnopqrstuvwXyz'
+             \ ], getline(1, 9))
+  call assert_equal([
+             \ 'line 2 Abcdefghijklmnopqrstuvwxyz',
+             \ 'line 3 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
+             \ 'line 4 Abcdefghijklmnopqrstuvwxyz',
+             \ 'line 5 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
+             \ 'line 6 Abcdefghijklmnopqrstuvwxyz',
+             \ 'line 7 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
+             \ 'line 8 Abcdefghijklmnopqrstuvwxyz',
+             \ 'line 9 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
+             \ 'line 10 Abcdefghijklmnopqrstuvwxyz'
+             \ ], readfile('test.out'))
+
+  augroup Test4
+    au!
+  augroup END
+  set shelltemp&vim
+
+  " Test for the FileReadPre and FileReadPost autocmds.
+  augroup Test5
+    au!
+    au FileReadPre *.gz exe 'silent !gzip -d ' . shellescape(expand("<afile>"))
+    au FileReadPre *.gz call rename(expand("<afile>:r"), expand("<afile>"))
+    au FileReadPost *.gz '[,']s/l/L/
+  augroup END
+
+  new
+  0r Xtestfile.gz              " Read compressed file
+  call assert_equal([
+             \ 'Line 2 Abcdefghijklmnopqrstuvwxyz',
+             \ 'Line 3 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
+             \ 'Line 4 Abcdefghijklmnopqrstuvwxyz',
+             \ 'Line 5 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
+             \ 'Line 6 Abcdefghijklmnopqrstuvwxyz',
+             \ 'Line 7 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
+             \ 'Line 8 Abcdefghijklmnopqrstuvwxyz',
+             \ 'Line 9 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
+             \ 'Line 10 Abcdefghijklmnopqrstuvwxyz'
+             \ ], getline(1, 9))
+  call assert_equal([
+             \ 'line 2 Abcdefghijklmnopqrstuvwxyz',
+             \ 'line 3 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
+             \ 'line 4 Abcdefghijklmnopqrstuvwxyz',
+             \ 'line 5 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
+             \ 'line 6 Abcdefghijklmnopqrstuvwxyz',
+             \ 'line 7 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
+             \ 'line 8 Abcdefghijklmnopqrstuvwxyz',
+             \ 'line 9 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
+             \ 'line 10 Abcdefghijklmnopqrstuvwxyz'
+             \ ], readfile('Xtestfile.gz'))
+
+  augroup Test5
+    au!
+  augroup END
+
+  au! FileChangedShell
+  call delete('Xtestfile.gz')
+  call delete('Xtest.c')
+  call delete('test.out')
+endfunc
index f865c3d59347ee5e1c18c241016ccfa41fa42236..2b90f018adad754a17e7fbe6f8598480e8a758cc 100644 (file)
@@ -771,6 +771,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1203,
 /**/
     1202,
 /**/