Skip to content

Rkeithhill/tasks add problemmatcher #98

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 117 additions & 9 deletions examples/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
// This uses the 'taskRunnertest' tag to specify which tests to include.
// A task runner that invokes Pester which runs all Pester tests under the
// current workspace folder.

// Available variables which can be used inside of strings.
// ${workspaceRoot}: the root folder of the team
// ${file}: the current opened file
// ${fileBasename}: the current opened file's basename
// ${fileDirname}: the current opened file's dirname
// ${fileExtname}: the current opened file's extension
// ${cwd}: the current working directory of the spawned process

// A task runner that calls Pester for testing the current project
{
"version": "0.1.0",

// Start PowerShell
"command": "c:\\windows\\sysnative\\windowspowershell\\v1.0\\PowerShell.exe",
"command": "${env.windir}\\sysnative\\windowspowershell\\v1.0\\PowerShell.exe",

// The command is a shell script
"isShellCommand": true,
Expand All @@ -16,16 +24,116 @@
// Allow Pester to invoke scripts and run Pester
"args": [
"-NoProfile",
"Set-ExecutionPolicy -ExecutionPolicy 'RemoteSigned' -Scope 'Process';",
"write-host 'invoking Pester...';invoke-pester;",
"invoke-command {write-host \"Completed all tasks in taskRunner: $args[0]\"} -args"
"Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process;",
"Write-Host 'Invoking Pester...'; Invoke-Pester;",
"Invoke-Command { Write-Host \"Completed all tasks in task runner: $($args[0])\" } -args"
],
// Associate with test taskrunner

// Associate with test task runner
"tasks": [
{
"taskName": "Pester",
"isTestCommand": true
"isTestCommand": true,
"problemMatcher": [
{
"owner": "powershell",
"fileLocation": ["absolute"],
"severity": "error",
"pattern": [
{
"regexp": "^\\s*\\[-\\](.*?)(\\d+)ms\\s*$",
"message": 1
},
{
"regexp": "^.*$"
},
{
"regexp": "^\\s+at line: (\\d+) in (.*)$",
"line": 1,
"file": 2,
"message": 2
}
]
},
{
"owner": "powershell",
"fileLocation": ["absolute"],
"severity": "error",
"pattern": [
{
"regexp": "^\\s*\\[-\\](.*?)(\\d+)ms\\s*$",
"message": 1
},
{
"regexp": "^.*$"
},
{
"regexp": "^.*$"
},
{
"regexp": "^\\s+at line: (\\d+) in (.*)$",
"line": 1,
"file": 2,
"message": 2
}
]
},
{
"owner": "powershell",
"fileLocation": ["absolute"],
"severity": "error",
"pattern": [
{
"regexp": "^\\s*\\[-\\](.*?)(\\d+)ms\\s*$",
"message": 1
},
{
"regexp": "^.*$"
},
{
"regexp": "^.*$"
},
{
"regexp": "^.*$"
},
{
"regexp": "^\\s+at line: (\\d+) in (.*)$",
"line": 1,
"file": 2,
"message": 2
}
]
},
{
"owner": "powershell",
"fileLocation": ["absolute"],
"severity": "error",
"pattern": [
{
"regexp": "^\\s*\\[-\\](.*?)(\\d+)ms\\s*$",
"message": 1
},
{
"regexp": "^.*$"
},
{
"regexp": "^.*$"
},
{
"regexp": "^.*$"
},
{
"regexp": "^.*$"
},
{
"regexp": "^\\s+at line: (\\d+) in (.*)$",
"line": 1,
"file": 2,
"message": 2
}
]
}
]
}
]
}
60 changes: 35 additions & 25 deletions examples/PathProcessing.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,58 +1,68 @@
New-Item -Path 'foo[1].txt' -Force
# These Pester tests are for the for parameter-* and ex-path* snippets.
# Take a look at the .vscode\tasks.json file to see how you can create
# and configure a test task runner that will run all the Pester tests
# in your workspace folder.

. $PSScriptRoot\PathProcessingNonExistingPaths.ps1
Describe 'Verify Path Processing for Non-existing Paths Allowed Impl' {
# To run these Pester tests, press Ctrl+Shift+T or press Ctrl+Shift+P,
# type "test" and select "Tasks: Run Test Task". This will invoke the
# test task runner defined in .vscode\tasks.json.

# This (empty) file is required by some of the tests.
$null = New-Item -Path 'foo[1].txt' -Force

. $PSScriptRoot\PathProcessingNonExistingPaths.ps1
Describe 'Verify Path Processing for Non-existing Paths Allowed Impl' {
It 'Processes non-wildcard absolute path to non-existing file via -Path param' {
New-File -Path $PSScriptRoot\ReadmeNew.md | Should Be "$PSScriptRoot\READMENew.md"
}
It 'Processes multiple absolute paths via -Path param' {
New-File -Path $PSScriptRoot\Readme.md, $PSScriptRoot\XYZZY.ps1 |
New-File -Path $PSScriptRoot\Readme.md, $PSScriptRoot\XYZZY.ps1 |
Should Be @("$PSScriptRoot\README.md", "$PSScriptRoot\XYZZY.ps1")
}
}
It 'Processes relative path via -Path param' {
New-File -Path ..\examples\READMENew.md | Should Be "$PSScriptRoot\READMENew.md"
}
It 'Processes multiple relative path via -Path param' {
New-File -Path ..\examples\README.md, XYZZY.ps1 |
New-File -Path ..\examples\README.md, XYZZY.ps1 |
Should Be @("$PSScriptRoot\README.md", "$PSScriptRoot\XYZZY.ps1")
}

It 'Should accept pipeline input to Path' {
Get-ChildItem -LiteralPath "$pwd\foo[1].txt" | New-File | Should Be "$PSScriptRoot\foo[1].txt"
}
}
}

. $PSScriptRoot\PathProcessingNoWildcards.ps1
Describe 'Verify Path Processing for NO Wildcards Allowed Impl' {
. $PSScriptRoot\PathProcessingNoWildcards.ps1
Describe 'Verify Path Processing for NO Wildcards Allowed Impl' {
It 'Processes non-wildcard absolute path via -Path param' {
Import-FileNoWildcard -Path $PSScriptRoot\Readme.md | Should Be "$PSScriptRoot\README.md"
}
It 'Processes multiple absolute paths via -Path param' {
Import-FileNoWildcard -Path $PSScriptRoot\Readme.md, $PSScriptRoot\PathProcessingWildcards.ps1 |
Import-FileNoWildcard -Path $PSScriptRoot\Readme.md, $PSScriptRoot\PathProcessingWildcards.ps1 |
Should Be @("$PSScriptRoot\README.md", "$PSScriptRoot\PathProcessingWildcards.ps1")
}
}
It 'Processes relative path via -Path param' {
Import-FileNoWildcard -Path ..\examples\README.md | Should Be "$PSScriptRoot\README.md"
}
It 'Processes multiple relative path via -Path param' {
Import-FileNoWildcard -Path ..\examples\README.md, .vscode\launch.json |
Import-FileNoWildcard -Path ..\examples\README.md, .vscode\launch.json |
Should Be @("$PSScriptRoot\README.md", "$PSScriptRoot\.vscode\launch.json")
}

It 'Should accept pipeline input to Path' {
Get-ChildItem -LiteralPath "$pwd\foo[1].txt" | Import-FileNoWildcard | Should Be "$PSScriptRoot\foo[1].txt"
}
}
}

. $PSScriptRoot\PathProcessingWildcards.ps1
Describe 'Verify Path Processing for Wildcards Allowed Impl' {
. $PSScriptRoot\PathProcessingWildcards.ps1
Describe 'Verify Path Processing for Wildcards Allowed Impl' {
It 'Processes non-wildcard absolute path via -Path param' {
Import-FileWildcard -Path $PSScriptRoot\Readme.md | Should Be "$PSScriptRoot\README.md"
}
It 'Processes multiple absolute paths via -Path param' {
Import-FileWildcard -Path $PSScriptRoot\Readme.md, $PSScriptRoot\PathProcessingWildcards.ps1 |
Import-FileWildcard -Path $PSScriptRoot\Readme.md, $PSScriptRoot\PathProcessingWildcards.ps1 |
Should Be @("$PSScriptRoot\README.md", "$PSScriptRoot\PathProcessingWildcards.ps1")
}
}
It 'Processes wildcard absolute path via -Path param' {
Import-FileWildcard -Path $PSScriptRoot\*.md | Should Be "$PSScriptRoot\README.md"
}
Expand All @@ -63,26 +73,26 @@ Describe 'Verify Path Processing for Wildcards Allowed Impl' {
Import-FileWildcard -Path ..\examples\README.md | Should Be "$PSScriptRoot\README.md"
}
It 'Processes multiple relative path via -Path param' {
Import-FileWildcard -Path ..\examples\README.md, .vscode\launch.json |
Import-FileWildcard -Path ..\examples\README.md, .vscode\launch.json |
Should Be @("$PSScriptRoot\README.md", "$PSScriptRoot\.vscode\launch.json")
}

It 'DefaultParameterSet should be Path' {
Import-FileWildcard *.md | Should Be "$PSScriptRoot\README.md"
}

It 'Should process absolute literal paths via -LiteralPath param'{
Import-FileWildcard -LiteralPath "$PSScriptRoot\foo[1].txt" | Should Be "$PSScriptRoot\foo[1].txt"
}
It 'Should process relative literal paths via -LiteralPath param'{
Import-FileWildcard -LiteralPath "..\examples\foo[1].txt" | Should Be "$PSScriptRoot\foo[1].txt"
}
It 'Should process multiple literal paths via -LiteralPath param'{
Import-FileWildcard -LiteralPath "..\examples\foo[1].txt", "$PSScriptRoot\README.md" |
Import-FileWildcard -LiteralPath "..\examples\foo[1].txt", "$PSScriptRoot\README.md" |
Should Be @("$PSScriptRoot\foo[1].txt", "$PSScriptRoot\README.md")
}

It 'Should accept pipeline input to LiteralPath' {
Get-ChildItem -LiteralPath "$pwd\foo[1].txt" | Import-FileWildcard | Should Be "$PSScriptRoot\foo[1].txt"
}
}
}