Skip to content

Commit 973200c

Browse files
authored
workaround for "Failed to instrument modules" (#1700)
1 parent c2e6aee commit 973200c

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

Documentation/KnownIssues.md

+32
Original file line numberDiff line numberDiff line change
@@ -249,3 +249,35 @@ Change [DebugType](https://learn.microsoft.com/en-us/dotnet/csharp/language-refe
249249

250250
>[!IMPORTANT]
251251
>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.
252+
253+
## CoverletCoverageDataCollector: Failed to instrument modules
254+
255+
*Affected drivers*: VSTest integration `dotnet test --collect:"XPlat Code Coverage"`
256+
257+
*Symptoms:*
258+
259+
```text
260+
Data collector 'XPlat code coverage' message: [coverlet]Coverlet.Collector.Utilities.CoverletDataCollectorException: CoverletCoverageDataCollector: Failed to instrument modules
261+
---> System.AggregateException: One or more errors occurred. (The process cannot access the file XXX\ABC.pdb
262+
---> System.IO.IOException: The process cannot access the file 'XXX\ABC.pdb' because it is being used by another process.
263+
at System.IO.FileSystem.CopyFile(String sourceFullPath, String destFullPath, Boolean overwrite)
264+
at Coverlet.Core.Helpers.FileSystem.Copy(String sourceFileName, String destFileName, Boolean overwrite) in /_/src/coverlet.core/Helpers/FileSystem.cs:line 35
265+
at Coverlet.Core.Helpers.InstrumentationHelper.<>c__DisplayClass16_0.<RestoreOriginalModule>b__1() in /_/src/coverlet.core/Helpers/InstrumentationHelper.cs:line 277
266+
at Coverlet.Core.Helpers.RetryHelper.<>c__DisplayClass0_0.<Retry>b__0() in /_/src/coverlet.core/Helpers/RetryHelper.cs:line 28
267+
at Coverlet.Core.Helpers.RetryHelper.Do[T](Func`1 action, Func`1 backoffStrategy, Int32 maxAttemptCount) in /_/src/coverlet.core/Helpers/RetryHelper.cs:line 55
268+
--- End of inner exception stack trace ---
269+
...
270+
```
271+
272+
>[!Note]
273+
>This is not an coverlet issue but running tests in parallel without proper separation of test case resources
274+
>>
275+
>>**dotnet vstest cli option**
276+
>>
277+
>>--Parallel
278+
>>
279+
>> 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.
280+
281+
*Solutions:*
282+
283+
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 commit comments

Comments
 (0)