Quality of life improvements
This commit is contained in:
parent
ae2017f31e
commit
81007200b5
|
|
@ -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.
|
// 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.
|
// 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["DOTNET_SKIP_FIRST_TIME_EXPERIENCE"] = "true";
|
||||||
|
processStartInfo.EnvironmentVariables["_BlazorWebAssemblyBuildTest_BrotliCompressionLevel_NoCompression"] = "1";
|
||||||
|
|
||||||
var processResult = await RunProcessCoreAsync(processStartInfo, timeout);
|
var processResult = await RunProcessCoreAsync(processStartInfo, timeout);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,13 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Build.BrotliCompression
|
||||||
|
|
||||||
using var sourceStream = File.OpenRead(inputPath);
|
using var sourceStream = File.OpenRead(inputPath);
|
||||||
using var fileStream = new FileStream(targetCompressionPath, FileMode.Create);
|
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);
|
sourceStream.CopyTo(stream);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ namespace Microsoft.AspNetCore.E2ETesting
|
||||||
var browsers = await Task.WhenAll(_browsers.Values);
|
var browsers = await Task.WhenAll(_browsers.Values);
|
||||||
foreach (var (browser, log) in browsers)
|
foreach (var (browser, log) in browsers)
|
||||||
{
|
{
|
||||||
browser.Dispose();
|
browser?.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
await DeleteBrowserUserProfileDirectoriesAsync();
|
await DeleteBrowserUserProfileDirectoriesAsync();
|
||||||
|
|
@ -163,6 +163,7 @@ namespace Microsoft.AspNetCore.E2ETesting
|
||||||
|
|
||||||
var attempt = 0;
|
var attempt = 0;
|
||||||
const int maxAttempts = 3;
|
const int maxAttempts = 3;
|
||||||
|
Exception innerException;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
@ -189,13 +190,14 @@ namespace Microsoft.AspNetCore.E2ETesting
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
output.WriteLine($"Error initializing RemoteWebDriver: {ex.Message}");
|
output.WriteLine($"Error initializing RemoteWebDriver: {ex.Message}");
|
||||||
|
innerException = ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
attempt++;
|
attempt++;
|
||||||
|
|
||||||
} while (attempt < maxAttempts);
|
} 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)
|
private string UserProfileDirectory(string context)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// 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.
|
// 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;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using OpenQA.Selenium;
|
using OpenQA.Selenium;
|
||||||
|
|
@ -16,13 +18,32 @@ namespace Microsoft.AspNetCore.E2ETesting
|
||||||
private static readonly AsyncLocal<ILogs> _logs = new AsyncLocal<ILogs>();
|
private static readonly AsyncLocal<ILogs> _logs = new AsyncLocal<ILogs>();
|
||||||
private static readonly AsyncLocal<ITestOutputHelper> _output = new AsyncLocal<ITestOutputHelper>();
|
private static readonly AsyncLocal<ITestOutputHelper> _output = new AsyncLocal<ITestOutputHelper>();
|
||||||
|
|
||||||
|
private ExceptionDispatchInfo _exceptionDispatchInfo;
|
||||||
|
private IWebDriver _browser;
|
||||||
|
|
||||||
public BrowserTestBase(BrowserFixture browserFixture, ITestOutputHelper output)
|
public BrowserTestBase(BrowserFixture browserFixture, ITestOutputHelper output)
|
||||||
{
|
{
|
||||||
BrowserFixture = browserFixture;
|
BrowserFixture = browserFixture;
|
||||||
_output.Value = output;
|
_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;
|
public static IWebDriver BrowserAccessor => _asyncBrowser.Value;
|
||||||
|
|
||||||
|
|
@ -55,11 +76,19 @@ namespace Microsoft.AspNetCore.E2ETesting
|
||||||
|
|
||||||
protected async Task InitializeBrowser(string isolationContext)
|
protected async Task InitializeBrowser(string isolationContext)
|
||||||
{
|
{
|
||||||
var (browser, logs) = await BrowserFixture.GetOrCreateBrowserAsync(Output, isolationContext);
|
try
|
||||||
_asyncBrowser.Value = browser;
|
{
|
||||||
_logs.Value = logs;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue