-
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
Improve instrumentation tests #420
Improve instrumentation tests #420
Conversation
@@ -0,0 +1,34 @@ | |||
using System; |
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.
@tonerdo this is a key class, setup a "container" with all injectable services(for now only retry helper).
We have some "static" code(methods) so we need a domain wide model DependencyInjection.Current
provide access to all services.
I used DI framework used by ASP.NET Code inside Microsoft.Extensions.DependencyInjection
https://github.com/aspnet/Extensions
} | ||
} | ||
|
||
public static void Set(IServiceProvider serviceProvider) |
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.
this method needed to "plug new services collection" used by testing to pass mocked IRetryHelper aware of process exit and file locking.
@@ -7,8 +7,9 @@ | |||
using System.Reflection; |
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.
this file is the only file changed to use "container" low cost change.
@@ -1,3 +1,4 @@ | |||
using Coverlet.Core.Abstracts; |
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.
Here we simply make RetryHelper an injectable "instance" type that implements IRetryHelper.
<PackageReference Include="Mono.Cecil" Version="0.10.1" /> | ||
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" /> | ||
<PackageReference Include="Newtonsoft.Json" Version="10.0.1" /> |
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.
I change this to 10 because Newtosolft has got a bug on 9.0.1 and cannot use TypeConverter in a correct way, this lead to exception during serialization of CoveragePrepareResult
in testing.
MSbuild/VSTest collectors does not load this version but version 10.0.1 this is the reason why it works today(unexpected 😄).
Maybe @vagisha-nidhi has got some details on this.
@@ -54,5 +60,48 @@ public void TestCoverageWithTestAssembly() | |||
|
|||
directory.Delete(true); | |||
} | |||
|
|||
[Fact] | |||
public void Condition_If() |
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.
|
||
namespace Coverlet.Core.Samples.Tests | ||
{ | ||
public class Conditions |
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.
Added new file for new "class" of tests.
Wrote a "pilot" test.
I need to fix post build copy on linux, let me fix |
Fail on unix...I'm investigating. |
Found the issue, race between |
22d4c20
to
40450fc
Compare
|
||
namespace Coverlet.Core.Abstracts | ||
{ | ||
public interface IProcessExitHandler |
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.
We need this service to plug a fake in child process to avoid race condition on restore module.
In normal condition(no exception) we restore modules during coverage calculation, after @ViktorHofer update we restore also other instrumented module on exit, on msbuild/console/collector we use a shared dictionary but on test we instrument and run on child process so parent/child race on restore/delete files.
On child test we'll do nop.
Bonus, improved coverage
Post
@tonerdo we lost codecov report. |
@tonerdo great thank's for WIP! |
@tonerdo can you review this?So we can go on with "core instrumentation" fix and improve test coverage . |
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.
LGTM!
contributes to #387
@tonerdo @petli with this PR we've a way to test the "reality" of instrumentation and coverage calculation.
What we have:
RemoteExecutor.Invoke
that allow us to run a "lambda" in remote process to avoid issue with statics and file locks 🚀 🚀 🚀