aliou / bats.vim

Syntax files for Bats (Bash Automated Testing System).
21 stars 7 forks source link

Errorformat not picking up file, line and message #14

Closed Ian2020 closed 3 years ago

Ian2020 commented 4 years ago

I'm on bats 1.2.1 and the latest bats.vim.

With example test output such as this:

bats test/blah.bats
1..2
not ok 1 blah test
# (from function `assert_equal' in file test/test_helper/bats-assert/src/assert_equal.bash, line 40,
#  in test file test/blah.bats, line 14)
#   `assert_equal "$output" "foo: no such file 'nonexistent_filename'"' failed
# 
# -- values do not equal --
# expected : foo: no such file 'nonexistent_filename'
# actual   : 
# --
# 

In the quickfix window I see only this:

1 successful test

It looks like maybe the output of bats has changed a little so the current errorformat is not picking everything up any more? Specifically in my example the file and line are in parenthesis but split over two lines which seems to be the problem. Also error msgs seem to have one space after the # rather than two now.

If I tweak the errorformat in bats.vim to this:

let s:errorformat = join([
  \ '%Enot ok %m',
  \ '%-C#%.%#in test file %f\\, line %l)',
  \ '%-C# (from func%.%#',
  \ '%-C# %m',
  \ '%-G%.%#',
  \ '%Z'
  \ ], ',')

I get what I would have expected:

test/blah.bats|14 error| 1 successful test `assert_equal "$output" "foo: no such file 'nonexistent_filename'"' failed

It works in my case and I can submit this as a PR if it makes sense.

aliou commented 3 years ago

Hello @Ian2020 ! First off, sorry for taking so long to respond, I think this PR fell into the cracks of my GitHub notifications. I'll try to test this at some point this week and merge it. Thanks for contributing!

Ian2020 commented 3 years ago

No worries, thanks!

aliou commented 3 years ago

Hey @Ian2020, tested and updated the error message to handle the case you described. I've set you as the commit author as I copy-pasted your code from this issue.

I've realised bats.vim 0.10.0 with the change, could you update and let me know if everything is working as expected?

Thanks for opening this issue and again sorry for taking so long to respond, it seems life got in the way 😅

Ian2020 commented 3 years ago

Working for me, thanks again! :smiley: