forked from OData/odata.net
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PerformanceBuild.ps1
82 lines (70 loc) · 2.7 KB
/
PerformanceBuild.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
Param
(
[String]
$Config = "Debug"
)
If("Debug","Release" -notcontains $Config)
{
Write-Host "Usage: Performancebuild.ps1 -Config Debug|Release" -ForegroundColor Red
exit
}
$ProgramFilesX86 = [Environment]::GetFolderPath("ProgramFilesX86")
$EnlistmentRoot = Split-Path -Parent $MyInvocation.MyCommand.Definition
$LogDir = $EnlistmentRoot + "\bin"
$Msbuild= $ProgramFilesX86 + "\MSBuild\12.0\Bin\MSBuild.exe"
$TestDir = $EnlistmentRoot + "\bin\AnyCPU\$Config\Test\Desktop\Performance\bin"
$PackagesPath = $EnlistmentRoot + "\sln\packages\"
$Item = Get-ChildItem -Filter xunit.performance.run.exe -Recurse -path $PackagesPath
$PerfRunPath = $Item.FullName
$Item = Get-ChildItem -Filter xunit.performance.analysis.exe -Recurse -path $PackagesPath
$PerfAnalysisPath = $Item.FullName
$Item = Get-ChildItem -Filter xunit.console.exe -Recurse -path $PackagesPath
$XunitConsoleRunnerPath = $Item.FullName
Function RunBuild ($sln, $type, $conf)
{
Write-Host "*** Building $sln ***"
$slnpath = $EnlistmentRoot + "\sln\$sln"
& $Msbuild $slnpath /t:rebuild /m /nr:false /fl "/p:Platform=Any CPU" /p:Configuration=$conf /p:Desktop=true /flp:LogFile=$LogDir/msbuild.log /flp:Verbosity=Normal 1>$null
if($LASTEXITCODE -eq 0)
{
Write-Host "Build $sln SUCCESS" -ForegroundColor Green
write-host "`n"
}
else
{
Write-Host "Build $sln FAILED" -ForegroundColor Red
Write-Host "For more information, please open the following test result files:"
Write-Host "$LogDir\msbuild.log"
exit
}
}
Function ExecuteTests
{
Param(
[string]$testFolder,
[string]$perfRunPath,
[string]$perfAnalysisPath,
[string]$xunitConsoleRunnerPath
)
$location = Get-Location
Set-Location $testFolder
$testDlls = Get-ChildItem -Filter Microsoft.OData.Performance.*.Tests.dll
$time = Get-Date -Format yyyyMMdd.hhmmss
foreach ($dll in $testDlls)
{
$dllName = $dll.Name;
Write-Host "*** Run test for $dllName ***"
$rawName = $dllName.Replace("Microsoft.OData.Performance.","")
$rawName = $rawName.Replace(".Tests.dll", "")
$runid = $rawName + "." + $time
$result = $runid + ".xml"
$analysisResult = $runid + ".analysisResult.xml"
$resultPath = $testfolder + "\" + $analysisResult
&$perfRunPath $dll.Name -runner $xunitConsoleRunnerPath -runnerargs "-parallel none" -runid $runid
&$perfAnalysisPath $result -xml $analysisResult
Write-Host "See result for $dllName in $resultPath"
}
Set-Location $location
}
RunBuild 'OData.Tests.Performance.sln' $TestType $Config
ExecuteTests $TestDir $PerfRunPath $PerfAnalysisPath $XunitConsoleRunnerPath