question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Running coverlet on a sln results in fatal exception

See original GitHub issue

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


[22:13:31][Step 6/10] Data collector 'XPlat code coverage' message: Coverlet.Collector.Utilities.CoverletDataCollectorException: CoverletCoverageDataCollector: Failed to get coverage result
[22:13:31][Step 6/10]  ---> System.IO.IOException: The process cannot access the file '/opt/teamcity/temp/buildTmp/MP_2ccfd88a-3ed0-4316-9bdc-3213e6db0213' because it is being used by another process.
[22:13:31][Step 6/10]    at System.IO.FileStream.Init(FileMode mode, FileShare share, String originalPath)
[22:13:31][Step 6/10]    at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
[22:13:31][Step 6/10]    at Coverlet.Core.Coverage.CalculateCoverage()
[22:13:31][Step 6/10]    at Coverlet.Core.Coverage.GetCoverageResult()
[22:13:31][Step 6/10]    at Coverlet.Collector.DataCollection.CoverageWrapper.GetCoverageResult(Coverage coverage)
[22:13:31][Step 6/10]    at Coverlet.Collector.DataCollection.CoverageManager.GetCoverageResult()
[22:13:31][Step 6/10]    --- End of inner exception stack trace ---
[22:13:31][Step 6/10]    at Coverlet.Collector.DataCollection.CoverageManager.GetCoverageResult()
[22:13:31][Step 6/10]    at Coverlet.Collector.DataCollection.CoverageManager.GetCoverageReport()
[22:13:31][Step 6/10]    at Coverlet.Collector.DataCollection.CoverletCoverageCollector.OnSessionEnd(Object sender, SessionEndEventArgs e).

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.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:14

github_iconTop GitHub Comments

1reaction
reversearkcommented, Jan 10, 2020

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!

0reactions
MarcoRossignolicommented, Feb 15, 2020

Close for stale conversation.

Feel free to re-open if needed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Running coverlet on a sln results in fatal exception #572
This is a new regression in dotnet core 3 - we did not encounter this issue using coverlet collectors in 2.2.401.
Read more >
c# - Using coverlet with. Net Framework generates an error ...
One way I got around this issue was by renaming (or deleting) the coverlet.collector directory in your $HOME\.nuget\packages directory.
Read more >
AltCover and ReportGenerator give amazing code ...
This is the OpenCover XML format and I can run ReportGenerator on the coverage file and get a whole bunch of HTML files....
Read more >
Use code coverage for unit testing - .NET
Coverlet collects Cobertura coverage test run data, which is used for report generation. Additionally, this article details how to use the code ...
Read more >
Dot cover fails randomly on team city
I'm unsure if the crash happens while running the tests, running coverage or in the ... Reason: Test host process crashed : Fatal...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found