Skip to content

Inconsistent results with file filters #704

@tbutler-qontigo

Description

@tbutler-qontigo

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions