Skip to content

Commit

Permalink
Avoid logging >Task returned false but did not log an error.< (#2557)
Browse files Browse the repository at this point in the history
* Avoid logging >Task returned false but did not log an error.< on test failure

* Add VSTEST_BUILD_DEBUG env var

* Using namespaces
  • Loading branch information
nohwnd committed Sep 3, 2020
1 parent 95cb80f commit ef1d067
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/Microsoft.TestPlatform.Build/Tasks/VSTestTask.cs
Expand Up @@ -5,7 +5,9 @@ namespace Microsoft.TestPlatform.Build.Tasks
{
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using Microsoft.TestPlatform.Build.Resources;
Expand Down Expand Up @@ -161,6 +163,27 @@ public override bool Execute()
var traceEnabledValue = Environment.GetEnvironmentVariable("VSTEST_BUILD_TRACE");
Tracing.traceEnabled = !string.IsNullOrEmpty(traceEnabledValue) && traceEnabledValue.Equals("1", StringComparison.OrdinalIgnoreCase);

var debugEnabled = Environment.GetEnvironmentVariable("VSTEST_BUILD_DEBUG");
if (!string.IsNullOrEmpty(debugEnabled) && debugEnabled.Equals("1", StringComparison.Ordinal))
{
Console.WriteLine("Waiting for debugger attach...");

var currentProcess = Process.GetCurrentProcess();
Console.WriteLine(string.Format("Process Id: {0}, Name: {1}", currentProcess.Id, currentProcess.ProcessName));

while (!Debugger.IsAttached)
{
Thread.Sleep(1000);
}

Debugger.Break();
}

// Avoid logging "Task returned false but did not log an error." on test failure, because we don't
// write MSBuild error. https://github.com/dotnet/msbuild/blob/51a1071f8871e0c93afbaf1b2ac2c9e59c7b6491/src/Framework/IBuildEngine7.cs#L12
var allowfailureWithoutError = BuildEngine.GetType().GetProperty("AllowFailureWithoutError");
allowfailureWithoutError?.SetValue(BuildEngine, true);

vsTestForwardingApp = new VSTestForwardingApp(this.VSTestConsolePath, this.CreateArgument());
if (!string.IsNullOrEmpty(this.VSTestFramework))
{
Expand Down

0 comments on commit ef1d067

Please sign in to comment.