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

Log messages for Test Results #75084

Merged
merged 2 commits into from
Sep 12, 2024
Merged

Log messages for Test Results #75084

merged 2 commits into from
Sep 12, 2024

Conversation

JoeRobich
Copy link
Member

@JoeRobich JoeRobich commented Sep 12, 2024

This updates our logging to match the console logger from the vstest.console runner. See https://github.com/Evangelink/vstest/blob/85ae981180b515d79721266a19a7aa31c30828c5/src/vstest.console/Internal/ConsoleLogger.cs#L295

Resolves http://github.com/dotnet/vscode-csharp/issues/6221

Output looks like:

Starting test discovery
Failed to read environment variable [DOTNET_ROOT], HRESULT: 0x80070002
Logging TestHost Diagnostics in file: c:\Users\jorobich\AppData\Roaming\Code\logs\20240912T105218\window1\exthost\ms-dotnettools.csharp\testLogs\vsTestLogs.host.24-09-12_10-54-07_34481_10.txt
[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v2.5.7-pre.8+41a6ecafa6 (64-bit .NET 9.0.0-rc.1.24431.7)
[xUnit.net 00:00:00.09]   Discovering: dotnet-format.UnitTests
[xUnit.net 00:00:00.18]   Discovered:  dotnet-format.UnitTests
Found 3 tests in 1s

Starting test run
[Failed] Microsoft.CodeAnalysis.Tools.Tests.Analyzers.ThirdPartyAnalyzerFormatterTests.TestLoadingAllAnalyzers_LoadsDependenciesFromAllSearchPaths
    Message:
        System.Exception : This is an error message
    Stack Trace:
           at Microsoft.CodeAnalysis.Tools.Tests.Analyzers.ThirdPartyAnalyzerFormatterTests.TestLoadingAllAnalyzers_LoadsDependenciesFromAllSearchPaths() in c:\Users\jorobich\source\format\tests\Analyzers\ThirdPartyAnalyzerFormatterTests.cs:line 218
        --- End of stack trace from previous location ---
    Standard Output Messages:
          Determining projects to restore...
          All projects are up-to-date for restore.

[Passed] Microsoft.CodeAnalysis.Tools.Tests.Analyzers.ThirdPartyAnalyzerFormatterTests.TestStyleCopBlankLineFixer_RemovesUnnecessaryBlankLines
    Standard Output Messages:
          Determining projects to restore...
          All projects are up-to-date for restore.

[Passed] Microsoft.CodeAnalysis.Tools.Tests.Analyzers.ThirdPartyAnalyzerFormatterTests.TestIDisposableAnalyzer_AddsUsing
    Standard Output Messages:
          Determining projects to restore...
          All projects are up-to-date for restore.

==== Summary ====
Failed!  - Failed:    1, Passed:    2, Skipped:    0, Total:    3, Duration: 9s

@JoeRobich JoeRobich requested a review from a team as a code owner September 12, 2024 17:19
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Infrastructure untriaged Issues and PRs which have not yet been triaged by a lead labels Sep 12, 2024
Copy link
Member

@dibarbet dibarbet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

messageBuilder.AppendLine(IndentString($"{LanguageServerResources.Message}:", 4));
messageBuilder.AppendLine(IndentString(result.ErrorMessage, 8));
}

if (!string.IsNullOrWhiteSpace(result.ErrorStackTrace))
{
messageBuilder.AppendLine();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will append an empty line between the msg and stack trace, which IIRC is why I appended only once above. Maybe not the biggest issue but I believe that was why it was written that way

messageBuilder.AppendLine(value: IndentString($"{LanguageServerResources.Stack_Trace}:", 4));
messageBuilder.AppendLine(IndentString(result.ErrorStackTrace, 8));
}

var standardOutputMessages = GetTestMessages(result.Messages, TestResultMessage.StandardOutCategory);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you have a screenshot of what it looks like?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the description with some output. Let me see if I can get output and error messages.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, ok. So just one new line at the top and we squish everything together.

Starting test run
[Failed] Microsoft.CodeAnalysis.Tools.Tests.Analyzers.ThirdPartyAnalyzerFormatterTests.TestLoadingAllAnalyzers_LoadsDependenciesFromAllSearchPaths
    Message:
        System.Exception : This is an error message

    Stack Trace:
           at Microsoft.CodeAnalysis.Tools.Tests.Analyzers.ThirdPartyAnalyzerFormatterTests.TestLoadingAllAnalyzers_LoadsDependenciesFromAllSearchPaths() in c:\Users\jorobich\source\format\tests\Analyzers\ThirdPartyAnalyzerFormatterTests.cs:line 218
        --- End of stack trace from previous location ---

    Standard Output Messages:
          Determining projects to restore...
          All projects are up-to-date for restore.

==== Summary ====
Failed!  - Failed:    1, Passed:    0, Skipped:    0, Total:    1, Duration: 9s

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

@JoeRobich JoeRobich merged commit 20376a8 into main Sep 12, 2024
25 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Infrastructure untriaged Issues and PRs which have not yet been triaged by a lead VSCode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants