Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

:GoTest fails parsing output when it looks like a line number (timestamps etc.) #1245

Closed
thomasheller opened this issue Mar 27, 2017 · 2 comments · Fixed by #1316
Closed
Labels

Comments

@thomasheller
Copy link

thomasheller commented Mar 27, 2017

Behavior

I'm running some Go tests through :GoTest and I would expect to see the output in the quickfix window. Instead, the output gets truncated and I get the error message Dropped "[...]" from location list (nonvalid filename) from go#tool#FilterValids.

Steps to reproduce:

The following minimal Go code triggers the described behavior. Run it through :GoTest, see the truncated output in the quickfix window and the error message.

They key point is that the output contains a line break, and the content of the new line looks like what could be a filename followed by a line number.

package main

import (
        "testing"
)

func TestFails(t *testing.T) {
        t.Errorf("\n:1:")
}

Note that this is based on a real-world testcase provided by @deltaskelta, I'm just giving a minimal example to reproduce the behavior.

This bug occurs for example when the test output spans multiple lines and contains timestamps, where time values like 15:04:05 look a lot like what could be a filename followed by a line number.

Configuration

  • vim version: Vim 7.4
  • vim-go version: vim-go 1.11
  • go version: Go 1.8

Possible fix

I suppose this is caused by the regex in go#tool#ParseErrors which is a little too broad. It considers every line that begins with colon-number-colon (optional filename and whitespace) to be an error message.

If we would require the filename part to be non-empty in such a way that it at least begins with one non-whitespace character like ^\s*\(\S.\{-}\):\(\d\+\):\s*\(.*\), this works as expected.

I'm not 100% sure though what the idea behind this regex was and if requiring one non-whitespace character in the beginning is actually the best way to go about this, so perhaps someone else can take another look at this. I would suspect that matching could even be restricted to filenames that end in _test.go?

@fatih
Copy link
Owner

fatih commented Mar 28, 2017

Hi @thomasheller

Yeap, the regex is not perfect, it does the work though. If you have a a fix and provide a foo_test.go file with all the edge cases, I'm happy to merge it.

@fatih
Copy link
Owner

fatih commented Jun 2, 2017

I've changed the regex to only parse for files that end with .go. This fixes at least your issue. Please pull latest master to get the fix and feel free to open another issue if encounter anything new. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants