-
Notifications
You must be signed in to change notification settings - Fork 4.1k
/
test-build-correctness.ps1
98 lines (81 loc) · 3.5 KB
/
test-build-correctness.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
<#
This script drives the Jenkins verification that our build is correct. In particular:
- Our build has no double writes
- Our project.json files are consistent
- Our build files are well structured
- Our solution states are consistent
- Our generated files are consistent
#>
[CmdletBinding(PositionalBinding=$false)]
param(
[string]$configuration = "Debug",
[switch]$enableDumps = $false,
[switch]$help)
Set-StrictMode -version 2.0
$ErrorActionPreference="Stop"
function Print-Usage() {
Write-Host "Usage: test-build-correctness.ps1"
Write-Host " -configuration Build configuration ('Debug' or 'Release')"
}
try {
if ($help) {
Print-Usage
exit 0
}
$ci = $true
. (Join-Path $PSScriptRoot "build-utils.ps1")
Push-Location $RepoRoot
if ($enableDumps) {
$key = "HKLM:\\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps"
New-Item -Path $key -ErrorAction SilentlyContinue
New-ItemProperty -Path $key -Name 'DumpType' -PropertyType 'DWord' -Value 2 -Force
New-ItemProperty -Path $key -Name 'DumpCount' -PropertyType 'DWord' -Value 2 -Force
New-ItemProperty -Path $key -Name 'DumpFolder' -PropertyType 'String' -Value $LogDir -Force
}
# Verify no PROTOTYPE marker left in main
if ($env:SYSTEM_PULLREQUEST_TARGETBRANCH -eq "main") {
Write-Host "Checking no PROTOTYPE markers in source"
$prototypes = Get-ChildItem -Path src, eng, scripts -Exclude *.dll,*.exe,*.pdb,*.xlf,test-build-correctness.ps1 -Recurse | Select-String -Pattern 'PROTOTYPE' -CaseSensitive -SimpleMatch
if ($prototypes) {
Write-Host "Found PROTOTYPE markers in source:"
Write-Host $prototypes
throw "PROTOTYPE markers disallowed in compiler source"
}
}
# Verify no TODO2 marker left
$prototypes = Get-ChildItem -Path src, eng, scripts -Exclude *.dll,*.exe,*.pdb,*.xlf,test-build-correctness.ps1 -Recurse | Select-String -Pattern 'TODO2' -CaseSensitive -SimpleMatch
if ($prototypes) {
Write-Host "Found TODO2 markers in source:"
Write-Host $prototypes
throw "TODO2 markers disallowed in compiler source"
}
Write-Host "Building Roslyn"
Exec-Block { & (Join-Path $PSScriptRoot "build.ps1") -restore -build -bootstrap -bootstrapConfiguration:Debug -ci:$ci -runAnalyzers:$true -configuration:$configuration -pack -binaryLog -useGlobalNuGetCache:$false -warnAsError:$true -properties "/p:RoslynEnforceCodeStyle=true"}
Subst-TempDir
# Verify the state of our various build artifacts
Write-Host "Running BuildBoss"
$buildBossPath = GetProjectOutputBinary "BuildBoss.exe"
Exec-Console $buildBossPath "-r `"$RepoRoot/`" -c $configuration" -p Roslyn.sln
Write-Host ""
# Verify the state of our generated syntax files
Write-Host "Checking generated compiler files"
Exec-Block { & (Join-Path $PSScriptRoot "generate-compiler-code.ps1") -test -configuration:$configuration }
Exec-Console dotnet "tool run dotnet-format . --include-generated --include src/Compilers/CSharp/Portable/Generated/ src/Compilers/VisualBasic/Portable/Generated/ src/ExpressionEvaluator/VisualBasic/Source/ResultProvider/Generated/ --check -f"
Write-Host ""
exit 0
}
catch [exception] {
Write-Host $_
Write-Host $_.Exception
exit 1
}
finally {
if ($enableDumps) {
$key = "HKLM:\\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps"
Remove-ItemProperty -Path $key -Name 'DumpType'
Remove-ItemProperty -Path $key -Name 'DumpCount'
Remove-ItemProperty -Path $key -Name 'DumpFolder'
}
Unsubst-TempDir
Pop-Location
}