Skip to content

Commit

Permalink
Merge pull request #33575 from sharwell/fix-integration-tests
Browse files Browse the repository at this point in the history
Fix integration tests
  • Loading branch information
sharwell committed Mar 1, 2019
2 parents 391f56c + 0486466 commit 2773f5e
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 5 deletions.
27 changes: 27 additions & 0 deletions eng/build-utils.ps1
Expand Up @@ -287,3 +287,30 @@ function Make-BootstrapBuild() {

return $dir
}

Add-Type -AssemblyName 'System.Drawing'
Add-Type -AssemblyName 'System.Windows.Forms'
function Capture-Screenshot($path) {
$width = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Width
$height = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Height

$bitmap = New-Object System.Drawing.Bitmap $width, $height
try {
$graphics = [System.Drawing.Graphics]::FromImage($bitmap)
try {
$graphics.CopyFromScreen( `
[System.Windows.Forms.Screen]::PrimaryScreen.Bounds.X, `
[System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Y, `
0, `
0, `
$bitmap.Size, `
[System.Drawing.CopyPixelOperation]::SourceCopy)
} finally {
$graphics.Dispose()
}

$bitmap.Save($path, [System.Drawing.Imaging.ImageFormat]::Png)
} finally {
$bitmap.Dispose()
}
}
43 changes: 42 additions & 1 deletion eng/build.ps1
Expand Up @@ -370,7 +370,7 @@ function TestUsingOptimizedRunner() {
if ($ci) {
$args += " -xml"
if ($testVsi) {
$args += " -timeout:120"
$args += " -timeout:110"
} else {
$args += " -timeout:65"
}
Expand Down Expand Up @@ -505,6 +505,47 @@ try {
if ($ci) {
List-Processes
Prepare-TempDir

if ($testVsi) {
$screenshotPath = (Join-Path $LogDir "StartingBuild.png")
try {
Capture-Screenshot $screenshotPath
}
catch {
Write-Host "Screenshot failed; attempting to connect to the console"

# Keep the session open so we have a UI to interact with
$quserItems = ((quser $env:USERNAME | select -Skip 1) -split '\s+')
$sessionid = $quserItems[2]
if ($sessionid -eq 'Disc') {
# When the session isn't connected, the third value is 'Disc' instead of the ID
$sessionid = $quserItems[1]
}

if ($quserItems[1] -eq 'console') {
Write-Host "Disconnecting from console before attempting reconnection"
try {
tsdiscon
} catch {
# ignore
}

# Disconnection is asynchronous, so wait a few seconds for it to complete
Start-Sleep -Seconds 3
query user
}

Write-Host "tscon $sessionid /dest:console"
tscon $sessionid /dest:console

# Connection is asynchronous, so wait a few seconds for it to complete
Start-Sleep 3
query user

# Make sure we can capture a screenshot. An exception at this point will fail-fast the build.
Capture-Screenshot $screenshotPath
}
}
}

if ($bootstrap) {
Expand Down
Expand Up @@ -213,8 +213,8 @@ Inherits Attribute
VisualStudio.Editor.Verify.TextContains(@"
Import System;
Public Class CustomAttribute
Inherits Attribute
Public Class CustomAttribute
Inherits Attribute
End Class");
}

Expand Down Expand Up @@ -333,7 +333,7 @@ Inherits Attribute
Import System;
Public Class CustomAttribute
Inherits Attribute
Inherits Attribute
End Class");
}

Expand All @@ -359,7 +359,7 @@ Inherits Attribute
Import System;
Public Class CustomAttribute
Inherits Attribute
Inherits Attribute
End Class");
}
}
Expand Down
Expand Up @@ -324,6 +324,9 @@ private static Process StartNewVisualStudioProcess(string installationPath, int
// Disable roaming settings to avoid interference from the online user profile
Process.Start(vsRegEditExeFile, $"set \"{installationPath}\" {Settings.Default.VsRootSuffix} HKCU \"ApplicationPrivateSettings\\Microsoft\\VisualStudio\" RoamingEnabled string \"1*System.Boolean*False\"").WaitForExit();

// Disable async completion for 16.0 Preview 3 testing
Process.Start(vsRegEditExeFile, $"set \"{installationPath}\" {Settings.Default.VsRootSuffix} HKCU \"ApplicationPrivateSettings\\WindowManagement\\Options\" UseAsyncCompletion string \"1*System.Int32*-1\"").WaitForExit();

// Disable text editor error reporting because it pops up a dialog. We want to either fail fast in our
// custom handler or fail silently and continue testing.
Process.Start(vsRegEditExeFile, $"set \"{installationPath}\" {Settings.Default.VsRootSuffix} HKCU \"Text Editor\" \"Report Exceptions\" dword 0").WaitForExit();
Expand Down

0 comments on commit 2773f5e

Please sign in to comment.