-
Notifications
You must be signed in to change notification settings - Fork 382
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
Dll files opened by multiple processes during dotnet test #725
Comments
Some question: Do you have only one test project? From exception seem that after test run when coverlet tries to "restore" old files(because coverlet to work backup file instrument and at the end restore old one without instrumentation code inside) that files are in use by someone, so restoring fail. I found this issue sometimes when lib for some reason are "re-used" for different tests(related to some build config) in parallel or when you run big solutions with a lot of test projects(by default will run in parallel) and slow tests. |
Advice: if possible you should use vstest integration https://github.com/tonerdo/coverlet/blob/master/Documentation/VSTestIntegration.md |
Hi Marco :) I just run the tests from the command line. I do not use Visual Studio, I use Visual Studio Code as my editor, but I run the tests from the command line using When I just run My Solution structure is like this:
|
Intermittent nature is expected(I mean it's a problem 😄 it's not correct but expected possible bad behaviour) on parallel test/build try with this:
|
I tried I is possible to pass the options
and I would like to do it for the |
Also I googled a little bit about running tests in parallel when searching for solutions to the problem and I found this flag |
Yes as I said it's possible because the nature of issue is "randomic" if for some timing reason who is using that dll free the lib before restoring issue doesn't bubble up...the flag
I don't know if it works as xml props https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild-command-line-reference?view=vs-2019 try and tell me if it works, on docs is referred as command line arg. |
The I will try and keep these two set and see if the issue occurs again. You think the issue occurs in the |
It occour in coverlet but it's related to how build/test run. Coverlet restore all instrumented libs at the end of tests, we use an msbuild task(in this case) so seem that also if task should start at the end of tests someone(msbuild/test process) has got that dll loaded and doesn't allow to coverlet to restore(copy) files back. You could try with vstest integration, maybe solve the issue because the "workflow" is completely different https://github.com/tonerdo/coverlet/blob/master/Documentation/VSTestIntegration.md and there is no msbuild interaction. |
We have this issue as well. It happens intermittenly in Azure DevOps. However, when I run locally it happens every time. I tried adding both The command I am running looks something like:
Tried with
Not sure if related, but it seems to me that it started happening after I bumped mono to 6.6.0 and .NET Core to 3.1.100, but not sure. I tried adding a global.json to try make it run with .NET Core 3.0.100 but that doesn't seem to change anything. |
It's possible have a repro?Are one of these project OSS?I remember another user with same issue but I cannot repro in my local so it's hard to understand. Can you try with my custom patched version? #572 (comment) |
@MarcoRossignoli it is unfortunately not OSS |
OK! Just tried something. Lowered the version of |
I've got a suspect...can you try with my patched version? #572 (comment) |
@MarcoRossignoli yep, on it now. Ran it with:
and config looking like:
Seems to run fine. |
Please try removing |
Yes, the host log file contains this, when I remove the
|
Seem ok...the errors are logged so are not a problem, the essential part is
Double check....if you only update to official 1.2.0 does it work or start to fail? |
@Cheesebaron can you try with our nightly build we fixed the issue of race condition in collectors #835 @svenskmand does this issue solved? |
@MarcoRossignoli yes. Will have a look tomorrow. Do you want me to test with coverlet nightly and latest version of Test.Sdk? |
Yes thanks |
It seems to work. Tried a couple of runs with coverlet.collector version 1.3.0-preview.17.g3c55332cce and Microsoft.NET.Test.Sdk 16.6.1 |
Great!Thanks! |
Hi, I've got the same errors, mentioned above, with both msbuild and vstest integrations. Interesting point here, the error is observed with tests written with xUnit, with NUnit everything work just fine. Maybe it's related to xunit.runner? Tests and code itself target .NET Core 2.1, installed SDK details are below
The relevant packages
Adding |
Can you attach the error? |
Hi @MarcoRossignoli please have a look at logs generated by MSBuild integration (I've just removed the sensitive names) The process cannot access the file error is repeated a multiple times
The same error is observed with VSTest integration
Thank you! |
If you run for only one csproj does this error happen?I mean run something like |
Yes, error the same. I have only one test project here. I've tried to run using different ways, by specifying |
|
Thank you, I'll have a look. Can xunit.runner or testhost lock these files? Because I have a bunch of nunit tests in different repo, they work fine. Output folder for nunit tests doesn't contain testhost.exe and dll, but for xunit does |
I know a bit testhost(worked on vstest repo) and never seen that issue, I don't know nothing about xunit runner...btw it's hard to guess...could be everything, we need to analyze with some tecnique above. |
I've collected some events using Process Monitor, there no processes, except Attached two files with events, first one for run with |
@AntiPasha two things, first one, can you file a new issue and attach your first and last comment?This issue is old aged stale and solved in part, and I want a clean history for your one. |
@MarcoRossignoli Thank you, I've created new 857 issue fro that. It's first time, when I try to use coverlet |
I also have this problem in my multiple test projects, when I use |
I have not had the issue in a long time, I am currently using version 3.2.0 of both coverlet.collector and coverlet.msbuild. So it might have been resolved :S Thanks for all your help and time :) |
Yeah, I haven't seen it forever after updating, so I think all is good. Still running coverlet so should be fine to keep this closed. Thanks for following up :) |
When I run
dotnet test /p:CollectCoverage=true
I get the following exceptions that some dll files built by the project are opened by multiple processes:
This is my
dotnet --info
:If I remove the coverage option then the command runs fine. I do not understand why this has started happening.
The text was updated successfully, but these errors were encountered: