1
0
Форкнуть 0

Powershell script to run unit tests during the build

This commit is contained in:
Sergei Nikitin 2015-05-21 16:28:12 -07:00
Родитель f8d71fc49d
Коммит 9d776dd47d
2 изменённых файлов: 36 добавлений и 4 удалений

Просмотреть файл

@ -11,7 +11,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
global.json = global.json
NuGet.config = NuGet.config
Readme.md = Readme.md
RunTests.cmd = RunTests.cmd
RunTests.ps1 = RunTests.ps1
EndProjectSection
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.ApplicationInsights.AspNet", "src\Microsoft.ApplicationInsights.AspNet\Microsoft.ApplicationInsights.AspNet.xproj", "{95EC3635-22E4-4C3A-A066-F5823A0648DA}"

Просмотреть файл

@ -15,7 +15,7 @@ Function Execute-Process {
[String]$Arguments
)
$pinfo = New-Object System.Diagnostics.ProcessStartInfo
$pinfo = New-Object System.Diagnostics.ProcessStartInfo;
$pinfo.FileName = $dnxPath;
$pinfo.RedirectStandardError = $true;
$pinfo.RedirectStandardOutput = $true;
@ -30,14 +30,46 @@ Function Execute-Process {
Return $p.StandardOutput.ReadToEnd();
}
Function Get-OutputSummary {
Param (
[String]$Data
)
If ($Data -match '\W*Errors:\W*(?<Errors>\d+),\W*Failed:\W*(?<Failed>\d+)') {
Return New-Object PSObject -Property @{
Errors = [int]$matches['Errors'];
Failed = [int]$matches['Failed'];
};
} Else {
Throw "Input string is not wellformet to extract summary data";
}
}
[PSObject[]]$global:failed = @();
$DnxRuntimes |% {
$dnxPath = "%USERPROFILE%\.dnx\runtimes\$($_)\bin\dnx.exe";
$dnxPath = [System.Environment]::ExpandEnvironmentVariables($dnxPath);
$TestProjects |% {
[String]$arguments = "$_ test -nologo -diagnostics";
[String]$Out = Execute-Process $dnxPath $arguments;
Write-Host $Out;
Write-Host "=========================================================";
Write-Host "== Executing tests";
Write-Host "== Working Folder: $((pwd).Path)";
Write-Host "== Runtime:$dnxPath";
Write-Host "== Args:$arguments";
Write-Host "=========================================================";
[String]$out = Execute-Process $dnxPath $arguments;
Write-Host $out;
$summary = Get-OutputSummary $Out;
If (($summary.Failed -ne 0) -or ($summary.Errors -ne 0)){
$global:failed += $summary;
}
}
}
If ($global:failed.Count -gt 0){
Throw "Test execution failed";
}