From 352df35864d881b424ef87fc1633382123adcc64 Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Wed, 31 Jul 2019 20:12:23 -0700 Subject: [PATCH] Re-enable components E2E tests on the CI --- .../ServerFixtures/ServerFixture.cs | 22 +++++++++++++++++-- .../ServerFixtures/WebHostServerFixture.cs | 1 + ...soft.AspNetCore.Components.E2ETests.csproj | 6 ++++- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/Components/test/E2ETest/Infrastructure/ServerFixtures/ServerFixture.cs b/src/Components/test/E2ETest/Infrastructure/ServerFixtures/ServerFixture.cs index 3cd8539c61..742a83f12f 100644 --- a/src/Components/test/E2ETest/Infrastructure/ServerFixtures/ServerFixture.cs +++ b/src/Components/test/E2ETest/Infrastructure/ServerFixtures/ServerFixture.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Reflection; +using System.Runtime.ExceptionServices; using System.Threading; namespace Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures @@ -52,13 +53,30 @@ namespace Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures { var isDone = new ManualResetEvent(false); + ExceptionDispatchInfo edi = null; new Thread(() => { - action(); + try + { + action(); + } + catch (Exception ex) + { + edi = ExceptionDispatchInfo.Capture(ex); + } + isDone.Set(); }).Start(); - isDone.WaitOne(); + if (!isDone.WaitOne(TimeSpan.FromSeconds(10))) + { + throw new TimeoutException("Timed out waiting for: " + action); + } + + if (edi != null) + { + throw edi.SourceException; + } } } } diff --git a/src/Components/test/E2ETest/Infrastructure/ServerFixtures/WebHostServerFixture.cs b/src/Components/test/E2ETest/Infrastructure/ServerFixtures/WebHostServerFixture.cs index 2408713ca8..1da2656b37 100644 --- a/src/Components/test/E2ETest/Infrastructure/ServerFixtures/WebHostServerFixture.cs +++ b/src/Components/test/E2ETest/Infrastructure/ServerFixtures/WebHostServerFixture.cs @@ -24,6 +24,7 @@ namespace Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures { // This can be null if creating the webhost throws, we don't want to throw here and hide // the original exception. + Host?.Dispose(); Host?.StopAsync(); } diff --git a/src/Components/test/E2ETest/Microsoft.AspNetCore.Components.E2ETests.csproj b/src/Components/test/E2ETest/Microsoft.AspNetCore.Components.E2ETests.csproj index 9e85027c89..fc3a9c6dfa 100644 --- a/src/Components/test/E2ETest/Microsoft.AspNetCore.Components.E2ETests.csproj +++ b/src/Components/test/E2ETest/Microsoft.AspNetCore.Components.E2ETests.csproj @@ -7,12 +7,16 @@ netcoreapp3.0 Components.E2ETests - true false + + + true + +