-
Notifications
You must be signed in to change notification settings - Fork 389
Running coverlet on a sln results in fatal exception #572
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
Comments
Run coverage on sln is not supported at the moment #357 |
Ah if you can repro and attach would be great!I never repro this cases on my local. |
It's absolutely possible that two test sessions writing in parallel have a shared DLL between them that they are reporting coverage on. I'll try with -m:1 and report back. |
Looks like doing m:1 has NOT fixed it, with the added downside that it took our test run went from 7 minutes to closer to 23 minutes. If the naming on that temporary file is any indication, then it's a large common base-library DLL used by nearly all of the application packages in some way or another. So it's likely that it's contending quite a lot. |
This is expected...m1 block msbuild to run on only one node.
Can you try to run coverage for every test project?i.e.
I want to understand if there is a workaround to avoid dll sharing, I mean every test rebuild and use a local copy of lib and run in custom process, if works at the end we can merge result https://github.com/tonerdo/coverlet/blob/master/Documentation/Examples.md I'm aware that is not a great solution and need some pipeline updates. |
@queen-of-code I'm trying to repro your issue...I don't know if it's possible but are you able to generate a repro(with emtpy project) but with the structure that lead to your issue? |
@queen-of-code I did some check and I could try to give an alfa version of collectors package to test my idea. |
If you give me a test package on a public nuget server, I can test with it no problem. |
Try with this <?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="coverlet-test" value="https://nugetservercoverlet.azurewebsites.net/nuget/" /> <-- NB IT'S UNOFFICIAL USE ONLY FOR THIS TEST
<add key="nuget" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>
<Project>
<ItemGroup>
<PackageReference Update="coverlet.collector" Version="1.1.9-g42c952b491" />
</ItemGroup>
</Project> runsettings(bug vstest plat workaround) #576 <?xml version="1.0" encoding="utf-8" ?>
<RunSettings>
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="XPlat code coverage">
<Configuration>
<Format>cobertura</Format>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
<InProcDataCollectionRunSettings>
<InProcDataCollectors>
<InProcDataCollector assemblyQualifiedName="Coverlet.Collector.DataCollection.CoverletInProcDataCollector, coverlet.collector, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null"
friendlyName="XPlat Code Coverage"
enabled="True"
codebase="coverlet.collector.dll" />
</InProcDataCollectors>
</InProcDataCollectionRunSettings>
</RunSettings> cspoj sample <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
<PackageReference Include="coverlet.collector" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\lib1\lib1.csproj" />
<ProjectReference Include="..\lib2\lib2.csproj" />
<ProjectReference Include="..\lib3\lib3.csproj" />
</ItemGroup>
</Project>
Enable also logs for |
@queen-of-code any news? |
Just to report we hit exactly the same issue and search engine leads me here. Version of collector package is 1.2.0. It is not an easy repro though, probably once every 20-30 runs. I read through this thread. The MaxCpuCount not respected by dotnet test issue has been well discussed here. I also saw the description about what is happening behind the scene with. It seems this kind of issue will happen by nature, unless this design is changed "one tmp file for every dll". Thanks! |
I think that issue is referred to fact that max cpu count is ignored if used inside runsettings, that is the artifact that vstest load and use to run tests, Sequential
Parallel
|
@reverseark can you try the same sample of #572 (comment) and use a tmp patched version of coverlet? TL;DR; I try to explain better: Hits file(file where we put coverage data a simple array of int every position is a line or a branch and we count how many time we hit that position) is flushed to disk in 2 cases
However there is an issue with vstest https://github.com/tonerdo/coverlet/blob/master/Documentation/KnowIssues.md#1-vstest-stops-process-execution-earlydotnet-test that after some time(after test ends) kill host process and can happen in the middle of process exit. This lead us to integrate with vstest with collector where there is a protocol where the collector signal if his works is end and so vstest doesn't kill the process in the middle. By the way the host is subscribed yet to process exit(we don't have a custom code for "loaded by collector") so it's possible that out of process collectors are reading hit file and at the same time host test process close and re-flush hit file, and this is randomic and related to the overall condition. When you run
The tmp fix remove the flush of file on testhost.exe process exit. |
Close for stale conversation. Feel free to re-open if needed. |
This is a new regression in dotnet core 3 - we did not encounter this issue using coverlet collectors in 2.2.401. I have something like 40 test csproj files in
mycode.sln
.When I run
dotnet test mycode.sln --collect:"XPlat Code Coverage"
I inevitably at some point in the run will get
Pretty clearly it's contending over the same tmp file for coverage info. FWIW, this is much more likely to happen when I am running directly from the command line vs using a .runsettings file - though I believe it has happened in either case.
The text was updated successfully, but these errors were encountered: