Hi,
test11 uses gzip to test the autocmds FileReadPre/Post and
FileWritePre/Post. Gzip might not be available on all platforms, so I
switched to xxd to do the tests.
Attached patch is test11 using xxd instead of gzip.
- Ralf
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
diff -r f5bd6753cdc4 src/testdir/test11.in
--- a/src/testdir/test11.in Fri May 28 22:06:46 2010 +0200
+++ b/src/testdir/test11.in Sat May 29 13:12:51 2010 +0200
@@ -1,28 +1,29 @@
Tests for autocommands:
-- FileWritePre writing a compressed file
-- FileReadPost reading a compressed file
+- FileWritePre writing as hexdump (using xxd)
+- FileReadPost reading from hexdump (using xxd -r)
- BufNewFile reading a file template
-- BufReadPre decompressing the file to be read
+- BufReadPre un-hexdump 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
+- FileReadPre un-hexdump file before read
+- FileReadPost un-hexdump file after read
-Note: This test will fail 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
+Use a FileChangedShell autocommand to avoid a prompt for "Xtestfile.hd" being
modified outside of Vim (noticed on Solaris).
STARTTEST
:so small.vim
-: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
+:au FileWritePre *.hd '[,']!xxd
+:au FileWritePost *.hd undo
+:/^start of testfile/,/^end of testfile/w! Xtestfile.hd
+:$r Xtestfile.hd " Read hexdump and keep one line
+:/^0000010:/,$d
+:/^0000000:/s/\r$// " remove CR from xxd (if any)
+:/^0000000:/s/ \x[0-9a-f ]*/ -- / " remove hex codes (ascii/ebcdic-problem)
+:au FileReadPost *.hd '[,']!xxd -r
+:$r Xtestfile.hd " Read hexdump and un-xxd
:?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
@@ -32,11 +33,11 @@
: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
+:au BufReadPre *.hd exe '!xxd -r ' . shellescape(expand("<afile>")) . '>' . expand("<afile>:r")
+:au BufReadPre *.hd call rename(expand("<afile>:r"), expand("<afile>"))
+:au BufReadPost *.hd call rename(expand("<afile>"), expand("<afile>:r"))
+:au BufReadPost *.hd exe '!xxd ' . shellescape(expand("<afile>:r")) . '>' . expand("<afile>")
+:e! Xtestfile.hd " 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")
@@ -44,14 +45,14 @@
:au FilterReadPre *.out exe '!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 '!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
+:24,$!cat
+:24,$s/\r$// " remove CR for when sed adds them
+:au! FileReadPre *.hd exe '!xxd -r ' . shellescape(expand("<afile>")) . '>' . expand("<afile>:r")
+:au FileReadPre *.hd call rename(expand("<afile>:r"), expand("<afile>"))
+:au! FileReadPost *.hd '[,']s/l/L/
+:$r Xtestfile.hd " Read compressed file
:w " write it, after filtering
-:au! " remove all autocommands
+:au!
:e " Edit test.out again
:set nobin ff& " use the default fileformat for writing
:w
diff -r f5bd6753cdc4 src/testdir/test11.ok
--- a/src/testdir/test11.ok Fri May 28 22:06:46 2010 +0200
+++ b/src/testdir/test11.ok Sat May 29 13:12:51 2010 +0200
@@ -16,6 +16,7 @@
* Here is a new .c file
*/
end of test.c
+0000000: -- start of testfil
start of testfile
line 2 Abcdefghijklmnopqrstuvwxyz
line 3 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx