forked from dotnet/sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sdktests.ps1
73 lines (61 loc) · 1.37 KB
/
sdktests.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
[CmdletBinding(PositionalBinding=$false)]
Param(
[switch] $install,
[switch] $uninstall,
[switch] $run,
[string] $packageVersion = "",
[string] $tests = "",
[Parameter(ValueFromRemainingArguments=$true)][String[]]$additionalRunParams
)
Set-StrictMode -Version 2.0
$ErrorActionPreference = "Stop"
$lkgPackageVersion = "2.1.400-preview-63001-03"
if ($packageVersion -eq "")
{
$packageVersion = $lkgPackageVersion
}
$testNames = @()
if ($tests -eq "")
{
$testNames = "Build", "Clean", "Pack", "Perf", "Publish", "Rebuild", "Restore", "ToolPack"
}
else
{
$testNames = $tests.split(",")
}
if ($uninstall)
{
foreach ( $name in $testNames )
{
dotnet tool uninstall -g "testSdk$name"
}
}
if ($install)
{
foreach ( $name in $testNames )
{
dotnet tool install -g "testSdk$name" --version $packageVersion --add-source https://dotnet.myget.org/F/dotnet-cli/api/v3/index.json
}
}
if ($run)
{
$failedTests = @()
foreach ( $name in $testNames )
{
$cmd = "testSdk$name"
& $cmd -xml ($name + "results.xml") $additionalRunParams
if ($LASTEXITCODE -ne 0)
{
$failedTests += $name
}
}
if (@($failedTests).Count -gt 0)
{
Write-Error "Tests failed: $failedTests"
Exit 1
}
else
{
Write-Output "Tests passed"
}
}