Skip to content

Commit ece7f16

Browse files
authored
dump-logs? (#15187)
* dump-logs? * using
1 parent b9c33d9 commit ece7f16

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test/Microsoft.TestPlatform.Acceptance.IntegrationTests/TranslationLayerTests/CustomTestHostTests.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

4+
using System;
45
using System.Collections.Generic;
56
using System.Diagnostics;
7+
using System.IO;
68
using System.Linq;
9+
using System.Text;
710
using System.Threading;
811

912
using FluentAssertions;
@@ -158,6 +161,27 @@ public void RunAllTestsWithMixedTFMsWillProvideAdditionalInformationToTheDebugge
158161
vstestConsoleWrapper.RunTestsWithCustomTestHost(new[] { netFrameworkDll, netDll }, runsettingsXml, runEventHandler, testHostLauncher);
159162

160163
// Assert
164+
if (runEventHandler.Errors.Any())
165+
{
166+
var tempPath = TempDirectory.Path;
167+
var files = System.IO.Directory.GetFiles(tempPath, "*.txt").ToList();
168+
if (files.Count == 0)
169+
{
170+
throw new InvalidOperationException($"No error files found in {tempPath}. {string.Join("\n", Directory.GetFiles(tempPath))}");
171+
}
172+
173+
var allText = new StringBuilder();
174+
foreach (var file in files)
175+
{
176+
#pragma warning disable CA1305 // Specify IFormatProvider
177+
allText.AppendLine($"Error file: {file}");
178+
allText.AppendLine(File.ReadAllText(file));
179+
allText.AppendLine();
180+
#pragma warning restore CA1305 // Specify IFormatProvider
181+
}
182+
throw new InvalidOperationException($"Logs: {allText}");
183+
}
184+
161185
runEventHandler.Errors.Should().BeEmpty();
162186
testHostLauncher.AttachDebuggerInfos.Should().HaveCount(2);
163187
var targetFrameworks = testHostLauncher.AttachDebuggerInfos.Select(i => i.TargetFramework).ToList();

0 commit comments

Comments
 (0)