Skip to content

Commit

Permalink
workaround for "Failed to instrument modules" (#1700)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bertk authored Nov 18, 2024
1 parent c2e6aee commit 973200c
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions Documentation/KnownIssues.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,35 @@ Change [DebugType](https://learn.microsoft.com/en-us/dotnet/csharp/language-refe

>[!IMPORTANT]
>NET Core introduces a new symbol file (PDB) format - portable PDBs. Unlike traditional PDBs which are Windows-only, portable PDBs can be created and read on all platforms.
## CoverletCoverageDataCollector: Failed to instrument modules

*Affected drivers*: VSTest integration `dotnet test --collect:"XPlat Code Coverage"`

*Symptoms:*

```text
Data collector 'XPlat code coverage' message: [coverlet]Coverlet.Collector.Utilities.CoverletDataCollectorException: CoverletCoverageDataCollector: Failed to instrument modules
---> System.AggregateException: One or more errors occurred. (The process cannot access the file XXX\ABC.pdb
---> System.IO.IOException: The process cannot access the file 'XXX\ABC.pdb' because it is being used by another process.
at System.IO.FileSystem.CopyFile(String sourceFullPath, String destFullPath, Boolean overwrite)
at Coverlet.Core.Helpers.FileSystem.Copy(String sourceFileName, String destFileName, Boolean overwrite) in /_/src/coverlet.core/Helpers/FileSystem.cs:line 35
at Coverlet.Core.Helpers.InstrumentationHelper.<>c__DisplayClass16_0.<RestoreOriginalModule>b__1() in /_/src/coverlet.core/Helpers/InstrumentationHelper.cs:line 277
at Coverlet.Core.Helpers.RetryHelper.<>c__DisplayClass0_0.<Retry>b__0() in /_/src/coverlet.core/Helpers/RetryHelper.cs:line 28
at Coverlet.Core.Helpers.RetryHelper.Do[T](Func`1 action, Func`1 backoffStrategy, Int32 maxAttemptCount) in /_/src/coverlet.core/Helpers/RetryHelper.cs:line 55
--- End of inner exception stack trace ---
...
```

>[!Note]
>This is not an coverlet issue but running tests in parallel without proper separation of test case resources
>>
>>**dotnet vstest cli option**
>>
>>--Parallel
>>
>> Run tests in parallel. By default, all available cores on the machine are available for use. Specify an explicit number of cores by setting the MaxCpuCount property under the RunConfiguration node in the runsettings file.
*Solutions:*

use VSTest setting [-maxcpucount:1](https://learn.microsoft.com/en-us/visualstudio/msbuild/building-multiple-projects-in-parallel-with-msbuild?view=vs-2022#-maxcpucount-switch) which limits "worker processes".

0 comments on commit 973200c

Please sign in to comment.