forked from nightroman/PowerShellTraps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.test.ps1
41 lines (34 loc) · 1.21 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
if ($env:GITHUB_ACTION) {return task GITHUB_ACTION}
task Test-1-2-script-scope {
($r = .\Test-1-2-script-scope.ps1)
equals 'Invalid|Invalid|Invalid|Invalid|Invalid' ($r -join '|')
}
task Test-1-3-global-scope {
# v2 gets 10 output lines, v3 gets 5. So get the output as one string and
# test it with patterns (?m)^...
($r = .\Test-1-3-global-scope.ps1 | Out-String)
assert ($r -match '(?m)^ErrorActionPreference:')
assert ($r -match '(?m)^WarningPreference:')
assert ($r -match '(?m)^DebugPreference:')
assert ($r -match '(?m)^VerbosePreference:')
assert ($r -match '(?m)^ProgressPreference:')
}
function Invoke-Script($Path) {
(Invoke-PowerShell -NoProfile -File $Path | Out-String).TrimEnd()
}
task Test-2-1-invalid-error-effect {
($r = Invoke-Script Test-2-1-invalid-error-effect.ps1)
assert ($r -clike 'Test-Preference : Message*Done.')
}
task Test-2-2-invalid-warning-effect {
($r = Invoke-Script Test-2-2-invalid-warning-effect.ps1)
assert ($r -clike '*WARNING: Message*Done.*')
}
task Test-2-3-invalid-debug-effect {
($r = Invoke-Script Test-2-3-invalid-debug-effect.ps1)
equals $r 'Done.'
}
task Test-2-4-invalid-verbose-effect {
($r = Invoke-Script Test-2-4-invalid-verbose-effect.ps1)
equals $r 'Done.'
}