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

Account for InvalidOperationException in XunitLogger #5940

Merged
merged 1 commit into from
Jul 31, 2024

Conversation

jeffkl
Copy link
Contributor

@jeffkl jeffkl commented Jul 30, 2024

Description

Some functional tests have been failing with this error:

System.InvalidOperationException : There is no currently active test.

 at Test.Utility.XunitLogger.Log(ILogMessage message) in D:\a\_work\1\s\test\TestUtilities\Test.Utility\XunitLogger.cs:line 32
   at NuGet.Common.LoggerBase.Log(LogLevel level, String data) in D:\a\_work\1\s\src\NuGet.Core\NuGet.Common\Logging\LoggerBase.cs:line 29
   at NuGet.Common.LoggerBase.LogInformation(String data) in D:\a\_work\1\s\src\NuGet.Core\NuGet.Common\Logging\LoggerBase.cs:line 55
   at NuGet.Test.NuGetPackageManagerTests.TestNuGetVSTelemetryService.EmitTelemetryEvent(TelemetryEvent telemetryData) in D:\a\_work\1\s\test\NuGet.Core.Tests\NuGet.PackageManagement.Test\NuGetPackageManagerTests.cs:line 8024

I guess under certain circumstances, the xunit APIs think a test isn't running and so writing to the ITestOutputHelper causes an exception. This change catches the exception and writes to Console.Out instead.

https://dev.azure.com/dnceng-public/public/_build/results?buildId=759945&view=ms.vss-test-web.build-test-results-tab&runId=19293168&resultId=102473&paneView=debug

PR Checklist

  • Meaningful title, helpful description
  • Added tests
  • Link to an issue or pull request to update docs if this PR changes settings, environment variables, new feature, etc.

@jeffkl jeffkl added the Engineering Changes related to the build infrastructure of the repo and that do not change product code label Jul 30, 2024
@jeffkl jeffkl self-assigned this Jul 30, 2024
@jeffkl jeffkl requested a review from a team as a code owner July 30, 2024 23:07
@jeffkl jeffkl merged commit b303698 into dev Jul 31, 2024
28 of 29 checks passed
@jeffkl jeffkl deleted the dev-jeffkl-xunitinvalidoperationexception branch July 31, 2024 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Engineering Changes related to the build infrastructure of the repo and that do not change product code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants