serilog / serilog-settings-configuration

A Serilog configuration provider that reads from Microsoft.Extensions.Configuration
Apache License 2.0
444 stars 129 forks source link

Restore parallel tests execution #403

Closed 0xced closed 9 months ago

0xced commented 9 months ago

This reduces the tests execution time in half. On my machine: 76 seconds when run in parallel vs 144 seconds when run serially.

The fix introduced in 41bc33d4bc7b03c920102ddaba195e96d152fb5f (running dotnet test on the csproj rather then on the built dlls) was problematic for two reasons.

  1. It rebuilds Serilog.Settings.Configuration.Tests.csproj in Debug instead of Release and it's unnecessary since it was previously built.
  2. It doesn't run tests in parallel anymore, increasing the total tests execution time.

The right fix was to disable deterministic source paths for the test project with <DeterministicSourcePaths>false</DeterministicSourcePaths>. This way, the [CallerFilePath] attribute works as expected with absolute paths on the current machine instead of being substituted with /_/ (which was causing the test failures). This looks like a breaking change that was introduced in the .NET 8 SDK.

Also, I added back allowPrerelease = false and rollForward = latestFeature in the global.json file.

nblumhardt commented 9 months ago

Awesome! How on earth did you find that? :tada:

0xced commented 9 months ago

Well, I've become kind of an MSBuild expert in spite of myself over the years. The /_/ path was a great hint towards SourceLink, so I looked at SourceLink related stuff with MSBuild Binary and Structured Log Viewer (thanks again @KirillOsenkov 🙏) and eventually discovered this property.

Also, I was pretty motivated because I already had spend way too much figuring out how to run test in parallel across target frameworks. 😄

KirillOsenkov commented 9 months ago

Yes, .NET 8 enabled SourceLink by default. Happy the tool is helpful!