forked from nightroman/PowerShellTraps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.test.ps1
42 lines (38 loc) · 1.03 KB
/
.test.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
if ($env:GITHUB_ACTION) {return task GITHUB_ACTION}
$Version = $PSVersionTable.PSVersion.Major
task Test-Command-syntax {
($r = .\Test-Command-syntax.ps1 | Out-String)
if ($Version -ge 7) {
assert ($r.TrimEnd() -clike '*ParserError:*Exit code: 1*')
}
else {
assert ($r.TrimEnd() -clike '*MissingEndCurlyBrace*Exit code: 1')
}
}
task Test-Command-throw {
($r = .\Test-Command-throw.ps1 | Out-String)
assert ($r.TrimEnd() -clike '*Some error.*Exit code: 1')
}
# fixed in v5
task Test-File-syntax {
($r = .\Test-File-syntax.ps1 | Out-String)
if ($Version -ge 7) {
assert ($r.TrimEnd() -clike '*ParserError:*Exit code: 1*')
}
elseif ($Version -ge 5) {
assert ($r.TrimEnd() -clike '*MissingEndCurlyBrace*Exit code: 1')
}
else {
assert ($r.TrimEnd() -clike '*MissingEndCurlyBrace*Exit code: 0')
}
}
# fixed in v5
task Test-File-throw {
($r = .\Test-File-throw.ps1 | Out-String)
if ($Version -ge 5) {
assert ($r.TrimEnd() -clike '*Some error.*Exit code: 1')
}
else {
assert ($r.TrimEnd() -clike '*Some error.*Exit code: 0')
}
}