Files

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

139 lines
3.2 KiB
PowerShell
Raw Permalink Normal View History

2016-09-12 14:54:57 -07:00
<#
.SYNOPSIS
Build and run unit-tests and functional tests.
.PARAMETER Configuration
Build configuration (debug by default)
.PARAMETER ReleaseLabel
Release label to use for package and assemblies versioning (zlocal by default)
.PARAMETER BuildNumber
Build number to use for package and assemblies versioning (auto-generated if not provided)
.PARAMETER SkipCore
2016-09-12 14:54:57 -07:00
Skips running NuGet.Core.Tests and NuGet.Core.FuncTests
.PARAMETER CI
Indicates the build script is invoked from CI
2016-11-08 11:08:25 -08:00
.NOTES
Some of the functional tests including NuGet server ecosystem will fail outside of Microsoft corpnet.
2016-09-12 14:54:57 -07:00
.EXAMPLE
.\runTests.ps1 -Verbose
2016-11-08 11:08:25 -08:00
Running full test suite
2016-09-12 14:54:57 -07:00
2016-11-08 11:08:25 -08:00
.EXAMPLE
2016-09-12 14:54:57 -07:00
.\runTests.ps1 -sut
2016-11-08 11:08:25 -08:00
Running functional tests only
2016-09-12 14:54:57 -07:00
2016-11-08 11:08:25 -08:00
.EXAMPLE
2016-09-12 14:54:57 -07:00
.\runTests.ps1 -sft -s14 -s15
2016-11-08 11:08:25 -08:00
Running core unit tests only
2016-09-12 14:54:57 -07:00
#>
[CmdletBinding()]
param (
2017-07-07 12:51:20 -07:00
[ValidateSet('debug', 'release')]
2016-09-12 14:54:57 -07:00
[Alias('c')]
[string]$Configuration,
2017-07-07 12:51:20 -07:00
[ValidatePattern('^(beta|final|preview|rc|release|rtm|xprivate|zlocal)([0-9]*)$')]
[Alias('l')]
[string]$ReleaseLabel = 'zlocal',
[Alias('n')]
[int]$BuildNumber,
[Alias('sb')]
[switch]$SkipBuild,
[Alias('sc')]
[switch]$SkipCore,
2016-09-12 14:54:57 -07:00
[switch]$CI
)
. "$PSScriptRoot\build\common.ps1"
if (-not $Configuration) {
$Configuration = switch ($CI.IsPresent) {
$True { 'Release' } # CI build is Release by default
$False { 'Debug' } # Local builds are Debug by default
}
}
Write-Host ("`r`n" * 3)
Trace-Log ('=' * 60)
$startTime = [DateTime]::UtcNow
$pBuildNumber =""
if ($BuildNumber) {
$pBuildNumber = "/p:BuildNumber=$BuildNumber"
2016-09-12 14:54:57 -07:00
}
Invoke-BuildStep 'Installing .NET CLI for tests' {
Install-DotnetCLI -Force:$Force
} -ev +BuildErrors
2016-09-12 14:54:57 -07:00
Trace-Log "Test suite run #$BuildNumber started at $startTime"
Test-BuildEnvironment -CI:$CI
$MSBuildExe = Get-MSBuildExe
if(-not $MSBuildExe){
Warning-Log "The build is requested, but no MSBuild is available"
2018-12-27 16:41:46 -08:00
exit 1
2016-09-12 14:54:57 -07:00
}
$BuildErrors = @()
2016-10-11 07:24:54 -07:00
Invoke-BuildStep 'Cleaning package cache' {
Clear-PackageCache
} `
-skip:(-not $CI) `
2016-10-11 07:24:54 -07:00
-ev +BuildErrors
2019-05-02 20:55:21 -07:00
Invoke-BuildStep 'Running /t:RestoreVS' {
2016-09-12 14:54:57 -07:00
& $MSBuildExe build\build.proj /t:RestoreVS /p:Configuration=$Configuration /p:ReleaseLabel=$ReleaseLabel $pBuildNumber /v:m /m:1
if (-not $?)
{
Write-Error "Restore failed!"
exit 1
}
} `
-ev +BuildErrors
2016-09-12 14:54:57 -07:00
Invoke-BuildStep 'Running /t:CoreFuncTests' {
2016-09-12 14:54:57 -07:00
& $MSBuildExe build\build.proj /t:CoreFuncTests /p:Configuration=$Configuration /p:ReleaseLabel=$ReleaseLabel $pBuildNumber /v:m /m:1
2016-09-12 14:54:57 -07:00
if (-not $?)
{
Write-Error "CoreFuncTests failed!"
exit 1
}
} `
-ev +BuildErrors
Invoke-BuildStep 'Cleaning package cache' {
Clear-PackageCache
} `
-skip:(-not $CI) `
-ev +BuildErrors
2016-09-12 14:54:57 -07:00
Trace-Log ('-' * 60)
## Calculating Build time
$endTime = [DateTime]::UtcNow
Trace-Log "Test suite run has completed at $endTime"
Trace-Log "Time elapsed $(Format-ElapsedTime ($endTime - $startTime))"
Trace-Log ('=' * 60)
if ($BuildErrors) {
$ErrorLines = $BuildErrors | %{ ">>> $($_.Exception.Message)" }
Write-Error "Build's completed with $($BuildErrors.Count) error(s):`r`n$($ErrorLines -join "`r`n")" -ErrorAction Stop
}
2016-10-11 07:24:54 -07:00
2016-09-12 14:54:57 -07:00
Write-Host ("`r`n" * 3)