From 10c752ae6b5e1fddd8bf68401701b5bf9b6d097e Mon Sep 17 00:00:00 2001 From: Doug Bunting <6431421+dougbu@users.noreply.github.com> Date: Mon, 6 Jun 2022 18:20:21 -0700 Subject: [PATCH 1/2] Add debugging of repeated config issues - see #41937 - do not skip `SimpleWebSiteWithWebApplicationBuilder.DefaultEnvironment_Is_Development()` - get debug view of server's configuration when that test is going to fail --- .../SimpleWithWebApplicationBuilderTests.cs | 16 ++++++++++++++-- .../Program.cs | 4 ++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Mvc/test/Mvc.FunctionalTests/SimpleWithWebApplicationBuilderTests.cs b/src/Mvc/test/Mvc.FunctionalTests/SimpleWithWebApplicationBuilderTests.cs index d275e88e93c5..f84425f734cd 100644 --- a/src/Mvc/test/Mvc.FunctionalTests/SimpleWithWebApplicationBuilderTests.cs +++ b/src/Mvc/test/Mvc.FunctionalTests/SimpleWithWebApplicationBuilderTests.cs @@ -11,6 +11,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; using Xunit; +using Xunit.Abstractions; namespace Microsoft.AspNetCore.Mvc.FunctionalTests { @@ -18,13 +19,16 @@ public class SimpleWithWebApplicationBuilderTests : IClassFixture _fixture; - public SimpleWithWebApplicationBuilderTests(MvcTestFixture fixture) + public SimpleWithWebApplicationBuilderTests(MvcTestFixture fixture, + ITestOutputHelper helper) { _fixture = fixture; Client = _fixture.CreateDefaultClient(); + Helper = helper; } public HttpClient Client { get; } + public ITestOutputHelper Helper { get; } [Fact] public async Task HelloWorld() @@ -131,7 +135,7 @@ public async Task MvcControllerActionWorks() Assert.Equal("Hello human", content); } - [Fact(Skip = "Failing on Windows environments: https://github.com/dotnet/aspnetcore/issues/41937")] + [Fact] public async Task DefaultEnvironment_Is_Development() { // Arrange @@ -142,6 +146,14 @@ public async Task DefaultEnvironment_Is_Development() var content = await client.GetStringAsync("http://localhost/environment"); // Assert + if (!string.Equals(expected, content)) + { + // Get more information when this test is going to fail. + var configContent = await client.GetStringAsync("http://localhost/config"); + + Helper.WriteLine($"Configuration debug view: '{configContent}'"); + } + Assert.Equal(expected, content); } diff --git a/src/Mvc/test/WebSites/SimpleWebSiteWithWebApplicationBuilder/Program.cs b/src/Mvc/test/WebSites/SimpleWebSiteWithWebApplicationBuilder/Program.cs index ea06879f0b72..80e9743ece4d 100644 --- a/src/Mvc/test/WebSites/SimpleWebSiteWithWebApplicationBuilder/Program.cs +++ b/src/Mvc/test/WebSites/SimpleWebSiteWithWebApplicationBuilder/Program.cs @@ -34,6 +34,10 @@ app.MapGet("/problem", () => Results.Problem("Some problem")); app.MapGet("/environment", (IHostEnvironment environment) => environment.EnvironmentName); +app.MapGet("/config", (IConfiguration config, HttpContext context) => { + return context.Response.WriteAsync(((IConfigurationRoot)config).GetDebugView()); +}); + app.MapGet("/webroot", (IWebHostEnvironment environment) => environment.WebRootPath); app.MapGet("/greeting", (IConfiguration config) => config["Greeting"]); From 08040f537b7abde7a284270c65a965921f1cddd6 Mon Sep 17 00:00:00 2001 From: Doug Bunting <6431421+dougbu@users.noreply.github.com> Date: Thu, 9 Jun 2022 19:00:54 -0700 Subject: [PATCH 2/2] Attempt a workaround - unset `ASPNETCORE_ENVIRONMENT` --- eng/helix/content/runtests.cmd | 3 +++ 1 file changed, 3 insertions(+) diff --git a/eng/helix/content/runtests.cmd b/eng/helix/content/runtests.cmd index 3aab373c69c9..a3c6de9c0a45 100644 --- a/eng/helix/content/runtests.cmd +++ b/eng/helix/content/runtests.cmd @@ -18,6 +18,9 @@ set InstallPlaywright=%$installPlaywright% set PLAYWRIGHT_BROWSERS_PATH=%CD%\ms-playwright set PLAYWRIGHT_DRIVER_PATH=%CD%\.playwright\win-x64\native\playwright.cmd +REM Avoid https://github.com/dotnet/aspnetcore/issues/41937 in current session. +set ASPNETCORE_ENVIRONMENT= + set "PATH=%HELIX_WORKITEM_ROOT%;%PATH%;%HELIX_WORKITEM_ROOT%\node\bin" echo Set path to: "%PATH%" echo.