-
Notifications
You must be signed in to change notification settings - Fork 510
Problem matcher support for Context errors #2447
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
Conversation
For reference, I tested this on MacOS on Pester tests that have both context and test failures. The console log looks like this:
The failing test fixture looks like this: Describe "Reproduce Issue" {
Context "Failing BeforeAll in Context block" {
BeforeAll {
# In a "real" scenario, this is
# $pathToNuGet = Get-Command nuget.exe | Select-Object -ExpandProperty Source
# &mono $pathToNuGet do-some-things-with-nuget.exe
# to execute NuGet on a Linux/OS X box. The failure I'm seeing in the context
# happens when mono isn't available, and possibly nuget.exe is also not there.
$pathToCommand = Get-Command nosuchcommand.exe | Select-Object -ExpandProperty Source
&othermissingcommand $pathToCommand
}
}
It "has two failures - context and test" {
$False | Should -Be $True
}
} I had two instances of this, one in the top-level folder, one in a folder called I did have to create a tasks.json and run the Pester tests using that because the current "Run Pester tests" from the extension doesn't have the "IncludeVSCodeMarker" part. {
"command": "Invoke-Pester -PesterOption @{IncludeVSCodeMarker=$true}",
"group": {
"isDefault": true,
"kind": "test"
},
"label": "test",
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": "$pester",
"type": "shell"
} |
It appears the builds are failing due to API rate limits being exceeded. I'm not sure there's anything I can do about that. |
Yeah that CI failure can be ignored. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM thanks for fixing this!
@nohwnd this is what we will need to change for Pester 5. We can probably just add another problemMatcher and call it pester5 instead of pester or something.
Cool, I think Pester v5 already prints errors like this, but I will have to check if it triggers the same problem matcher. Is there an environment variable that can be used to detect we are running in VSCode? I would like to do that rather than passing the parameter (even though it is implemented already). That would align better with modifying the output for azure devops / other build services, which is planned later. |
# Any terminal in VSCode
$env:TERM_PROGRAM -eq 'vscode'
# Specifically this extension's terminal
$env:TERM_PROGRAM -eq 'vscode' -and $psEditor |
Since Tasks don't run in the PS Integrated Console, you should just check the |
PR Summary
Fixes #2438 - allows errors that occur in Pester test context to be shown in the Problems window just like other test failures. Solution is a simple regex fix in the problem matcher for line number/location.
PR Checklist
Note: Tick the boxes below that apply to this pull request by putting an
x
between the square brackets.Please mark anything not applicable to this PR
NA
.I didn't see that there were any existing problem matcher tests. If there are, I'd be happy to try adding some updates to them.