forked from gzepeda/ApplicationInsights-aspnetcore
-
Notifications
You must be signed in to change notification settings - Fork 1
/
RunTestsCore.ps1
53 lines (45 loc) · 1.49 KB
/
RunTestsCore.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
#enable verbose mode
$VerbosePreference = "Continue";
$TestProjects = @(
'.\test\Microsoft.ApplicationInsights.AspNetCore.Tests',
'.\test\MVCFramework45.FunctionalTests',
'.\test\WebApiShimFw46.FunctionalTests'
)
Function Execute-DotnetProcess {
Param (
[Parameter(Mandatory=$True)]
[String]$RuntimePath,
[Parameter(Mandatory=$True)]
[String]$Arguments,
[Parameter(Mandatory=$True)]
[String]$WorkingDirectory
)
$p = Start-Process $RuntimePath $Arguments -PassThru -NoNewWindow -Wait;
Write-Host "Process executed, ExitCode:$($p.ExitCode)";
Write-Host "Output:";
Write-Host $p.StandardOutput;
If ($p.ExitCode -ne 0) {
$global:failed += $executeResult;
}
}
[PSObject[]]$global:failed = @();
$global:WorkingDirectory = (pwd).Path;
$dotnetPath = "C:\Program Files\dotnet\dotnet.exe";
$TestProjects |% {
[String]$arguments = "test";
[String]$currentWorkingDirectory = Join-Path $global:WorkingDirectory -ChildPath $_;
Write-Host "=========================================================";
Write-Host "== Executing tests";
Write-Host "== Working Folder: $currentWorkingDirectory";
Write-Host "== Runtime:$dotnetPath";
Write-Host "== Args:$arguments";
Write-Host "=========================================================";
Set-Location -Path $currentWorkingDirectory;
$executeResult = Execute-DotnetProcess `
-RuntimePath $dotnetPath `
-Arguments $arguments `
-WorkingDirectory $currentWorkingDirectory;
}
If ($global:failed.Count -gt 0) {
Throw "Test execution failed";
}