patch 9.1.0898: runtime(compiler): pytest compiler not included

Commit: 
https://github.com/vim/vim/commit/3c2596a9e967910143d41fbb9615614ab36d43a7
Author: Konfekt <konf...@users.noreply.github.com>
Date:   Sat Nov 30 11:32:49 2024 +0100

    patch 9.1.0898: runtime(compiler): pytest compiler not included
    
    Problem:  runtime(compiler): pytest compiler not included
    Solution: include pytest compiler, update the compiler completion test
              (Konfekt)
    
    closes: #16130
    
    Signed-off-by: Konfekt <konf...@users.noreply.github.com>
    Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/runtime/compiler/pytest.vim b/runtime/compiler/pytest.vim
new file mode 100644
index 000000000..7fc189932
--- /dev/null
+++ b/runtime/compiler/pytest.vim
@@ -0,0 +1,103 @@
+" Vim compiler file
+" Compiler:     Pytest (Python testing framework)
+" Maintainer:   @Konfekt and @mgedmin
+" Last Change:  2024 Nov 28
+
+if exists("current_compiler") | finish | endif
+let current_compiler = "pytest"
+
+let s:cpo_save = &cpo
+set cpo&vim
+
+" CompilerSet makeprg=pytest
+if has('unix')
+  execute $'CompilerSet makeprg=/usr/bin/env\ PYTHONWARNINGS=ignore\ pytest\ 
{escape(get(b:, 'pytest_makeprg_params', get(g:, 'pytest_makeprg_params', 
'--tb=short --quiet')), ' \|"')}'
+elseif has('win32')
+  execute $'CompilerSet makeprg=set\ PYTHONWARNINGS=ignore\ &&\ pytest\ 
{escape(get(b:, 'pytest_makeprg_params', get(g:, 'pytest_makeprg_params', 
'--tb=short --quiet')), ' \|"')}'
+else
+  CompilerSet makeprg=pytest\ --tb=short\ --quiet
+  execute $'CompilerSet makeprg=pytest\ {escape(get(b:, 
'pytest_makeprg_params', get(g:, 'pytest_makeprg_params', '--tb=short 
--quiet')), ' \|"')}'
+endif
+
+" Pytest syntax errors                                          {{{2
+
+" Reset error format so that sourcing .vimrc again and again doesn't grow it
+" without bounds
+setlocal errorformat&
+
+" For the record, the default errorformat is this:
+"
+"   %*[^"]"%f"%*\D%l: %m
+"   "%f"%*\D%l: %m
+"   %-G%f:%l: (Each undeclared identifier is reported only once
+"   %-G%f:%l: for each function it appears in.)
+"   %-GIn file included from %f:%l:%c:
+"   %-GIn file included from %f:%l:%c\,
+"   %-GIn file included from %f:%l:%c
+"   %-GIn file included from %f:%l
+"   %-G%*[ ]from %f:%l:%c
+"   %-G%*[ ]from %f:%l:
+"   %-G%*[ ]from %f:%l\,
+"   %-G%*[ ]from %f:%l
+"   %f:%l:%c:%m
+"   %f(%l):%m
+"   %f:%l:%m
+"   "%f"\, line %l%*\D%c%*[^ ] %m
+"   %D%* [%*\d]: Entering directory %*[`']%f'
+"   %X%* [%*\d]: Leaving directory %*[`']%f'
+"   %D%* : Entering directory %*[`']%f'
+"   %X%* : Leaving directory %*[`']%f'
+"   %DMaking %*  in %f
+"   %f|%l| %m
+"
+" and sometimes it misfires, so let's fix it up a bit
+" (TBH I don't even know what compiler produces filename(lineno) so why even
+" have it?)
+setlocal errorformat-=%f(%l):%m
+
+" Sometimes Vim gets confused about ISO-8601 timestamps and thinks they're
+" filenames; this is a big hammer that ignores anything filename-like on lines
+" that start with at least two spaces, possibly preceded by a number and
+" optional punctuation
+setlocal errorformat^=%+G%\d%#%.%\=\ \ %.%#
+
+" Similar, but when the entire line starts with a date
+setlocal errorformat^=%+G\d\d\d\d-\d\d-\d\d\ \d\d:\d\d%.%#
+
+" make: *** [Makefile:14: target] Error 1
+setlocal errorformat^=%+Gmake:\ ***\ %.%#
+
+" FAILED tests.py::test_with_params[YYYY-MM-DD:HH:MM:SS] - Exception: bla bla
+setlocal errorformat^=%+GFAILED\ %.%#
+
+" AssertionError: assert ...YYYY-MM-DD:HH:MM:SS...
+setlocal errorformat^=%+GAssertionError:\ %.%#
+
+" --- /path/to/file:before  YYYY-MM-DD HH:MM:SS.ssssss
+setlocal errorformat^=---%f:%m
+
+" +++ /path/to/file:before  YYYY-MM-DD HH:MM:SS.ssssss
+setlocal errorformat^=+++%f:%m
+
+" Sometimes pytest prepends an 'E' marker at the beginning of a traceback line
+setlocal errorformat+=E\ %#File\ \"%f\"\,\ line\ %l%.%#
+
+" Python tracebacks (unittest + doctest output)                 {{{2
+
+" This collapses the entire traceback into just the last file+lineno,
+" which is convenient when you want to jump to the line that failed (and not
+" the top-level entry point), but it makes it impossible to see the full
+" traceback, which sucks.
+""setlocal errorformat+=
+""            \File\ \"%f\"\,\ line\ %l%.%#,
+""            \%C\ %.%#,
+""            \%-A\ \ File\ \"unittest%.py\"\,\ line\ %.%#,
+""            \%-A\ \ File\ \"%f\"\,\ line\ 0%.%#,
+""            \%A\ \ File\ \"%f\"\,\ line\ %l%.%#,
+""            \%Z%[%^\ ]%\@=%m
+setlocal errorformat+=File\ \"%f\"\,\ line\ %l\,%#%m
+
+exe 'CompilerSet errorformat='..escape(&l:errorformat, ' \|"')
+
+let &cpo = s:cpo_save
+unlet s:cpo_save
diff --git a/runtime/doc/quickfix.txt b/runtime/doc/quickfix.txt
index 5d97f793f..6d46458c0 100644
--- a/runtime/doc/quickfix.txt
+++ b/runtime/doc/quickfix.txt
@@ -1557,6 +1557,14 @@ Useful values for the 'makeprg' options therefore are:
 
 Also see http://vim.sourceforge.net/tip_view.php?tip_id=280.
 
+PYTEST COMPILER                                                
*compiler-pytest*
+
+Commonly used compiler options can be added to 'makeprg' by setting the
+b/g:pytest_makeprg_params variable.  For example: >
+
+  let b:pytest_makeprg_params = "--verbose --no-summary --disable-warnings"
+
+The global default is "--tb=short --quiet"; Python warnings are suppressed.
 
 TEX COMPILER                                           *compiler-tex*
 
diff --git a/runtime/doc/tags b/runtime/doc/tags
index b55055026..d44dd81a8 100644
--- a/runtime/doc/tags
+++ b/runtime/doc/tags
@@ -6570,6 +6570,7 @@ compiler-mypy     quickfix.txt    /*compiler-mypy*
 compiler-pandoc        quickfix.txt    /*compiler-pandoc*
 compiler-perl  quickfix.txt    /*compiler-perl*
 compiler-pylint        quickfix.txt    /*compiler-pylint*
+compiler-pytest        quickfix.txt    /*compiler-pytest*
 compiler-pyunit        quickfix.txt    /*compiler-pyunit*
 compiler-ruff  quickfix.txt    /*compiler-ruff*
 compiler-select        quickfix.txt    /*compiler-select*
diff --git a/runtime/ftplugin/python.vim b/runtime/ftplugin/python.vim
index c00029672..6f2046889 100644
--- a/runtime/ftplugin/python.vim
+++ b/runtime/ftplugin/python.vim
@@ -3,8 +3,9 @@
 " Maintainer:  Tom Picton <t...@tompicton.com>
 " Previous Maintainer: James Sully <sull...@gmail.com>
 " Previous Maintainer: Johannes Zellner <johan...@zellner.org>
-" Last Change: 2024/05/13
-" https://github.com/tpict/vim-ftplugin-python
+" Repository: https://github.com/tpict/vim-ftplugin-python
+" Last Change: 2024/05/13
+"              2024 Nov 30 use pytest compiler (#16130)
 
 if exists("b:did_ftplugin") | finish | endif
 let b:did_ftplugin = 1
@@ -134,6 +135,11 @@ elseif executable('python')
   setlocal keywordprg=python\ -m\ pydoc
 endif
 
+if expand('%:t') =~# ' ^test_.*\.py$|_test\.py$' && executable('pytest')
+  compiler pytest
+  let &l:makeprg .= ' %:S'
+endif
+
 " Script for filetype switching to undo the local stuff we may have changed
 let b:undo_ftplugin = 'setlocal cinkeys<'
       \ . '|setlocal comments<'
@@ -148,6 +154,7 @@ let b:undo_ftplugin = 'setlocal cinkeys<'
       \ . '|setlocal softtabstop<'
       \ . '|setlocal suffixesadd<'
       \ . '|setlocal tabstop<'
+      \ . '|setlocal makeprg<'
       \ . '|silent! nunmap <buffer> [M'
       \ . '|silent! nunmap <buffer> [['
       \ . '|silent! nunmap <buffer> []'
diff --git a/src/testdir/test_compiler.vim b/src/testdir/test_compiler.vim
index d65080826..71afe5c69 100644
--- a/src/testdir/test_compiler.vim
+++ b/src/testdir/test_compiler.vim
@@ -71,10 +71,10 @@ func Test_compiler_completion()
   call assert_match('^"compiler ' .. clist .. '$', @:)
 
   call feedkeys(":compiler p\<C-A>\<C-B>\"\<CR>", 'tx')
-  call assert_match('"compiler pandoc pbx perl\( p[a-z_]\+\)\+ pylint pyunit', 
@:)
+  call assert_match('"compiler pandoc pbx perl\( p[a-z_]\+\)\+ pyunit', @:)
 
   call feedkeys(":compiler! p\<C-A>\<C-B>\"\<CR>", 'tx')
-  call assert_match('"compiler! pandoc pbx perl\( p[a-z_]\+\)\+ pylint 
pyunit', @:)
+  call assert_match('"compiler! pandoc pbx perl\( p[a-z_]\+\)\+ pyunit', @:)
 endfunc
 
 func Test_compiler_error()
diff --git a/src/version.c b/src/version.c
index e3093a3db..f83e5976d 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    898,
 /**/
     897,
 /**/

-- 
-- 
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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1tHKyF-00FffB-BS%40256bit.org.

Raspunde prin e-mail lui