forked from NuGet/NuGet.Client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunTests.ps1
161 lines (127 loc) · 4.49 KB
/
runTests.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<#
.SYNOPSIS
Build and run unit-tests and functional tests.
.PARAMETER Configuration
Build configuration (debug by default)
.PARAMETER SkipXProj
Skips running NuGet.Core.Tests and NuGet.Core.FuncTests
.PARAMETER SkipVS14
Skips running NuGet.Clients.Tests and NuGet.Clients.FuncTests with VS14 toolset
.PARAMETER SkipVS15
Skips running NuGet.Clients.Tests and NuGet.Clients.FuncTests with VS15 toolset
.PARAMETER SkipUnitTests
Skips running NuGet.Core.Tests and NuGet.Clients.Tests
.PARAMETER SkipFuncTests
Skips running NuGet.Core.FuncTests and NuGet.Clients.FuncTests
.PARAMETER CI
Indicates the build script is invoked from CI
.EXAMPLE
Running full test suite:
.\runTests.ps1 -Verbose
Running functional tests only:
.\runTests.ps1 -sut
Running core unit tests only:
.\runTests.ps1 -sft -s14 -s15
#>
[CmdletBinding()]
param (
[ValidateSet("debug", "release")]
[Alias('c')]
[string]$Configuration,
[Alias('sx')]
[switch]$SkipXProj,
[Alias('s14')]
[switch]$SkipVS14,
[Alias('s15')]
[switch]$SkipVS15,
[Alias('sut')]
[switch]$SkipUnitTests,
[Alias('sft')]
[switch]$SkipFuncTests,
[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
if (-not $BuildNumber) {
$BuildNumber = Get-BuildNumber
}
Trace-Log "Test suite run #$BuildNumber started at $startTime"
Test-BuildEnvironment -CI:$CI
# Adjust version skipping if only one version installed - if VS15 is not installed, no need to specify SkipVS15
if (-not $SkipVS14 -and -not $VS14Installed) {
Warning-Log "VS14 build is requested but it appears not to be installed."
$SkipVS14 = $True
}
if (-not $SkipVS15 -and -not $VS15Installed) {
Warning-Log "VS15 build is requested but it appears not to be installed."
$SkipVS15 = $True
}
$BuildErrors = @()
Invoke-BuildStep 'Cleaning package cache' {
Clear-PackageCache
} `
-ev +BuildErrors
Invoke-BuildStep 'Running NuGet.Core unit-tests' {
Test-CoreProjects $Configuration
} `
-skip:($SkipXProj -or $SkipUnitTests) `
-ev +BuildErrors
Invoke-BuildStep 'Running NuGet.Core functional tests' {
Test-FuncCoreProjects $Configuration
} `
-skip:($SkipXProj -or $SkipFuncTests) `
-ev +BuildErrors
Invoke-BuildStep 'Building NuGet.Clients projects - VS14 Toolset' {
Build-ClientsProjects $Configuration $DefaultReleaseLabel $BuildNumber -ToolsetVersion 14
} `
-skip:$SkipVS14 `
-ev +BuildErrors
Invoke-BuildStep 'Running NuGet.Clients unit-tests - VS14 Toolset' {
Test-ClientsProjects $Configuration -ToolsetVersion 14
} `
-skip:($SkipVS14 -or $SkipUnitTests) `
-ev +BuildErrors
Invoke-BuildStep 'Running NuGet.Clients functional tests - VS14 Toolset' {
Test-FuncClientsProjects $Configuration -ToolsetVersion 14
} `
-skip:($SkipVS14 -or $SkipFuncTests) `
-ev +BuildErrors
Invoke-BuildStep 'Building NuGet.Clients projects - VS15 Toolset' {
Build-ClientsProjects $Configuration $DefaultReleaseLabel $BuildNumber -ToolsetVersion 15
} `
-skip:$SkipVS15 `
-ev +BuildErrors
Invoke-BuildStep 'Running NuGet.Clients tests - VS15 Toolset' {
# We don't run command line tests on VS15 as we don't build a nuget.exe for this version
Test-ClientsProjects $Configuration -ToolsetVersion 15 -SkipProjects 'NuGet.CommandLine.Test'
} `
-skip:($SkipVS15 -or $SkipUnitTests) `
-ev +BuildErrors
Invoke-BuildStep 'Running NuGet.Clients functional tests - VS15 Toolset' {
# We don't run command line tests on VS15 as we don't build a nuget.exe for this version
Test-FuncClientsProjects $Configuration -ToolsetVersion 15 -SkipProjects 'NuGet.CommandLine.FuncTest'
} `
-skip:($SkipVS15 -or $SkipFuncTests) `
-ev +BuildErrors
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
}
Invoke-BuildStep 'Cleaning package cache' {
Clear-PackageCache
}
Write-Host ("`r`n" * 3)