forked from nightroman/PowerShellTraps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.test.ps1
26 lines (20 loc) · 796 Bytes
/
.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
if ($env:GITHUB_ACTION) {return task GITHUB_ACTION}
$Major = $PSVersionTable.PSVersion.Major
if ($Major -ge 6) {return task SKIP_CORE}
$NET_20 = Test-Path 'HKLM:\Software\Microsoft\NET Framework Setup\NDP\v2.0.50727'
task Test.1.works.in.any.host {
($r = .\Test.1.works.in.any.host.ps1)
equals 42 $r
}
task Test.2.works.in.ConsoleHost -If ($NET_20 -and $Host.Name -eq 'ConsoleHost') {
($r = .\Test.2.works.in.ConsoleHost.ps1)
equals 42 $r
}
task Test.3.fails.in.DefaultHost -If ($NET_20) {
($r = .\Test.3.fails.in.DefaultHost.ps1)
assert ((-join $r).Contains('ObjectNotFound: (-Version:String) [], CommandNotFoundException'))
}
task Test.4.fails.in.PowerShell.job {
($r = try {.\Test.4.fails.in.PowerShell.job.ps1} catch {$_})
equals $r.FullyQualifiedErrorId 'NativeCommandError'
}