Skip to content

Commit 8100720

Browse files
committed
Quality of life improvements
1 parent ae2017f commit 8100720

File tree

4 files changed

+46
-8
lines changed

4 files changed

+46
-8
lines changed

src/Components/WebAssembly/Build/test/BuildIntegrationTests/MSBuildProcessManager.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public static async Task<MSBuildResult> RunProcessAsync(
6060
// Suppresses the 'Welcome to .NET Core!' output that times out tests and causes locked file issues.
6161
// When using dotnet we're not guarunteed to run in an environment where the dotnet.exe has had its first run experience already invoked.
6262
processStartInfo.EnvironmentVariables["DOTNET_SKIP_FIRST_TIME_EXPERIENCE"] = "true";
63+
processStartInfo.EnvironmentVariables["_BlazorWebAssemblyBuildTest_BrotliCompressionLevel_NoCompression"] = "1";
6364

6465
var processResult = await RunProcessCoreAsync(processStartInfo, timeout);
6566

src/Components/WebAssembly/Compression/src/Program.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,13 @@ static async Task<int> Main(string[] args)
5454

5555
using var sourceStream = File.OpenRead(inputPath);
5656
using var fileStream = new FileStream(targetCompressionPath, FileMode.Create);
57-
using var stream = new BrotliStream(fileStream, CompressionLevel.Optimal);
57+
58+
var compressionLevel = CompressionLevel.Optimal;
59+
if (Environment.GetEnvironmentVariable("_BlazorWebAssemblyBuildTest_BrotliCompressionLevel_NoCompression") == "1")
60+
{
61+
compressionLevel = CompressionLevel.NoCompression;
62+
}
63+
using var stream = new BrotliStream(fileStream, compressionLevel);
5864

5965
sourceStream.CopyTo(stream);
6066
}

src/Shared/E2ETesting/BrowserFixture.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public async Task DisposeAsync()
6767
var browsers = await Task.WhenAll(_browsers.Values);
6868
foreach (var (browser, log) in browsers)
6969
{
70-
browser.Dispose();
70+
browser?.Dispose();
7171
}
7272

7373
await DeleteBrowserUserProfileDirectoriesAsync();
@@ -163,6 +163,7 @@ private async Task DeleteBrowserUserProfileDirectoriesAsync()
163163

164164
var attempt = 0;
165165
const int maxAttempts = 3;
166+
Exception innerException;
166167
do
167168
{
168169
try
@@ -189,13 +190,14 @@ private async Task DeleteBrowserUserProfileDirectoriesAsync()
189190
catch (Exception ex)
190191
{
191192
output.WriteLine($"Error initializing RemoteWebDriver: {ex.Message}");
193+
innerException = ex;
192194
}
193195

194196
attempt++;
195197

196198
} while (attempt < maxAttempts);
197199

198-
throw new InvalidOperationException("Couldn't create a Selenium remote driver client. The server is irresponsive");
200+
throw new InvalidOperationException("Couldn't create a Selenium remote driver client. The server is irresponsive", innerException);
199201
}
200202

201203
private string UserProfileDirectory(string context)

src/Shared/E2ETesting/BrowserTestBase.cs

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

4+
using System;
5+
using System.Runtime.ExceptionServices;
46
using System.Threading;
57
using System.Threading.Tasks;
68
using OpenQA.Selenium;
@@ -16,13 +18,32 @@ public class BrowserTestBase : IClassFixture<BrowserFixture>, IAsyncLifetime
1618
private static readonly AsyncLocal<ILogs> _logs = new AsyncLocal<ILogs>();
1719
private static readonly AsyncLocal<ITestOutputHelper> _output = new AsyncLocal<ITestOutputHelper>();
1820

21+
private ExceptionDispatchInfo _exceptionDispatchInfo;
22+
private IWebDriver _browser;
23+
1924
public BrowserTestBase(BrowserFixture browserFixture, ITestOutputHelper output)
2025
{
2126
BrowserFixture = browserFixture;
2227
_output.Value = output;
2328
}
2429

25-
public IWebDriver Browser { get; set; }
30+
public IWebDriver Browser
31+
{
32+
get
33+
{
34+
if (_exceptionDispatchInfo != null)
35+
{
36+
_exceptionDispatchInfo.Throw();
37+
throw _exceptionDispatchInfo.SourceException;
38+
}
39+
40+
return _browser;
41+
}
42+
set
43+
{
44+
_browser = value;
45+
}
46+
}
2647

2748
public static IWebDriver BrowserAccessor => _asyncBrowser.Value;
2849

@@ -55,11 +76,19 @@ protected virtual void InitializeAsyncCore()
5576

5677
protected async Task InitializeBrowser(string isolationContext)
5778
{
58-
var (browser, logs) = await BrowserFixture.GetOrCreateBrowserAsync(Output, isolationContext);
59-
_asyncBrowser.Value = browser;
60-
_logs.Value = logs;
79+
try
80+
{
81+
var (browser, logs) = await BrowserFixture.GetOrCreateBrowserAsync(Output, isolationContext);
82+
_asyncBrowser.Value = browser;
83+
_logs.Value = logs;
6184

62-
Browser = browser;
85+
Browser = browser;
86+
}
87+
catch (Exception ex)
88+
{
89+
_exceptionDispatchInfo = ExceptionDispatchInfo.Capture(ex);
90+
throw;
91+
}
6392
}
6493
}
6594
}

0 commit comments

Comments
 (0)