Skip to content

CommonExporterVerifyTests randomly failed when called from multiple thread. #2927

@filzrev

Description

@filzrev

CommonExporterVerifyTests failed on latest CI.
https://github.com/dotnet/BenchmarkDotNet/actions/runs/20255647506/job/58156934897

Failed Log

2025-12-16T03:44:34.1544745Z [xUnit.net 00:00:01.16]     Exporters(cultureInfoName: "") [FAIL]
2025-12-16T03:44:34.1546551Z [xUnit.net 00:00:01.16]       VerifyException : Directory: /home/runner/work/BenchmarkDotNet/BenchmarkDotNet/tests/BenchmarkDotNet.Tests/Exporters/VerifiedFiles
2025-12-16T03:44:34.1548056Z [xUnit.net 00:00:01.16]       NotEqual:
2025-12-16T03:44:34.1549309Z [xUnit.net 00:00:01.16]         - Received: CommonExporterVerifyTests.Exporters_Invariant.DotNet8_0.received.txt
2025-12-16T03:44:34.1551023Z [xUnit.net 00:00:01.16]           Verified: CommonExporterVerifyTests.Exporters_Invariant.verified.txt

The verified content contains JSON that is incorrectly indented.
It looks like SimpleJsonSerializer doesn't support concurrent calls from multiple threads.
(indentationLevel is stored on static variable)

Currently SimpleJson is not expected to be called from multiple threads except for UnitTests.
Though, I thought it is desirable to migrate to System.Text.Json based implementation in the future.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions