Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions test/dotnet.Tests/CommandTests/Run/RunFileTestBase.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics;
using Microsoft.Build.Framework;
using Microsoft.Build.Logging.StructuredLogger;
using Microsoft.DotNet.Cli.Commands;
Expand Down Expand Up @@ -185,9 +186,17 @@ private protected void Build(
command = customizeCommand(command);
}

command.Execute()
.Should().Pass()
.And.HaveStdOut(prefix + expectedOutput);
var result = command.Execute();

var fullExpectedOutput = prefix + expectedOutput;
if (result.ExitCode != 0 || result.StdOut != fullExpectedOutput)
{
// Re-run with verbose logging for easier debugging of test failures.
command.WithEnvironmentVariable(CommandLoggingContext.Variables.Verbose, bool.TrueString).Execute();

result.Should().Pass().And.HaveStdOut(fullExpectedOutput);
throw new UnreachableException();
}

var binlogs = new DirectoryInfo(workDir ?? testInstance.Path)
.EnumerateFiles("*.binlog", SearchOption.TopDirectoryOnly);
Expand Down
Loading