-
Notifications
You must be signed in to change notification settings - Fork 401
/
test.ps1
94 lines (80 loc) · 2.99 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
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
param([string]$buildType="Debug", [string]$dotnetDir="c:\Program Files\dotnet", [string]$root=$PSScriptRoot, [string]$failBuildOnTest="YES")
################################################# Functions ############################################################
function WriteSectionHeader($sectionName)
{
$startTime = Get-Date -DisplayHint Time
Write-Host ""
Write-Host "============================"
Write-Host $sectionName
Write-Host "Start Time: " $startTime
Write-Host ""
}
function WriteSectionFooter($sectionName)
{
$startTime = Get-Date -DisplayHint Time
Write-Host ""
Write-Host "End Time: " $startTime
Write-Host $sectionName
Write-Host "============================"
Write-Host ""
}
################################################# Functions ############################################################
WriteSectionHeader("runTests.ps1");
Write-Host "buildType: " $buildType;
Write-Host "dotnetDir: " $dotnetDir
Write-Host "root: " $root;
Write-Host "failBuildOnTest: " $failBuildOnTest;
Write-Host "slnFile: " $slnFile;
[xml]$buildConfiguration = Get-Content $PSScriptRoot\buildConfiguration.xml
$dotnetexe = "$dotnetDir\dotnet.exe";
$startTime = Get-Date
Write-Host "Start Time: " $startTime
Write-Host "PSScriptRoot: " $PSScriptRoot;
Write-Host "dotnetexe: " $dotnetexe;
$ErrorActionPreference = "Stop"
$testProjects = $buildConfiguration.SelectNodes("root/projects/test/project")
foreach ($testProject in $testProjects)
{
if ($testProject.test -eq "YES")
{
WriteSectionHeader("Test");
$name = $testProject.name;
Write-Host ">>> Set-Location $root\test\$name"
pushd
Set-Location $root\test\$name
Write-Host ">>> Start-Process -wait -passthru -NoNewWindow $dotnetexe 'test $name.csproj' --filter category!=nonwindowstests --no-build --no-restore -v q -c $buildType"
$p = Start-Process -wait -passthru -NoNewWindow $dotnetexe "test $name.csproj --filter category!=nonwindowstests --no-build --no-restore -v q -c $buildType"
if($p.ExitCode -ne 0)
{
if (!$testExitCode)
{
$failedTestProjects = "$name"
}
else
{
$failedTestProjects = "$failedTestProjects, $name"
}
}
$testExitCode = $p.ExitCode + $testExitCode
popd
WriteSectionFooter("End Test");
}
}
if($testExitCode -ne 0)
{
WriteSectionHeader("==== Test Failures ====");
Write-Host "Failed test projects: $failedTestProjects" -foregroundcolor "DarkRed"
WriteSectionFooter("==== End Test Failures ====");
if($failBuildOnTest -ne "NO")
{
throw "Exiting test run."
}
}
Write-Host "============================"
Write-Host ""
$time = Get-Date
Write-Host "Start Time: " ($startTime);
Write-Host "End Time: " ($time);
Write-Host "Time to runtests: " ($time - $startTime);
Write-Host ""
Write-Host "============================";