Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
krwq opened this issue Oct 14, 2019 · 8 comments
Closed

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

krwq opened this issue Oct 14, 2019 · 8 comments

Comments

@krwq
Copy link
Member

krwq commented Oct 14, 2019

Description

VSTest should be using logger instead of Console.WriteLine. I.e.:

Console.WriteLine(Resources.TestRunningSummary, this.TestFileFullPath, this.VSTestFramework);

Console.WriteLine(Resources.UpdateTestSdkForCollectingCodeCoverage);

This is causing that in some cases output gets lost.

Steps to reproduce

  <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

@ericstj
Copy link
Member

ericstj commented Oct 15, 2019

It also looks like this task creates a process but doesn't redirect output, so that will further be lost logging.

public int Execute()
{
var processInfo = new ProcessStartInfo
{
FileName = hostExe,
Arguments = string.Join(" ", this.allArgs),
UseShellExecute = false,
};
Tracing.Trace("VSTest: Starting vstest.console...");
Tracing.Trace("VSTest: Arguments: " + processInfo.FileName + " " + processInfo.Arguments);
using (var activeProcess = new Process { StartInfo = processInfo })
{
activeProcess.Start();
this.activeProcessId = activeProcess.Id;
activeProcess.WaitForExit();
Tracing.Trace("VSTest: Exit code: " + activeProcess.ExitCode);
return activeProcess.ExitCode;
}
}

@ViktorHofer
Copy link
Member

cc @nohwnd

@nohwnd
Copy link
Member

nohwnd commented Mar 30, 2020

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

@ViktorHofer
Copy link
Member

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

@mcartoixa
Copy link
Contributor

Is it another manifestation of #680?

@Evangelink Evangelink added needs-triage This item should be discussed in the next triage meeting. triaged and removed needs-triage This item should be discussed in the next triage meeting. labels Jul 27, 2022
@krwq
Copy link
Member Author

krwq commented Jul 18, 2023

@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.

@mcartoixa
Copy link
Contributor

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

@nohwnd
Copy link
Member

nohwnd commented Jul 9, 2024

addressed in the msbuild logger work

@nohwnd nohwnd closed this as completed Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants