From 7d9e374b8069f726c93738e4133a28ccf93ed97e Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Fri, 22 Feb 2019 18:26:11 -0600 Subject: [PATCH 1/4] Connect to an unlocked interactive session for testing --- eng/build.ps1 | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 79 insertions(+), 1 deletion(-) diff --git a/eng/build.ps1 b/eng/build.ps1 index 40479e05314b3..6863addc2a182 100644 --- a/eng/build.ps1 +++ b/eng/build.ps1 @@ -63,6 +63,33 @@ param ( Set-StrictMode -version 2.0 $ErrorActionPreference = "Stop" +Add-Type -AssemblyName 'System.Drawing' +Add-Type -AssemblyName 'System.Windows.Forms' +function 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() + } +} + function Print-Usage() { Write-Host "Common settings:" Write-Host " -configuration Build configuration: 'Debug' or 'Release' (short: -c)" @@ -370,7 +397,7 @@ function TestUsingOptimizedRunner() { if ($ci) { $args += " -xml" if ($testVsi) { - $args += " -timeout:120" + $args += " -timeout:110" } else { $args += " -timeout:65" } @@ -507,6 +534,57 @@ try { Prepare-TempDir } + if ($ci) { + query user + query session + $currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent()) + $isAdmin = $currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) + Write-Host "Current session is administrator: $isAdmin" + + if ($testVsi) { + $screenshotPath = (Join-Path $LogDir "image.png") + try { + 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') { + $sessionid = $quserItems[1] + } + + if ($quserItems[1] -eq 'console') { + Write-Host "Disconnecting from console before attempting reconnection" + try { + tsdiscon + } catch { + # ignore + } + + $disconnected = $false + for ($iter = 0; ($iter -lt 20) -and (-not $disconnected); $iter++) { + Start-Sleep -Seconds 1 + query user + $quserItems = ((quser $env:USERNAME | select -Skip 1) -split '\s+') + $disconnected = $quserItems[3] -ne 'Active' + } + } + + Write-Host "tscon $sessionid /dest:console" + tscon $sessionid /dest:console + + Start-Sleep 3 + query user + query session + + screenshot $screenshotPath + } + } + } + if ($bootstrap) { $bootstrapDir = Make-BootstrapBuild } From 5e6db3d35c864d8de63633e43404375fe43a040b Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Wed, 27 Feb 2019 14:21:34 -0600 Subject: [PATCH 2/4] Disable async completion for 16.0 Preview 3 testing due to bugs --- .../TestUtilities/VisualStudioInstanceFactory.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/VisualStudio/IntegrationTest/TestUtilities/VisualStudioInstanceFactory.cs b/src/VisualStudio/IntegrationTest/TestUtilities/VisualStudioInstanceFactory.cs index ec70469e4ca7a..cc42d3bbc9365 100644 --- a/src/VisualStudio/IntegrationTest/TestUtilities/VisualStudioInstanceFactory.cs +++ b/src/VisualStudio/IntegrationTest/TestUtilities/VisualStudioInstanceFactory.cs @@ -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(); From 4c24a3ebca96c010c05642c559b32cf79e872a5c Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Thu, 28 Feb 2019 11:41:13 -0600 Subject: [PATCH 3/4] Update expected test results to account for formatting behavior change --- .../IntegrationTests/VisualBasic/BasicRename.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/VisualStudio/IntegrationTest/IntegrationTests/VisualBasic/BasicRename.cs b/src/VisualStudio/IntegrationTest/IntegrationTests/VisualBasic/BasicRename.cs index 36ad941dbce71..72a7260e6fd75 100644 --- a/src/VisualStudio/IntegrationTest/IntegrationTests/VisualBasic/BasicRename.cs +++ b/src/VisualStudio/IntegrationTest/IntegrationTests/VisualBasic/BasicRename.cs @@ -213,8 +213,8 @@ Inherits Attribute VisualStudio.Editor.Verify.TextContains(@" Import System; -Public Class CustomAttribute - Inherits Attribute +Public Class CustomAttribute + Inherits Attribute End Class"); } @@ -333,7 +333,7 @@ Inherits Attribute Import System; Public Class CustomAttribute - Inherits Attribute + Inherits Attribute End Class"); } @@ -359,7 +359,7 @@ Inherits Attribute Import System; Public Class CustomAttribute - Inherits Attribute + Inherits Attribute End Class"); } } From 048646633b75ef6b76be6132848f3642c03765ab Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Fri, 1 Mar 2019 10:59:01 -0600 Subject: [PATCH 4/4] Clean up the build script --- eng/build-utils.ps1 | 27 ++++++++++++++++++++++ eng/build.ps1 | 55 ++++++++------------------------------------- 2 files changed, 36 insertions(+), 46 deletions(-) diff --git a/eng/build-utils.ps1 b/eng/build-utils.ps1 index 0dcf9bdcb5d1b..6d75e98b14307 100644 --- a/eng/build-utils.ps1 +++ b/eng/build-utils.ps1 @@ -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() + } +} diff --git a/eng/build.ps1 b/eng/build.ps1 index 6863addc2a182..9a346142d130f 100644 --- a/eng/build.ps1 +++ b/eng/build.ps1 @@ -63,33 +63,6 @@ param ( Set-StrictMode -version 2.0 $ErrorActionPreference = "Stop" -Add-Type -AssemblyName 'System.Drawing' -Add-Type -AssemblyName 'System.Windows.Forms' -function 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() - } -} - function Print-Usage() { Write-Host "Common settings:" Write-Host " -configuration Build configuration: 'Debug' or 'Release' (short: -c)" @@ -532,19 +505,11 @@ try { if ($ci) { List-Processes Prepare-TempDir - } - - if ($ci) { - query user - query session - $currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent()) - $isAdmin = $currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) - Write-Host "Current session is administrator: $isAdmin" if ($testVsi) { - $screenshotPath = (Join-Path $LogDir "image.png") + $screenshotPath = (Join-Path $LogDir "StartingBuild.png") try { - screenshot $screenshotPath + Capture-Screenshot $screenshotPath } catch { Write-Host "Screenshot failed; attempting to connect to the console" @@ -553,6 +518,7 @@ try { $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] } @@ -564,23 +530,20 @@ try { # ignore } - $disconnected = $false - for ($iter = 0; ($iter -lt 20) -and (-not $disconnected); $iter++) { - Start-Sleep -Seconds 1 - query user - $quserItems = ((quser $env:USERNAME | select -Skip 1) -split '\s+') - $disconnected = $quserItems[3] -ne 'Active' - } + # 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 - query session - screenshot $screenshotPath + # Make sure we can capture a screenshot. An exception at this point will fail-fast the build. + Capture-Screenshot $screenshotPath } } }