Wrestling with &errorformat and ISO-8601 timestamps

14 views
Skip to first unread message

Marius Gedminas

unread,
Sep 16, 2020, 3:12:57 AM9/16/20
to vim...@googlegroups.com
I like to run Python unit tests using asyncrun.vim[*] and look at the
results in the quickfix window. One thing that annoys me is that when
the output contains assertion failures involving ISO-8601 timestamps
like this one:

E AssertionError: assert 'GitLab proje...tion: 42s\n' == 'GitLab proje...ob created:\n'
E GitLab project: owner/project
E - Job created: tbd
E + Job created: 2020-09-16T06:16:49.180Z
E + Job started: 2020-09-16T06:16:51.066Z
E + Job finished: not yet
E + Job duration: 42s

tests.py:346: AssertionError

Vim thinks there's an error on line 16 of a file named
"E + Job created: 2020-09-16T06"

How can I tell Vim that, as a Linux user, I don't believe in file names
with spaces in them? Or, as a compromise with Windows users, that file
names with multiple sequential spaces are _extremely_ unlikely?

My &errorformat is set as follows in my .vimrc:

set errorformat&
set errorformat-=%f(%l):%m
set errorformat+=E\ %#File\ \"%f\"\\,\ line\ %l%.%#
set errorformat+=File\ \"%f\"\\,\ line\ %l\\,%#%m

The help says %f pays attention to &isfname, which I haven't tweaked
much:

set isfname-=\=

and it does not include a space AFAICT.

Please help, vim_use@, you're my only hope!


[*] I have this set of plugins[+] that figure out the name of the unit
test that my cursor is inside, so I can press Ctrl+F9 and run that
single test in isolation, in the background, with my statusline
changing color to indicate test running/success/failed, with
quickfix opening automatically in case of failure. Ctrl+Shift+F9
reruns the last test so I can quickly fix the code and see if that
helped without navigating back to the test. Life would be utter
bliss except for this one small annoyance.

[+] https://github.com/mgedmin/dotvim/blob/master/vimrc

Marius Gedminas
--
I went cold turkey on games early on in college in an attempt to focus; in
retrospect, putting Linux on my primary computer to help enforce that was
likely a valuable career decision.
-- Evan Martin

aro...@vex.net

unread,
Sep 16, 2020, 11:29:21 AM9/16/20
to vim...@googlegroups.com

> How can I tell Vim that, as a Linux user, I don't believe in file names
> with spaces in them?

They're legal if quoted or escaped - "dummy file" or dummy\ file.

Gary Johnson

unread,
Sep 16, 2020, 1:57:25 PM9/16/20
to vim...@googlegroups.com
What I have done to avoid these sorts of problems is to put a rule
early in 'errorformat' that matches the unwanted lines and tells Vim
to ignore them. Here's an example of one such rule from my
cppcheck.vim plugin.

set errorformat^=%-G%#:0:\ information:%.%# " Ignores "*:0: information: ..."

See

:help efm-ignore
:help set^=

HTH,
Gary

Marius Gedminas

unread,
Sep 17, 2020, 2:58:20 AM9/17/20
to vim...@googlegroups.com
On Wed, Sep 16, 2020 at 10:56:34AM -0700, Gary Johnson wrote:
> On 2020-09-16, Marius Gedminas wrote:
> > Vim thinks there's an error on line 16 of a file named
> > "E + Job created: 2020-09-16T06"
> >
> > How can I tell Vim that, as a Linux user, I don't believe in file names
> > with spaces in them? Or, as a compromise with Windows users, that file
> > names with multiple sequential spaces are _extremely_ unlikely?
>
> What I have done to avoid these sorts of problems is to put a rule
> early in 'errorformat' that matches the unwanted lines and tells Vim
> to ignore them. Here's an example of one such rule from my
> cppcheck.vim plugin.
>
> set errorformat^=%-G%#:0:\ information:%.%# " Ignores "*:0: information: ..."

Thank you for that suggestion!

set errorformat^=%+G%.\ \ %.%#

solved my problem.

Regards,
Marius Gedminas
--
Any sufficiently advanced technology is indistinguishable from a rigged demo.
- Andy Finkel, computer guy
Reply all
Reply to author
Forward
0 new messages