Skip to content

Commit 6a5d3e1

Browse files
committed
Merge pull request #98 from rkeithhill/rkeithhill/tasks-add-problemmatcher
Rkeithhill/tasks add problemmatcher
2 parents dfa0d00 + fdfb04a commit 6a5d3e1

File tree

2 files changed

+152
-34
lines changed

2 files changed

+152
-34
lines changed

examples/.vscode/tasks.json

+117-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1-
// This uses the 'taskRunnertest' tag to specify which tests to include.
1+
// A task runner that invokes Pester which runs all Pester tests under the
2+
// current workspace folder.
3+
4+
// Available variables which can be used inside of strings.
5+
// ${workspaceRoot}: the root folder of the team
6+
// ${file}: the current opened file
7+
// ${fileBasename}: the current opened file's basename
8+
// ${fileDirname}: the current opened file's dirname
9+
// ${fileExtname}: the current opened file's extension
10+
// ${cwd}: the current working directory of the spawned process
211

3-
// A task runner that calls Pester for testing the current project
412
{
513
"version": "0.1.0",
614

715
// Start PowerShell
8-
"command": "c:\\windows\\sysnative\\windowspowershell\\v1.0\\PowerShell.exe",
16+
"command": "${env.windir}\\sysnative\\windowspowershell\\v1.0\\PowerShell.exe",
917

1018
// The command is a shell script
1119
"isShellCommand": true,
@@ -16,16 +24,116 @@
1624
// Allow Pester to invoke scripts and run Pester
1725
"args": [
1826
"-NoProfile",
19-
"Set-ExecutionPolicy -ExecutionPolicy 'RemoteSigned' -Scope 'Process';",
20-
"write-host 'invoking Pester...';invoke-pester;",
21-
"invoke-command {write-host \"Completed all tasks in taskRunner: $args[0]\"} -args"
27+
"Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process;",
28+
"Write-Host 'Invoking Pester...'; Invoke-Pester;",
29+
"Invoke-Command { Write-Host \"Completed all tasks in task runner: $($args[0])\" } -args"
2230
],
23-
24-
// Associate with test taskrunner
31+
32+
// Associate with test task runner
2533
"tasks": [
2634
{
2735
"taskName": "Pester",
28-
"isTestCommand": true
36+
"isTestCommand": true,
37+
"problemMatcher": [
38+
{
39+
"owner": "powershell",
40+
"fileLocation": ["absolute"],
41+
"severity": "error",
42+
"pattern": [
43+
{
44+
"regexp": "^\\s*\\[-\\](.*?)(\\d+)ms\\s*$",
45+
"message": 1
46+
},
47+
{
48+
"regexp": "^.*$"
49+
},
50+
{
51+
"regexp": "^\\s+at line: (\\d+) in (.*)$",
52+
"line": 1,
53+
"file": 2,
54+
"message": 2
55+
}
56+
]
57+
},
58+
{
59+
"owner": "powershell",
60+
"fileLocation": ["absolute"],
61+
"severity": "error",
62+
"pattern": [
63+
{
64+
"regexp": "^\\s*\\[-\\](.*?)(\\d+)ms\\s*$",
65+
"message": 1
66+
},
67+
{
68+
"regexp": "^.*$"
69+
},
70+
{
71+
"regexp": "^.*$"
72+
},
73+
{
74+
"regexp": "^\\s+at line: (\\d+) in (.*)$",
75+
"line": 1,
76+
"file": 2,
77+
"message": 2
78+
}
79+
]
80+
},
81+
{
82+
"owner": "powershell",
83+
"fileLocation": ["absolute"],
84+
"severity": "error",
85+
"pattern": [
86+
{
87+
"regexp": "^\\s*\\[-\\](.*?)(\\d+)ms\\s*$",
88+
"message": 1
89+
},
90+
{
91+
"regexp": "^.*$"
92+
},
93+
{
94+
"regexp": "^.*$"
95+
},
96+
{
97+
"regexp": "^.*$"
98+
},
99+
{
100+
"regexp": "^\\s+at line: (\\d+) in (.*)$",
101+
"line": 1,
102+
"file": 2,
103+
"message": 2
104+
}
105+
]
106+
},
107+
{
108+
"owner": "powershell",
109+
"fileLocation": ["absolute"],
110+
"severity": "error",
111+
"pattern": [
112+
{
113+
"regexp": "^\\s*\\[-\\](.*?)(\\d+)ms\\s*$",
114+
"message": 1
115+
},
116+
{
117+
"regexp": "^.*$"
118+
},
119+
{
120+
"regexp": "^.*$"
121+
},
122+
{
123+
"regexp": "^.*$"
124+
},
125+
{
126+
"regexp": "^.*$"
127+
},
128+
{
129+
"regexp": "^\\s+at line: (\\d+) in (.*)$",
130+
"line": 1,
131+
"file": 2,
132+
"message": 2
133+
}
134+
]
135+
}
136+
]
29137
}
30138
]
31139
}

examples/PathProcessing.Tests.ps1

+35-25
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,68 @@
1-
New-Item -Path 'foo[1].txt' -Force
1+
# These Pester tests are for the for parameter-* and ex-path* snippets.
2+
# Take a look at the .vscode\tasks.json file to see how you can create
3+
# and configure a test task runner that will run all the Pester tests
4+
# in your workspace folder.
25

3-
. $PSScriptRoot\PathProcessingNonExistingPaths.ps1
4-
Describe 'Verify Path Processing for Non-existing Paths Allowed Impl' {
6+
# To run these Pester tests, press Ctrl+Shift+T or press Ctrl+Shift+P,
7+
# type "test" and select "Tasks: Run Test Task". This will invoke the
8+
# test task runner defined in .vscode\tasks.json.
9+
10+
# This (empty) file is required by some of the tests.
11+
$null = New-Item -Path 'foo[1].txt' -Force
12+
13+
. $PSScriptRoot\PathProcessingNonExistingPaths.ps1
14+
Describe 'Verify Path Processing for Non-existing Paths Allowed Impl' {
515
It 'Processes non-wildcard absolute path to non-existing file via -Path param' {
616
New-File -Path $PSScriptRoot\ReadmeNew.md | Should Be "$PSScriptRoot\READMENew.md"
717
}
818
It 'Processes multiple absolute paths via -Path param' {
9-
New-File -Path $PSScriptRoot\Readme.md, $PSScriptRoot\XYZZY.ps1 |
19+
New-File -Path $PSScriptRoot\Readme.md, $PSScriptRoot\XYZZY.ps1 |
1020
Should Be @("$PSScriptRoot\README.md", "$PSScriptRoot\XYZZY.ps1")
11-
}
21+
}
1222
It 'Processes relative path via -Path param' {
1323
New-File -Path ..\examples\READMENew.md | Should Be "$PSScriptRoot\READMENew.md"
1424
}
1525
It 'Processes multiple relative path via -Path param' {
16-
New-File -Path ..\examples\README.md, XYZZY.ps1 |
26+
New-File -Path ..\examples\README.md, XYZZY.ps1 |
1727
Should Be @("$PSScriptRoot\README.md", "$PSScriptRoot\XYZZY.ps1")
1828
}
19-
29+
2030
It 'Should accept pipeline input to Path' {
2131
Get-ChildItem -LiteralPath "$pwd\foo[1].txt" | New-File | Should Be "$PSScriptRoot\foo[1].txt"
22-
}
32+
}
2333
}
2434

25-
. $PSScriptRoot\PathProcessingNoWildcards.ps1
26-
Describe 'Verify Path Processing for NO Wildcards Allowed Impl' {
35+
. $PSScriptRoot\PathProcessingNoWildcards.ps1
36+
Describe 'Verify Path Processing for NO Wildcards Allowed Impl' {
2737
It 'Processes non-wildcard absolute path via -Path param' {
2838
Import-FileNoWildcard -Path $PSScriptRoot\Readme.md | Should Be "$PSScriptRoot\README.md"
2939
}
3040
It 'Processes multiple absolute paths via -Path param' {
31-
Import-FileNoWildcard -Path $PSScriptRoot\Readme.md, $PSScriptRoot\PathProcessingWildcards.ps1 |
41+
Import-FileNoWildcard -Path $PSScriptRoot\Readme.md, $PSScriptRoot\PathProcessingWildcards.ps1 |
3242
Should Be @("$PSScriptRoot\README.md", "$PSScriptRoot\PathProcessingWildcards.ps1")
33-
}
43+
}
3444
It 'Processes relative path via -Path param' {
3545
Import-FileNoWildcard -Path ..\examples\README.md | Should Be "$PSScriptRoot\README.md"
3646
}
3747
It 'Processes multiple relative path via -Path param' {
38-
Import-FileNoWildcard -Path ..\examples\README.md, .vscode\launch.json |
48+
Import-FileNoWildcard -Path ..\examples\README.md, .vscode\launch.json |
3949
Should Be @("$PSScriptRoot\README.md", "$PSScriptRoot\.vscode\launch.json")
4050
}
41-
51+
4252
It 'Should accept pipeline input to Path' {
4353
Get-ChildItem -LiteralPath "$pwd\foo[1].txt" | Import-FileNoWildcard | Should Be "$PSScriptRoot\foo[1].txt"
44-
}
54+
}
4555
}
4656

47-
. $PSScriptRoot\PathProcessingWildcards.ps1
48-
Describe 'Verify Path Processing for Wildcards Allowed Impl' {
57+
. $PSScriptRoot\PathProcessingWildcards.ps1
58+
Describe 'Verify Path Processing for Wildcards Allowed Impl' {
4959
It 'Processes non-wildcard absolute path via -Path param' {
5060
Import-FileWildcard -Path $PSScriptRoot\Readme.md | Should Be "$PSScriptRoot\README.md"
5161
}
5262
It 'Processes multiple absolute paths via -Path param' {
53-
Import-FileWildcard -Path $PSScriptRoot\Readme.md, $PSScriptRoot\PathProcessingWildcards.ps1 |
63+
Import-FileWildcard -Path $PSScriptRoot\Readme.md, $PSScriptRoot\PathProcessingWildcards.ps1 |
5464
Should Be @("$PSScriptRoot\README.md", "$PSScriptRoot\PathProcessingWildcards.ps1")
55-
}
65+
}
5666
It 'Processes wildcard absolute path via -Path param' {
5767
Import-FileWildcard -Path $PSScriptRoot\*.md | Should Be "$PSScriptRoot\README.md"
5868
}
@@ -63,26 +73,26 @@ Describe 'Verify Path Processing for Wildcards Allowed Impl' {
6373
Import-FileWildcard -Path ..\examples\README.md | Should Be "$PSScriptRoot\README.md"
6474
}
6575
It 'Processes multiple relative path via -Path param' {
66-
Import-FileWildcard -Path ..\examples\README.md, .vscode\launch.json |
76+
Import-FileWildcard -Path ..\examples\README.md, .vscode\launch.json |
6777
Should Be @("$PSScriptRoot\README.md", "$PSScriptRoot\.vscode\launch.json")
6878
}
69-
79+
7080
It 'DefaultParameterSet should be Path' {
7181
Import-FileWildcard *.md | Should Be "$PSScriptRoot\README.md"
7282
}
73-
83+
7484
It 'Should process absolute literal paths via -LiteralPath param'{
7585
Import-FileWildcard -LiteralPath "$PSScriptRoot\foo[1].txt" | Should Be "$PSScriptRoot\foo[1].txt"
7686
}
7787
It 'Should process relative literal paths via -LiteralPath param'{
7888
Import-FileWildcard -LiteralPath "..\examples\foo[1].txt" | Should Be "$PSScriptRoot\foo[1].txt"
7989
}
8090
It 'Should process multiple literal paths via -LiteralPath param'{
81-
Import-FileWildcard -LiteralPath "..\examples\foo[1].txt", "$PSScriptRoot\README.md" |
91+
Import-FileWildcard -LiteralPath "..\examples\foo[1].txt", "$PSScriptRoot\README.md" |
8292
Should Be @("$PSScriptRoot\foo[1].txt", "$PSScriptRoot\README.md")
8393
}
84-
94+
8595
It 'Should accept pipeline input to LiteralPath' {
8696
Get-ChildItem -LiteralPath "$pwd\foo[1].txt" | Import-FileWildcard | Should Be "$PSScriptRoot\foo[1].txt"
87-
}
97+
}
8898
}

0 commit comments

Comments
 (0)