-
Notifications
You must be signed in to change notification settings - Fork 386
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
[WIP] Implement a VSTest data collector to write coverage data to disk #329
Conversation
Codecov Report
@@ Coverage Diff @@
## master #329 +/- ##
=======================================
Coverage 86.57% 86.57%
=======================================
Files 16 16
Lines 2011 2011
=======================================
Hits 1741 1741
Misses 270 270 |
|
||
var unloadModule = injectedInstrumentationClass.GetMethod(nameof(ModuleTrackerTemplate.UnloadModule), new[] { typeof(object), typeof(EventArgs) }); | ||
if (unloadModule is null) | ||
continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this possible?Maybe this is "in process" code...binding flag etc...
I remember trying to do this as the initial implementation. I found it hard to achieve the intended end user experience due to that |
…fixes it in the future
@sharwell can I somehow help you getting this done? |
FYI we've added some new logging infos and seems that on my local I hit issue also with coverlet build #353 |
@sharwell I did some test with collectors https://github.com/Microsoft/vstest-docs/blob/master/docs/extensions/datacollector.md and I saw that it works(deriving from DataCollector not InProc)) using simply command line
question, why do we need config file? |
No one previously knew how to enable it otherwise :) |
* Move linux build to AppVeyor, no longer use Travis, update Readme to reflect move away from Travis and MyGet * relax SDK check, falling behind is handled by dotnet CLI properly already * move to dotnet test (xunit is removed in later versions) * explicit test reporter * coverlet does not work yet but hopeful coverlet-coverage/coverlet#329 fixes it in the future * include integration tests on azure pipelines * job names are not allowed spaces * disable integration tests for now against master * Update readme.md Co-Authored-By: Mpdreamz <Mpdreamz@gmail.com>
* Move linux build to AppVeyor, no longer use Travis, update Readme to reflect move away from Travis and MyGet * relax SDK check, falling behind is handled by dotnet CLI properly already * move to dotnet test (xunit is removed in later versions) * explicit test reporter * coverlet does not work yet but hopeful coverlet-coverage/coverlet#329 fixes it in the future * include integration tests on azure pipelines * job names are not allowed spaces * disable integration tests for now against master * Update readme.md Co-Authored-By: Mpdreamz <Mpdreamz@gmail.com> (cherry picked from commit 67d9b69)
* Move linux build to AppVeyor, no longer use Travis, update Readme to reflect move away from Travis and MyGet * relax SDK check, falling behind is handled by dotnet CLI properly already * move to dotnet test (xunit is removed in later versions) * explicit test reporter * coverlet does not work yet but hopeful coverlet-coverage/coverlet#329 fixes it in the future * include integration tests on azure pipelines * job names are not allowed spaces * disable integration tests for now against master * Update readme.md Co-Authored-By: Mpdreamz <Mpdreamz@gmail.com> (cherry picked from commit 67d9b69)
* Move linux build to AppVeyor, no longer use Travis, update Readme to reflect move away from Travis and MyGet * relax SDK check, falling behind is handled by dotnet CLI properly already * move to dotnet test (xunit is removed in later versions) * explicit test reporter * coverlet does not work yet but hopeful coverlet-coverage/coverlet#329 fixes it in the future * include integration tests on azure pipelines * job names are not allowed spaces * disable integration tests for now against master * Update readme.md Co-Authored-By: Mpdreamz <Mpdreamz@gmail.com> (cherry picked from commit 67d9b69)
I was testing this PR locally to see how it fixes the issue and I have a question about the implementation. With In particular this block I think and maybe the code block below it as well? I'm not too familiar with this file // Fixup the custom tracker class constructor, according to all instrumented types
if (_customTrackerRegisterUnloadEventsMethod == null)
{
_customTrackerRegisterUnloadEventsMethod = new MethodReference(
nameof(ModuleTrackerTemplate.RegisterUnloadEvents), module.TypeSystem.Void, _customTrackerTypeDef);
}
Instruction lastInstr = _customTrackerClassConstructorIl.Body.Instructions.Last();
if (!containsAppContext)
{
// For "normal" cases, where the instrumented assembly is not the core library, we add a call to
// RegisterUnloadEvents to the static constructor of the generated custom tracker. Due to static
// initialization constraints, the core library is handled separately below.
_customTrackerClassConstructorIl.InsertBefore(lastInstr, Instruction.Create(OpCodes.Call, _customTrackerRegisterUnloadEventsMethod));
} I added few log statements and I can see UnloadModule being called twice, but I'm not sure if there is any consequences to that? |
* Move linux build to AppVeyor, no longer use Travis, update Readme to reflect move away from Travis and MyGet * relax SDK check, falling behind is handled by dotnet CLI properly already * move to dotnet test (xunit is removed in later versions) * explicit test reporter * coverlet does not work yet but hopeful coverlet-coverage/coverlet#329 fixes it in the future * include integration tests on azure pipelines * job names are not allowed spaces * disable integration tests for now against master * Update readme.md Co-Authored-By: Mpdreamz <Mpdreamz@gmail.com> (cherry picked from commit 67d9b69)
Is there an easy way to get a PreRelease NuGet of this (preferably in coverlet.msbuild package) so I can test this on a project that has these symptoms? |
@kamilon usually I clone repo, checkout branch and build
you find nuget package |
@sharwell let me know if you would like some help to go on with this, if you don't have free cycles I could give it a try! |
Just to chime in here, we're seeing the error from #210 pop up with both 2.5.0 and 2.6.0 on Azure DevOps. I'll see if I can run a test with a version in our private NuGet feed |
@MarcoRossignoli It looks like using the --collect and --test-adapter-path flags isn't going to work for this collector since it is an InProc one. Looking at this code from VSTest it looks like the only way to inject an in-process data collector is through the runsettings file. |
@jmezach yes I saw, as I said above I did test deriving from DataCollector that isn't in proc, I wonder if it could work like in proc one to avoid settings file and use switches, it seems a simpler/more elegant approach to me. |
@MarcoRossignoli I tried that today, but it looks like I don't have access to the AppDomain where the instrumented code is running, so I can't call the Unload method from there. Or at least not that I can see. |
I think that is the reason to use InProc...or maybe some with out of proc we need a way to "call test process", something like pipes or block |
Implemented in #410 |
Fixes #210
Still need to register the data collector using something like this.