Skip to content
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

Add [xunit*]* to default excluded modules filter if not specified #462

Merged

Conversation

MarcoRossignoli
Copy link
Collaborator

@MarcoRossignoli MarcoRossignoli requested a review from tonerdo June 10, 2019 14:09
@MarcoRossignoli MarcoRossignoli changed the title Add [xunit*]* to default excluded modules filter if not specified [WIP]Add [xunit*]* to default excluded modules filter if not specified Jun 10, 2019
@MarcoRossignoli
Copy link
Collaborator Author

msbuild test
image

image

@MarcoRossignoli
Copy link
Collaborator Author

Test with console

C:\git\coverlet\src\coverlet.console\bin\Debug\netcoreapp2.2 (defaultexcludedfiles -> origin)
λ dotnet coverlet.console.dll "C:\git\coverlet\test\coverlet.core.tests\bin\Debug\netcoreapp2.0\coverlet.core.tests.dll" --target "dotnet" --targetargs "test C:\git\coverlet\test\coverlet.core.tests\coverlet.core.tests.csproj --no-build" --verbosity detailed
Excluded module filter '[xunit*]*'
Instrumented module: 'C:\git\coverlet\test\coverlet.core.tests\bin\Debug\netcoreapp2.0\coverlet.core.dll'
Excluded module: 'C:\git\coverlet\test\coverlet.core.tests\bin\Debug\netcoreapp2.0\xunit.runner.reporters.netcoreapp10.dll'
Excluded module: 'C:\git\coverlet\test\coverlet.core.tests\bin\Debug\netcoreapp2.0\xunit.runner.utility.netcoreapp10.dll'
Excluded module: 'C:\git\coverlet\test\coverlet.core.tests\bin\Debug\netcoreapp2.0\xunit.runner.visualstudio.dotnetcore.testadapter.dll'
Test run for C:\git\coverlet\test\coverlet.core.tests\bin\Debug\netcoreapp2.0\coverlet.core.tests.dll(.NETCoreApp,Version=v2.0)
Microsoft (R) Test Execution Command Line Tool Version 16.1.0
Copyright (c) Microsoft Corporation.  All rights reserved.
Starting test execution, please wait...
[xUnit.net 00:00:01.4208241]     Coverlet.Core.Tests.Instrumentation.ModuleTrackerTemplateTests.HitsOnMultipleThreadsCorrectlyCounted [SKIP]
  ! Coverlet.Core.Tests.Instrumentation.ModuleTrackerTemplateTests.HitsOnMultipleThreadsCorrectlyCounted [1ms]
[xUnit.net 00:00:03.7948155]     Coverlet.Core.Instrumentation.Tests.InstrumenterTests.TestCoreLibInstrumentation [SKIP]
  ! Coverlet.Core.Instrumentation.Tests.InstrumenterTests.TestCoreLibInstrumentation [1ms]
Test Run Successful.
Total tests: 113
     Passed: 111
    Skipped: 2
 Total time: 4,5155 Seconds
C:\git\coverlet\src\coverlet.console\bin\Debug\netcoreapp2.2 (defaultexcludedfiles -> origin)
λ dotnet coverlet.console.dll "C:\git\coverlet\test\coverlet.core.tests\bin\Debug\netcoreapp2.0\coverlet.core.tests.dll" --target "dotnet" --targetargs "test C:\git\coverlet\test\coverlet.core.tests\coverlet.core.tests.csproj --no-build" --verbosity detailed --exclude AAA
Excluded module filter 'AAA'
Instrumented module: 'C:\git\coverlet\test\coverlet.core.tests\bin\Debug\netcoreapp2.0\coverlet.core.dll'
Instrumented module: 'C:\git\coverlet\test\coverlet.core.tests\bin\Debug\netcoreapp2.0\xunit.runner.reporters.netcoreapp10.dll'
Instrumented module: 'C:\git\coverlet\test\coverlet.core.tests\bin\Debug\netcoreapp2.0\xunit.runner.utility.netcoreapp10.dll'
Instrumented module: 'C:\git\coverlet\test\coverlet.core.tests\bin\Debug\netcoreapp2.0\xunit.runner.visualstudio.dotnetcore.testadapter.dll'
Test run for C:\git\coverlet\test\coverlet.core.tests\bin\Debug\netcoreapp2.0\coverlet.core.tests.dll(.NETCoreApp,Version=v2.0)
Microsoft (R) Test Execution Command Line Tool Version 16.1.0
Copyright (c) Microsoft Corporation.  All rights reserved.
Starting test execution, please wait...
[xUnit.net 00:00:01.5159707]     Coverlet.Core.Tests.Instrumentation.ModuleTrackerTemplateTests.HitsOnMultipleThreadsCorrectlyCounted [SKIP]
  ! Coverlet.Core.Tests.Instrumentation.ModuleTrackerTemplateTests.HitsOnMultipleThreadsCorrectlyCounted [1ms]
[xUnit.net 00:00:03.9041438]     Coverlet.Core.Instrumentation.Tests.InstrumenterTests.TestCoreLibInstrumentation [SKIP]
  ! Coverlet.Core.Instrumentation.Tests.InstrumenterTests.TestCoreLibInstrumentation [1ms]
Test Run Successful.
Total tests: 113
     Passed: 111
    Skipped: 2
 Total time: 4,7460 Seconds

@MarcoRossignoli MarcoRossignoli changed the title [WIP]Add [xunit*]* to default excluded modules filter if not specified Add [xunit*]* to default excluded modules filter if not specified Jun 10, 2019
@MarcoRossignoli
Copy link
Collaborator Author

@vagisha-nidhi PTAL

@MarcoRossignoli
Copy link
Collaborator Author

PS. x @tonerdo, all this non-testable code of console/msbuild makes me a bit nervous 😄 we should inject everything #410 (comment), collectors are completely testable, I don't need any manual test.

@vagisha-nidhi
Copy link
Contributor

@vagisha-nidhi PTAL

LGTM! 👍

@@ -57,6 +57,12 @@ static int Main(string[] args)
logger.Level = verbosity.ParsedValue;
}

// We add default exclusion filter if no specified
if (excludeFilters.Values.Count == 0)
Copy link
Contributor

@pape77 pape77 Jul 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, why did we chose to include if Count == 0 instead of excludeFilters.Values.Contains("[xunit*]*")?
Since i cannot think an scenario in which we want to include this dlls, and maybe we forgot to include it in our custom exclude filters. Or we missincluded it using the wrong wildcards or whatever
@MarcoRossignoli

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment says "We add default exclusion filter if no specified" but you are not adding the CoverletConstants. DefaultExcludeFilter here, but the xunit one, which i find confusing

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since i cannot think an scenario in which we want to include this dlls

The idea is to remove only in default config...after first include users win.

Copy link
Contributor

@pape77 pape77 Jul 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When are you adding the CoverletConstants. DefaultExcludeFilter btw?
Not sure about the code, but if this later goes into CoverletSettingsParser then it will never reach the code you added in that file (the if statement), since you add this before reaching that part, and then all it does is add the constants, so count is always 2
If you pass some custom exclude filters as argument, here you don't add xunit, and later count will be >1 , then your if statement is also not excecuted...

Copy link
Collaborator Author

@MarcoRossignoli MarcoRossignoli Jul 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CoverletConstants.DefaultExcludeFilter is needed only by collector.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Today we've 3 entry point/driver for coverlet console/msbuild/collector they behave in a different way on defaults.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check manual tests FYI
#462 (comment)
#462 (comment)

@@ -131,6 +131,13 @@ private string[] ParseExcludeFilters(XmlElement configurationElement)
}
}

// if we've only one element mean that we only added CoverletConstants.DefaultExcludeFilter
Copy link
Contributor

@pape77 pape77 Jul 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't make that assumption, but more like excludeFilters.Contains(CoverletConstants.DefaultExcludeFilter) && excludeFilters.Count==1
is way safer.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CoverletConstants.DefaultExcludeFilter will be always present

@pape77
Copy link
Contributor

pape77 commented Jul 2, 2019

Why not including xunit to the CoverletConstants.DefaultExcludeFilter directly?
Or someone might name it's project xunit as well and then it's on a dll? By default they will be screwed as well anyways :P

@MarcoRossignoli
Copy link
Collaborator Author

Or someone might name it's project xunit as well and then it's on a dll?

If we fix that filter we won't have plan b for possible name collision

@pape77
Copy link
Contributor

pape77 commented Jul 2, 2019

Or someone might name it's project xunit as well and then it's on a dll?

If we fix that filter we won't have plan b for possible name collision

Same for [coverlet*]*] :)
It's more easily fixable from the user side, to just rename their project to something that doesn't start with xunit and done...
You may argue is more unlikely to use that same name for a project but maybe same for xunit.
Now you have different custom behaviour when you include or not a filter. So you have to remember to also exclude xunit if you decide to exclude something by yourself (bit annoying)

Btw. My pr which i pointed before, magically excluded all dlls that have nothing to do to your code itself without any exclude filters. You might want to take a look to see if it's still applicable.
That's what I'm currently using as a fork

@MarcoRossignoli
Copy link
Collaborator Author

Sure @pape77 we can go on with discussion on that PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add [xunit*]* to default excluded modules filter
4 participants