From 2e807ab0f4b1e42aa131f63bcb376a0a54790363 Mon Sep 17 00:00:00 2001 From: Larry Ewing Date: Wed, 12 Aug 2020 13:13:14 -0500 Subject: [PATCH] [browser] Move the test specific code to the right location (#40722) * Split out TestHarness related classes * Move TestHarness files --- src/mono/wasm/debugger/BrowserDebugHost/Program.cs | 52 ------------------- .../DebuggerTestSuite/TestHarnessOptions.cs | 15 ++++++ .../debugger/DebuggerTestSuite/TestHarnessProxy.cs | 59 ++++++++++++++++++++++ .../TestHarnessStartup.cs | 0 4 files changed, 74 insertions(+), 52 deletions(-) create mode 100644 src/mono/wasm/debugger/DebuggerTestSuite/TestHarnessOptions.cs create mode 100644 src/mono/wasm/debugger/DebuggerTestSuite/TestHarnessProxy.cs rename src/mono/wasm/debugger/{BrowserDebugHost => DebuggerTestSuite}/TestHarnessStartup.cs (100%) diff --git a/src/mono/wasm/debugger/BrowserDebugHost/Program.cs b/src/mono/wasm/debugger/BrowserDebugHost/Program.cs index 66db8a1..442e5ac 100644 --- a/src/mono/wasm/debugger/BrowserDebugHost/Program.cs +++ b/src/mono/wasm/debugger/BrowserDebugHost/Program.cs @@ -18,14 +18,6 @@ namespace Microsoft.WebAssembly.Diagnostics public Uri DevToolsUrl { get; set; } = new Uri("http://localhost:9222"); } - public class TestHarnessOptions : ProxyOptions - { - public string ChromePath { get; set; } - public string AppPath { get; set; } - public string PagePath { get; set; } - public string NodeApp { get; set; } - } - public class Program { public static void Main(string[] args) @@ -45,48 +37,4 @@ namespace Microsoft.WebAssembly.Diagnostics host.Run(); } } - - public class TestHarnessProxy - { - static IWebHost host; - static Task hostTask; - static CancellationTokenSource cts = new CancellationTokenSource(); - static object proxyLock = new object(); - - public static readonly Uri Endpoint = new Uri("http://localhost:9400"); - - public static Task Start(string chromePath, string appPath, string pagePath) - { - lock (proxyLock) - { - if (host != null) - return hostTask; - - host = WebHost.CreateDefaultBuilder() - .UseSetting("UseIISIntegration", false.ToString()) - .ConfigureAppConfiguration((hostingContext, config) => - { - config.AddEnvironmentVariables(prefix: "WASM_TESTS_"); - }) - .ConfigureServices((ctx, services) => - { - services.Configure(ctx.Configuration); - services.Configure(options => - { - options.ChromePath = options.ChromePath ?? chromePath; - options.AppPath = appPath; - options.PagePath = pagePath; - options.DevToolsUrl = new Uri("http://localhost:0"); - }); - }) - .UseStartup() - .UseUrls(Endpoint.ToString()) - .Build(); - hostTask = host.StartAsync(cts.Token); - } - - Console.WriteLine("WebServer Ready!"); - return hostTask; - } - } } diff --git a/src/mono/wasm/debugger/DebuggerTestSuite/TestHarnessOptions.cs b/src/mono/wasm/debugger/DebuggerTestSuite/TestHarnessOptions.cs new file mode 100644 index 0000000..96a6c13 --- /dev/null +++ b/src/mono/wasm/debugger/DebuggerTestSuite/TestHarnessOptions.cs @@ -0,0 +1,15 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; + +namespace Microsoft.WebAssembly.Diagnostics +{ + public class TestHarnessOptions : ProxyOptions + { + public string ChromePath { get; set; } + public string AppPath { get; set; } + public string PagePath { get; set; } + public string NodeApp { get; set; } + } +} \ No newline at end of file diff --git a/src/mono/wasm/debugger/DebuggerTestSuite/TestHarnessProxy.cs b/src/mono/wasm/debugger/DebuggerTestSuite/TestHarnessProxy.cs new file mode 100644 index 0000000..3995dcc --- /dev/null +++ b/src/mono/wasm/debugger/DebuggerTestSuite/TestHarnessProxy.cs @@ -0,0 +1,59 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.IO; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.AspNetCore; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; + +namespace Microsoft.WebAssembly.Diagnostics +{ + public class TestHarnessProxy + { + static IWebHost host; + static Task hostTask; + static CancellationTokenSource cts = new CancellationTokenSource(); + static object proxyLock = new object(); + + public static readonly Uri Endpoint = new Uri("http://localhost:9400"); + + public static Task Start(string chromePath, string appPath, string pagePath) + { + lock (proxyLock) + { + if (host != null) + return hostTask; + + host = WebHost.CreateDefaultBuilder() + .UseSetting("UseIISIntegration", false.ToString()) + .ConfigureAppConfiguration((hostingContext, config) => + { + config.AddEnvironmentVariables(prefix: "WASM_TESTS_"); + }) + .ConfigureServices((ctx, services) => + { + services.Configure(ctx.Configuration); + services.Configure(options => + { + options.ChromePath = options.ChromePath ?? chromePath; + options.AppPath = appPath; + options.PagePath = pagePath; + options.DevToolsUrl = new Uri("http://localhost:0"); + }); + }) + .UseStartup() + .UseUrls(Endpoint.ToString()) + .Build(); + hostTask = host.StartAsync(cts.Token); + } + + Console.WriteLine("WebServer Ready!"); + return hostTask; + } + } +} \ No newline at end of file diff --git a/src/mono/wasm/debugger/BrowserDebugHost/TestHarnessStartup.cs b/src/mono/wasm/debugger/DebuggerTestSuite/TestHarnessStartup.cs similarity index 100% rename from src/mono/wasm/debugger/BrowserDebugHost/TestHarnessStartup.cs rename to src/mono/wasm/debugger/DebuggerTestSuite/TestHarnessStartup.cs -- 2.7.4