aboutsummaryrefslogtreecommitdiff
path: root/test/functional/legacy/quickfix_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/legacy/quickfix_spec.lua')
-rw-r--r--test/functional/legacy/quickfix_spec.lua226
1 files changed, 225 insertions, 1 deletions
diff --git a/test/functional/legacy/quickfix_spec.lua b/test/functional/legacy/quickfix_spec.lua
index 7657b8641b..5787ff8ff3 100644
--- a/test/functional/legacy/quickfix_spec.lua
+++ b/test/functional/legacy/quickfix_spec.lua
@@ -265,7 +265,7 @@ describe('helpgrep', function()
autocmd BufReadCmd t call R(expand("<amatch>"))
augroup END
- function R(n)
+ function! R(n)
quit
endfunc
@@ -389,6 +389,73 @@ describe('helpgrep', function()
augroup! testgroup
endfunction
+
+ func Test_vimgreptitle()
+ augroup QfBufWinEnter
+ au!
+ au BufWinEnter * :let g:a=get(w:, 'quickfix_title', 'NONE')
+ augroup END
+ try
+ vimgrep /pattern/j file
+ catch /E480/
+ endtry
+ copen
+ call assert_equal(': vimgrep /pattern/j file', g:a)
+ augroup QfBufWinEnter
+ au!
+ augroup END
+ augroup! QfBufWinEnter
+ endfunc
+
+ function XquickfixChangedByAutocmd(cchar)
+ let Xolder = a:cchar . 'older'
+ let Xgetexpr = a:cchar . 'getexpr'
+ let Xrewind = a:cchar . 'rewind'
+ if a:cchar == 'c'
+ let Xsetlist = 'setqflist('
+ let ErrorNr = 'E925'
+ function! ReadFunc()
+ colder
+ cgetexpr []
+ endfunc
+ else
+ let Xsetlist = 'setloclist(0,'
+ let ErrorNr = 'E926'
+ function! ReadFunc()
+ lolder
+ lgetexpr []
+ endfunc
+ endif
+
+ augroup testgroup
+ au!
+ autocmd BufReadCmd t call ReadFunc()
+ augroup END
+
+ bwipe!
+ let words = [ "a", "b" ]
+ let qflist = []
+ for word in words
+ call add(qflist, {'filename': 't'})
+ exec "call " . Xsetlist . "qflist, '')"
+ endfor
+ exec "call assert_fails('" . Xrewind . "', '" . ErrorNr . ":')"
+
+ augroup! testgroup
+ endfunc
+
+ func Test_caddbuffer_to_empty()
+ helpgr quickfix
+ call setqflist([], 'r')
+ cad
+ try
+ silent cn
+ catch
+ " number of matches is unknown
+ call assert_true(v:exception =~ 'E553:')
+ endtry
+ quit!
+ endfunc
]])
end)
@@ -447,6 +514,11 @@ describe('helpgrep', function()
eq(':setqflist()', eval('g:foo'))
end)
+ it('does not truncate quickfix title', function()
+ call('Test_vimgreptitle')
+ expected_empty()
+ end)
+
it('errors when an autocommand closes the location list\'s window', function()
call('Test_locationlist_curwin_was_closed')
expected_empty()
@@ -456,4 +528,156 @@ describe('helpgrep', function()
call('Test_locationlist')
expected_empty()
end)
+
+ it('is changed by autocmd', function()
+ call('XquickfixChangedByAutocmd', 'c')
+ expected_empty()
+ call('XquickfixChangedByAutocmd', 'l')
+ expected_empty()
+ end)
+
+ it('does not crash after using caddbuffer with an empty qf list', function()
+ call('Test_caddbuffer_to_empty')
+ expected_empty()
+ end)
+
+ it('cgetexpr does not crash with a NULL element in a list', function()
+ execute('cgetexpr [$x]')
+ -- Still alive?
+ eq(2, eval('1+1'))
+ end)
+end)
+
+describe('errorformat', function()
+ before_each(function()
+ clear()
+
+ source([[
+ " More tests for 'errorformat'
+ function! Test_efm1()
+ if !has('unix')
+ " The 'errorformat' setting is different on non-Unix systems.
+ " This test works only on Unix-like systems.
+ return
+ endif
+
+ let l = [
+ \ '"Xtestfile", line 4.12: 1506-045 (S) Undeclared identifier fd_set.',
+ \ '"Xtestfile", line 6 col 19; this is an error',
+ \ 'gcc -c -DHAVE_CONFIsing-prototypes -I/usr/X11R6/include version.c',
+ \ 'Xtestfile:9: parse error before `asd''',
+ \ 'make: *** [vim] Error 1',
+ \ 'in file "Xtestfile" linenr 10: there is an error',
+ \ '',
+ \ '2 returned',
+ \ '"Xtestfile", line 11 col 1; this is an error',
+ \ '"Xtestfile", line 12 col 2; this is another error',
+ \ '"Xtestfile", line 14:10; this is an error in column 10',
+ \ '=Xtestfile=, line 15:10; this is another error, but in vcol 10 this time',
+ \ '"Xtestfile", linenr 16: yet another problem',
+ \ 'Error in "Xtestfile" at line 17:',
+ \ 'x should be a dot',
+ \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 17',
+ \ ' ^',
+ \ 'Error in "Xtestfile" at line 18:',
+ \ 'x should be a dot',
+ \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 18',
+ \ '.............^',
+ \ 'Error in "Xtestfile" at line 19:',
+ \ 'x should be a dot',
+ \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 19',
+ \ '--------------^',
+ \ 'Error in "Xtestfile" at line 20:',
+ \ 'x should be a dot',
+ \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 20',
+ \ ' ^',
+ \ '',
+ \ 'Does anyone know what is the problem and how to correction it?',
+ \ '"Xtestfile", line 21 col 9: What is the title of the quickfix window?',
+ \ '"Xtestfile", line 22 col 9: What is the title of the quickfix window?'
+ \ ]
+
+ call writefile(l, 'Xerrorfile1')
+ call writefile(l[:-2], 'Xerrorfile2')
+
+ let m = [
+ \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 2',
+ \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 3',
+ \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 4',
+ \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 5',
+ \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 6',
+ \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 7',
+ \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 8',
+ \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 9',
+ \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 10',
+ \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 11',
+ \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 12',
+ \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 13',
+ \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 14',
+ \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 15',
+ \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 16',
+ \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 17',
+ \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 18',
+ \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 19',
+ \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 20',
+ \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 21',
+ \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 22'
+ \ ]
+ call writefile(m, 'Xtestfile')
+
+ let save_efm = &efm
+ set efm+==%f=\\,\ line\ %l%*\\D%v%*[^\ ]\ %m
+ set efm^=%AError\ in\ \"%f\"\ at\ line\ %l:,%Z%p^,%C%m
+
+ exe 'cf Xerrorfile2'
+ clast
+ copen
+ call assert_equal(':cf Xerrorfile2', w:quickfix_title)
+ wincmd p
+
+ exe 'cf Xerrorfile1'
+ call assert_equal([4, 12], [line('.'), col('.')])
+ cn
+ call assert_equal([6, 19], [line('.'), col('.')])
+ cn
+ call assert_equal([9, 2], [line('.'), col('.')])
+ cn
+ call assert_equal([10, 2], [line('.'), col('.')])
+ cn
+ call assert_equal([11, 1], [line('.'), col('.')])
+ cn
+ call assert_equal([12, 2], [line('.'), col('.')])
+ cn
+ call assert_equal([14, 10], [line('.'), col('.')])
+ cn
+ call assert_equal([15, 3, 10], [line('.'), col('.'), virtcol('.')])
+ cn
+ call assert_equal([16, 2], [line('.'), col('.')])
+ cn
+ call assert_equal([17, 6], [line('.'), col('.')])
+ cn
+ call assert_equal([18, 7], [line('.'), col('.')])
+ cn
+ call assert_equal([19, 8], [line('.'), col('.')])
+ cn
+ call assert_equal([20, 9], [line('.'), col('.')])
+ clast
+ cprev
+ cprev
+ wincmd w
+ call assert_equal(':cf Xerrorfile1', w:quickfix_title)
+ wincmd p
+
+ let &efm = save_efm
+ call delete('Xerrorfile1')
+ call delete('Xerrorfile2')
+ call delete('Xtestfile')
+ endfunction
+ ]])
+ end)
+
+ it('works', function()
+ call('Test_efm1')
+ expected_empty()
+ end)
end)