-
Notifications
You must be signed in to change notification settings - Fork 29.5k
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
Problem matchers for error messages that span multiple lines #9635
Comments
It is partly possible but without actually capturing both messages. A message can only be captured once. Can you share a project showing this output. Then I can have a look why it doesn't work? |
@dbaeumer sure, I've just uploaded the sample project here: Let me know if you need anything else. Ideally what would be cool is if we should capture both lines relevant to the failure so that it gets reported as "Expected: 0 But was: 3", literally just replacing the new lines with spaces or something. |
@massimocode thanks for the example. I cloned it and run the task, however it produces the following output for me (which I have to admit is not parseable by the framework right now):
I am using |
@dbaeumer Apologies for that, the code I checked in had passing unit tests (so no errors to report). I have since updated the repository to have the same 2 failing tests as in the original issue description. The repository is here: Thanks! |
I will have another look then. Thanks. |
I need this same functionality (capturing a message across multiple lines). I also have output from my tests like Expected: 0 that I would like to capture as the 'message'. |
@indiejames we are working on making tasks API so that people can code this. Having a declarative approach to this requires me to invent a programming language in JSON :-( |
@dbaeumer do you have an idea how high in the priority list a reporting API is ? We're comparing Atom with VSCode, and I really like VSCode. But on this front, the atom build plugin & problem reporter are light years ahead... |
It is |
This is a pain point for Haskell users, too. Here's a typical multi-line error from GHC:
The best I can do with the current |
If I wanted a quick fix for this, I'd create an |
So it looks like the UI work done in 1.31 on multi-line messages is part of a fix to this issue, but providing an API is still to be done, is that correct? |
The UI work will be useful for this, but yes, there is still Task API that will need to be added. |
I did some exploration with problem matchers on the weekend and I really wanted this. Having this would mean it could be done all in JSON committed to the repo, not require an extension as in #59337 I was trying to get a nice problem matcher with a multi-line message for mocha errors and to do that I ended up needing to do a custom mocha reporter to output a specific format and then repeating the message capture several times. The problem is the exact number of the Problem matcher I used: "problemMatcher": {
"owner": "javascript",
"severity": "error",
"fileLocation": "absolute",
"pattern": [
{
"regexp": "^\\s*File: ([^ ]+):(\\d+)",
"file": 1,
"line": 2,
},
{ "regexp": "^\\s*Trace: (.+)", "message": 1 },
{ "regexp": "^\\s*Trace: (.+)", "message": 1 },
{ "regexp": "^\\s*Trace: (.+)", "message": 1 },
{ "regexp": "^\\s*Trace: (.+)", "message": 1 },
{ "regexp": "^\\s*Trace: (.+)", "message": 1 },
{ "regexp": "^\\s*Trace: (.+)", "message": 1 },
{ "regexp": "^\\s*Trace: (.+)", "message": 1 },
{ "regexp": "^\\s*Trace: (.+)", "message": 1 },
{ "regexp": "^\\s*Trace: (.+)", "message": 1 },
{ "regexp": "^\\s*Trace: (.+)", "message": 1 },
{ "regexp": "^\\s*Trace: (.+)", "message": 1 },
{ "regexp": "^\\s*Trace: (.+)", "message": 1 },
{ "regexp": "^\\s*Trace: (.+)", "message": 1 }
]
} The result after pressing F8 means I wouldn't even have to open the terminal 😍 I would expect something like this to work instead: "pattern": [
{
"regexp": "^\\s*File: ([^ ]+):(\\d+)",
"file": 1,
"line": 2,
},
{ "regexp": "^\\s*Trace: (.+)", "message": 1, "repeat": true },
] Without a problem matcher there is the issue of the message potentially containing empty lines which would need to be supported but I would expect something like this to work for the regular "spec" reporter: "pattern": [
{
"regexp": "^\\s*(AssertionError: .+)",
"file": 1,
"line": 2,
"message": 1
},
{
"regexp": "...", // not "at ...", not sure how to do that without looking it up
"message": 1,
// Repeats the message until it no longer matches, needs to handle empty lines as well
"repeatMessage": true
},
] |
The method described previously by @jpihl seems to only show one error in 1.76.2: |
I tried every combination of emitting message output from by build and VS Code problem matcher that I could think of. I don't think meaningful display of multi-line problem messages of any kind is possible using any UI feature (except the editor) in 1.76.2. I definitely welcome an example demonstrating meaningful display of multiline messages. I have good control over what my build system emits, so if VS Code can be coerced into displaying a multiline message I expect I can adapt to that. As a stop-gap I configured my build to dump each multiline message to a file and mention that file as a problem. The result is easily the best multiline problem user experience I have achieved using VS Code, but it's still extra steps to see view the right problems and far from ideal. At least I no longer have to hunt through terminal output to find details of test failures though. Here is a screenshot of the UI for multiline problem messages with this approach: |
To pile on, Python's Sample output:
|
Would be very nice to get this feature! The "workaround" I got for now in the case of eslint is this {
"version": "2.0.0",
"tasks": [
{
"label": "ESLINT - Full project",
"type": "shell",
"command": "npx eslint . --format=compact",
"problemMatcher": ["$eslint-compact"],
}
]
} It does not enable to match everything though (and even more so when I am not using my external monitor full screen). I also tried to use something like this (with Git Bash) to remove spaces to get less long lines "command": "npx eslint . --output-file \"$TEMP\\eslint.log\"; sed 's/ \\{3,\\}/ /g' \"$TEMP\\eslint.log\"",
"problemMatcher": ["$eslint-stylish"], But this heuristic is performing worse on my project than the compact hack. As a sidenote, I think it is very sad to have this kind of deadlock on Microsoft own ecosystem this is one more thing making me consider just switching to UNIX because a very basic thing has been broken for years. |
I've come to this issue from trying to parse Ruby's Minitest output in some meaningful way (using For reference, here's a typical
Here's a typical
We'll work with the latter. So here how it goes, I have three
First, attempting to capture
Then we have this for test
Interestingly enough the reason for the match failure is visible when trying something like @Tyriar did (just eat with Finally the third one, for
And we're done:
It all gets really odd if you add/replace with a bunch of these I've attached a couple or three screenshots:
If I add 10 Again, there was no change whatsoever between these runs, merely re-running the task again, which produced identical output yet different matching results. So overall ... but matching multiple lines, each with a distinct pattern, appears to be broken in some way that makes it completely unreliable and useless. |
This works around problems identified at: microsoft/vscode#9635 (comment)
Hello,
Errors are always terminated by a dual-linechange. This regex parses the output just fine if used with Python.re: But it seems VSCode is missing the "multiline" modifier in its matcher... |
I'm unable to get a message built up from several lines in the output. In the output below, I would like the message to contain the spec name, and the reason it failed. Any ideas if this is possible?
I have the following output from NUnit:
I have configured the following problem matcher:
The text was updated successfully, but these errors were encountered: