vstest icon indicating copy to clipboard operation
vstest copied to clipboard

VSTest is printing using Console.WriteLine instead of using the logger

Open krwq opened this issue 6 years ago • 7 comments

Description

VSTest should be using logger instead of Console.WriteLine. I.e.: https://github.com/microsoft/vstest/blob/e6c198ca439603f0e81d723538894646032745f6/src/Microsoft.TestPlatform.Build/Tasks/VSTestTask.cs#L132 https://github.com/microsoft/vstest/blob/e6c198ca439603f0e81d723538894646032745f6/src/Microsoft.TestPlatform.Build/Tasks/VSTestTask.cs#L301

This is causing that in some cases output gets lost.

Steps to reproduce

  • Clone https://github.com/dotnet/iot/
  • Replace following ("Test") task https://github.com/dotnet/iot/blob/a5a53b5a3a287638df0176c483fcb1f3b2fef7f0/build.proj#L59 with
  <Target Name="Test">
    <ItemGroup>
      <UnitTestProjects Include="$(MSBuildThisFileDirectory)src\devices\**\*.Tests.csproj" />
    </ItemGroup>
    <MSBuild Projects="@(UnitTestProjects)" Targets="VSTest"
        ContinueOnError="ErrorAndContinue" />
    <Error Condition="$(MSBuildLastTaskResult) != 'true'"
        Text="Unit tests failed. Please check the detailed log to find out which ones failed." />
  </Target>

Replacing will not be needed once linked PR is merged

  • Run build.cmd/build.sh (in the root directory)

If any property is passed to MSBuild task then output gets printed (because of luck it gets run on master node where Console.WriteLine works correctly)

Expected behavior

Test output is displayed

Actual behavior

Build fails but no errors get printed

krwq avatar Oct 14 '19 23:10 krwq

It also looks like this task creates a process but doesn't redirect output, so that will further be lost logging. https://github.com/microsoft/vstest/blob/e6c198ca439603f0e81d723538894646032745f6/src/Microsoft.TestPlatform.Build/Tasks/VSTestForwardingApp.cs#L30-L51

ericstj avatar Oct 15 '19 04:10 ericstj

cc @nohwnd

ViktorHofer avatar Mar 30 '20 15:03 ViktorHofer

@ViktorHofer did you see this issue happen somewher or why are you tagging me just now?:)

nohwnd avatar Mar 30 '20 16:03 nohwnd

@akoeplinger a colleague of mine is hitting this issue in mono/linker. Thought you might be interested in this issue :)

ViktorHofer avatar Mar 30 '20 16:03 ViktorHofer

Is it another manifestation of #680?

mcartoixa avatar Aug 22 '20 18:08 mcartoixa

@mayankbansal018 @Evangelink do you have any ETA when this might be addressed? this is currently making vstests kinda useless in some scenarios for dotnet/iot because tests fail but we get not info what failed and issue is CI specific in our case.

krwq avatar Jul 18 '23 10:07 krwq

FYI #2702 addresses the issue, but has been waiting for ages now. I'm rebasing from time to time...

mcartoixa avatar Jul 18 '23 11:07 mcartoixa

addressed in the msbuild logger work

nohwnd avatar Jul 09 '24 08:07 nohwnd