diff --git a/src/Components/WebAssembly/Build/test/BuildIntegrationTests/MSBuildProcessManager.cs b/src/Components/WebAssembly/Build/test/BuildIntegrationTests/MSBuildProcessManager.cs index c9e5176399..e1ee50af43 100644 --- a/src/Components/WebAssembly/Build/test/BuildIntegrationTests/MSBuildProcessManager.cs +++ b/src/Components/WebAssembly/Build/test/BuildIntegrationTests/MSBuildProcessManager.cs @@ -60,6 +60,7 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Build // Suppresses the 'Welcome to .NET Core!' output that times out tests and causes locked file issues. // When using dotnet we're not guarunteed to run in an environment where the dotnet.exe has had its first run experience already invoked. processStartInfo.EnvironmentVariables["DOTNET_SKIP_FIRST_TIME_EXPERIENCE"] = "true"; + processStartInfo.EnvironmentVariables["_BlazorWebAssemblyBuildTest_BrotliCompressionLevel_NoCompression"] = "1"; var processResult = await RunProcessCoreAsync(processStartInfo, timeout); diff --git a/src/Components/WebAssembly/Compression/src/Program.cs b/src/Components/WebAssembly/Compression/src/Program.cs index 3391e96036..804129166b 100644 --- a/src/Components/WebAssembly/Compression/src/Program.cs +++ b/src/Components/WebAssembly/Compression/src/Program.cs @@ -54,7 +54,13 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Build.BrotliCompression using var sourceStream = File.OpenRead(inputPath); using var fileStream = new FileStream(targetCompressionPath, FileMode.Create); - using var stream = new BrotliStream(fileStream, CompressionLevel.Optimal); + + var compressionLevel = CompressionLevel.Optimal; + if (Environment.GetEnvironmentVariable("_BlazorWebAssemblyBuildTest_BrotliCompressionLevel_NoCompression") == "1") + { + compressionLevel = CompressionLevel.NoCompression; + } + using var stream = new BrotliStream(fileStream, compressionLevel); sourceStream.CopyTo(stream); } diff --git a/src/Shared/E2ETesting/BrowserFixture.cs b/src/Shared/E2ETesting/BrowserFixture.cs index 4ccc5f5aca..1d88020b9a 100644 --- a/src/Shared/E2ETesting/BrowserFixture.cs +++ b/src/Shared/E2ETesting/BrowserFixture.cs @@ -67,7 +67,7 @@ namespace Microsoft.AspNetCore.E2ETesting var browsers = await Task.WhenAll(_browsers.Values); foreach (var (browser, log) in browsers) { - browser.Dispose(); + browser?.Dispose(); } await DeleteBrowserUserProfileDirectoriesAsync(); @@ -163,6 +163,7 @@ namespace Microsoft.AspNetCore.E2ETesting var attempt = 0; const int maxAttempts = 3; + Exception innerException; do { try @@ -189,13 +190,14 @@ namespace Microsoft.AspNetCore.E2ETesting catch (Exception ex) { output.WriteLine($"Error initializing RemoteWebDriver: {ex.Message}"); + innerException = ex; } attempt++; } while (attempt < maxAttempts); - throw new InvalidOperationException("Couldn't create a Selenium remote driver client. The server is irresponsive"); + throw new InvalidOperationException("Couldn't create a Selenium remote driver client. The server is irresponsive", innerException); } private string UserProfileDirectory(string context) diff --git a/src/Shared/E2ETesting/BrowserTestBase.cs b/src/Shared/E2ETesting/BrowserTestBase.cs index aea8b38727..d643074c87 100644 --- a/src/Shared/E2ETesting/BrowserTestBase.cs +++ b/src/Shared/E2ETesting/BrowserTestBase.cs @@ -1,6 +1,8 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System; +using System.Runtime.ExceptionServices; using System.Threading; using System.Threading.Tasks; using OpenQA.Selenium; @@ -16,13 +18,32 @@ namespace Microsoft.AspNetCore.E2ETesting private static readonly AsyncLocal _logs = new AsyncLocal(); private static readonly AsyncLocal _output = new AsyncLocal(); + private ExceptionDispatchInfo _exceptionDispatchInfo; + private IWebDriver _browser; + public BrowserTestBase(BrowserFixture browserFixture, ITestOutputHelper output) { BrowserFixture = browserFixture; _output.Value = output; } - public IWebDriver Browser { get; set; } + public IWebDriver Browser + { + get + { + if (_exceptionDispatchInfo != null) + { + _exceptionDispatchInfo.Throw(); + throw _exceptionDispatchInfo.SourceException; + } + + return _browser; + } + set + { + _browser = value; + } + } public static IWebDriver BrowserAccessor => _asyncBrowser.Value; @@ -55,11 +76,19 @@ namespace Microsoft.AspNetCore.E2ETesting protected async Task InitializeBrowser(string isolationContext) { - var (browser, logs) = await BrowserFixture.GetOrCreateBrowserAsync(Output, isolationContext); - _asyncBrowser.Value = browser; - _logs.Value = logs; + try + { + var (browser, logs) = await BrowserFixture.GetOrCreateBrowserAsync(Output, isolationContext); + _asyncBrowser.Value = browser; + _logs.Value = logs; - Browser = browser; + Browser = browser; + } + catch (Exception ex) + { + _exceptionDispatchInfo = ExceptionDispatchInfo.Capture(ex); + throw; + } } } }