From 65fb622000af8e3dbb65480e1581758ecf4ba3e2 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 9 Apr 2017 00:12:26 +0300 Subject: functests: Replace execute with either command or feed_command Hope this will make people using feed_command less likely: this hides bugs. Already found at least two: 1. msgpackparse() will show internal error: hash_add() in case of duplicate keys, though it will still work correctly. Currently silenced. 2. ttimeoutlen was spelled incorrectly, resulting in option not being set when expected. Test was still functioning somehow though. Currently fixed. --- test/functional/legacy/011_autocommands_spec.lua | 60 ++++++++++++------------ 1 file changed, 30 insertions(+), 30 deletions(-) (limited to 'test/functional/legacy/011_autocommands_spec.lua') diff --git a/test/functional/legacy/011_autocommands_spec.lua b/test/functional/legacy/011_autocommands_spec.lua index ba899f8119..e01af4583b 100644 --- a/test/functional/legacy/011_autocommands_spec.lua +++ b/test/functional/legacy/011_autocommands_spec.lua @@ -14,8 +14,8 @@ local helpers= require('test.functional.helpers')(after_each) local lfs = require('lfs') -local clear, execute, expect, eq, neq, dedent, write_file, feed = - helpers.clear, helpers.execute, helpers.expect, helpers.eq, helpers.neq, +local clear, feed_command, expect, eq, neq, dedent, write_file, feed = + helpers.clear, helpers.feed_command, helpers.expect, helpers.eq, helpers.neq, helpers.dedent, helpers.write_file, helpers.feed if helpers.pending_win32(pending) then return end @@ -66,26 +66,26 @@ describe('file reading, writing and bufnew and filter autocommands', function() it('FileReadPost (using gzip)', function() prepare_gz_file('Xtestfile', text1) - execute('let $GZIP = ""') + feed_command('let $GZIP = ""') --execute('au FileChangedShell * echo "caught FileChangedShell"') - execute('set bin') - execute("au FileReadPost *.gz '[,']!gzip -d") + feed_command('set bin') + feed_command("au FileReadPost *.gz '[,']!gzip -d") -- Read and decompress the testfile. - execute('$r Xtestfile.gz') + feed_command('$r Xtestfile.gz') expect('\n'..text1) end) it('BufReadPre, BufReadPost (using gzip)', function() prepare_gz_file('Xtestfile', text1) local gzip_data = io.open('Xtestfile.gz'):read('*all') - execute('let $GZIP = ""') + feed_command('let $GZIP = ""') -- Setup autocommands to decompress before reading and re-compress afterwards. - execute("au BufReadPre *.gz exe '!gzip -d ' . shellescape(expand(''))") - execute("au BufReadPre *.gz call rename(expand(':r'), expand(''))") - execute("au BufReadPost *.gz call rename(expand(''), expand(':r'))") - execute("au BufReadPost *.gz exe '!gzip ' . shellescape(expand(':r'))") + feed_command("au BufReadPre *.gz exe '!gzip -d ' . shellescape(expand(''))") + feed_command("au BufReadPre *.gz call rename(expand(':r'), expand(''))") + feed_command("au BufReadPost *.gz call rename(expand(''), expand(':r'))") + feed_command("au BufReadPost *.gz exe '!gzip ' . shellescape(expand(':r'))") -- Edit compressed file. - execute('e! Xtestfile.gz') + feed_command('e! Xtestfile.gz') -- Discard all prompts and messages. feed('') -- Expect the decompressed file in the buffer. @@ -96,11 +96,11 @@ describe('file reading, writing and bufnew and filter autocommands', function() it('FileReadPre, FileReadPost', function() prepare_gz_file('Xtestfile', text1) - execute('au! FileReadPre *.gz exe "silent !gzip -d " . shellescape(expand(""))') - execute('au FileReadPre *.gz call rename(expand(":r"), expand(""))') - execute("au! FileReadPost *.gz '[,']s/l/L/") + feed_command('au! FileReadPre *.gz exe "silent !gzip -d " . shellescape(expand(""))') + feed_command('au FileReadPre *.gz call rename(expand(":r"), expand(""))') + feed_command("au! FileReadPost *.gz '[,']s/l/L/") -- Read compressed file. - execute('$r Xtestfile.gz') + feed_command('$r Xtestfile.gz') -- Discard all prompts and messages. feed('') expect([[ @@ -121,17 +121,17 @@ describe('file reading, writing and bufnew and filter autocommands', function() end it('FileAppendPre, FileAppendPost', function() - execute('au BufNewFile *.c read Xtest.c') + feed_command('au BufNewFile *.c read Xtest.c') -- Will load Xtest.c. - execute('e! foo.c') - execute("au FileAppendPre *.out '[,']s/new/NEW/") - execute('au FileAppendPost *.out !cat Xtest.c >>test.out') + feed_command('e! foo.c') + feed_command("au FileAppendPre *.out '[,']s/new/NEW/") + feed_command('au FileAppendPost *.out !cat Xtest.c >>test.out') -- Append it to the output file. - execute('w>>test.out') + feed_command('w>>test.out') -- Discard all prompts and messages. feed('') -- Expect the decompressed file in the buffer. - execute('e test.out') + feed_command('e test.out') expect([[ /* @@ -166,18 +166,18 @@ describe('file reading, writing and bufnew and filter autocommands', function() * Here is a new .c file */]])) -- Need temp files here. - execute('set shelltemp') - execute('au FilterReadPre *.out call rename(expand(""), expand("") . ".t")') - execute('au FilterReadPre *.out exe "silent !sed s/e/E/ " . shellescape(expand("")) . ".t >" . shellescape(expand(""))') - execute('au FilterReadPre *.out exe "silent !rm " . shellescape(expand("")) . ".t"') - execute("au FilterReadPost *.out '[,']s/x/X/g") + feed_command('set shelltemp') + feed_command('au FilterReadPre *.out call rename(expand(""), expand("") . ".t")') + feed_command('au FilterReadPre *.out exe "silent !sed s/e/E/ " . shellescape(expand("")) . ".t >" . shellescape(expand(""))') + feed_command('au FilterReadPre *.out exe "silent !rm " . shellescape(expand("")) . ".t"') + feed_command("au FilterReadPost *.out '[,']s/x/X/g") -- Edit the output file. - execute('e! test.out') - execute('23,$!cat') + feed_command('e! test.out') + feed_command('23,$!cat') -- Discard all prompts and messages. feed('') -- Remove CR for when sed adds them. - execute([[23,$s/\r$//]]) + feed_command([[23,$s/\r$//]]) expect([[ startstart start of testfile -- cgit From 126b2ca077718a02c086039c8f98ef267cf9eb3e Mon Sep 17 00:00:00 2001 From: KillTheMule Date: Sun, 24 Sep 2017 20:42:48 +0200 Subject: test: lint whitespace in legacy/ (#7308) --- test/functional/legacy/011_autocommands_spec.lua | 2 ++ 1 file changed, 2 insertions(+) (limited to 'test/functional/legacy/011_autocommands_spec.lua') diff --git a/test/functional/legacy/011_autocommands_spec.lua b/test/functional/legacy/011_autocommands_spec.lua index e01af4583b..d969a8bd37 100644 --- a/test/functional/legacy/011_autocommands_spec.lua +++ b/test/functional/legacy/011_autocommands_spec.lua @@ -94,6 +94,8 @@ describe('file reading, writing and bufnew and filter autocommands', function() eq(gzip_data, io.open('Xtestfile.gz'):read('*all')) end) + -- luacheck: ignore 621 (Indentation) + -- luacheck: ignore 611 (Line contains only whitespaces) it('FileReadPre, FileReadPost', function() prepare_gz_file('Xtestfile', text1) feed_command('au! FileReadPre *.gz exe "silent !gzip -d " . shellescape(expand(""))') -- cgit