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

Inconsistent results with file filters #704

Closed
tbutler-qontigo opened this issue Nov 7, 2024 · 5 comments
Closed

Inconsistent results with file filters #704

tbutler-qontigo opened this issue Nov 7, 2024 · 5 comments
Labels

Comments

@tbutler-qontigo
Copy link

Describe the bug
Goal: To filter out everything in the Base/Foo folder and sub folders and report in multiple formats

I have found a few problems trying to do this:

  1. It is unexpectedly mandatory to use \ path separators even if the source files contain / separators.
  2. Not all report types respect the exclusion even with the \ separators

To Reproduce

The sample-coverage.xml.txt file uses the / path separator so that seems like a natrual choice in the -filefilters parameter but that does not work at all with this command line:

.\ReportGenerator.exe -reports:sample-coverage.xml.txt -targetdir:./_coverage-report -reporttypes:"Html_Dark;MarkdownSummaryGithub;SonarQube" -filefilters:"-**/Base/Foo**"

Nothing at all is filtered out in any report.

Switching to \ (which is not intuitively what I should need to do) and calling:

.\ReportGenerator.exe -reports:sample-coverage.xml.txt -targetdir:./_coverage-report -reporttypes:"Html_Dark;MarkdownSummaryGithub;SonarQube" -filefilters:"-**\Base\Foo\**"

then I get variable results as follows:

SonarQuble.xml looks correct:

<?xml version="1.0" encoding="utf-8"?>
<coverage version="1">
  <file path="mySource\Base\Loggers.py">
    <lineToCover lineNumber="7" covered="true" />
  </file>
</coverage>

ie no Base/Foo references at all.

SummaryGithub.md is not quite right:

## Coverage
<details><summary>Base - 100%</summary>

|**Name**|**Line**|**Branch**|
|:---|---:|---:|
|**Base**|**100%**|****|
|Loggers.py|100%||

</details>
<details><summary>Base.Foo - </summary>

|**Name**|**Line**|**Branch**|
|:---|---:|---:|
|**Base.Foo**|****|****|

It still lists Base.Foo but does not include any coverage information, but it should not show anything at all

Html_Dark seems to be correctly excluding Base.Foo completely

Expected Outcome
Ideally I should be able to specify file (or other file-like) filters using either \ or / as I prefer, but as a minimum, the separators used in the source coverage files should be respected - if they use / then / should be allowed. I feel this latter might be a bit confusing though as, depending on the source file, (which could depend on the OS it was run on), the path separator might have to change. It would be easier from the user's perspective to use whichever path separator they are more comfortable with.

For all report types, if I have excluded particular files, they should not be reported anywhere - and indeed if excluding all of the files in a folder, or all of the tests in a file, results in nothing being covered then there should be no reference to that at all in the output - ie my exclusions have removed everything under Base/Foo so I should not see any reference at all to Base.Foo in any output. This is distinct from the files in Base/Foo having no coverage.

@danielpalme danielpalme added the bug label Nov 7, 2024
@danielpalme
Copy link
Owner

Thanks for the detailed report! I will have a look as soon as possible.

@danielpalme
Copy link
Owner

I have fixed both issues:

  • You can now use / or \ in file filters. Both have the same result
  • All report types now have the same behavior (if a module/assembly does not contain any classes, it is completely ignored)

A new release will be published next week after .NET 9 has been released.

@tbutler-qontigo
Copy link
Author

Awesome, thanks for the quick response - I will try it out once your new version is live

@danielpalme
Copy link
Owner

Release 5.4.0 is now available!

@tbutler-qontigo
Copy link
Author

Tested and working, thanks!

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

No branches or pull requests

2 participants