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

Extraneous coverage results #33

Closed
RussKie opened this issue Jun 8, 2023 · 9 comments
Closed

Extraneous coverage results #33

RussKie opened this issue Jun 8, 2023 · 9 comments
Assignees

Comments

@RussKie
Copy link
Member

RussKie commented Jun 8, 2023

In the settings I have the following inclusions:

      <Include>
        <ModulePath>.*Microsoft.AspNetCore.*\.dll$</ModulePath>
        <ModulePath>.*Microsoft.Extensions.*\.dll$</ModulePath>
        <ModulePath>.*System.Cloud.*\.dll$</ModulePath>
      </Include>

Yet, the coverage results contain entries for "Humanizer" (and "Microsoft.IO.*" which I had to explicitly suppress). Can you please help understand why these entries get added?
image

dotnet-coverage: 17.7.1
Command: dotnet dotnet-coverage collect --settings ./eng/CodeCoverage.config --output ./artifacts/TestResults/Release//w.cobertura.xml "./build.cmd -ci -NativeToolsOnMachine -test -configuration Release "
Build: https://dev.azure.com/dnceng-public/public/_build/results?buildId=299361&view=artifacts&pathAsName=false&type=publishedArtifacts (see CodeCoverageResults)
Settings: https://github.com/dotnet/extensions/blob/cc/eng/CodeCoverage.config

@jakubch1
Copy link
Member

jakubch1 commented Jun 8, 2023

@RussKie those regexes are checked against whole ModulePath so Microsoft.AspNetCore can match directory for example. So you should make regex in that way that between Microsoft.AspNetCore and .dll you can't have any slash or backslash. I will search for correct regex.

@jakubch1
Copy link
Member

jakubch1 commented Jun 8, 2023

@RussKie on Windows you can use: <ModulePath>.*microsoft\.windowsazure\.governance\.policy[^\\]*(.dll|.exe)</ModulePath>

@RussKie
Copy link
Member Author

RussKie commented Jun 8, 2023

Thank you, I'll give it a go.

@RussKie
Copy link
Member Author

RussKie commented Jun 9, 2023

I tried that, thank you, but it didn't seem to work.
As a test I have tried only this:

      <Include>
        <ModulePath>.*System\.Cloud\.([^\\]*)\.dll$</ModulePath>
      </Include>

...yet I'm still seeing additional assemblies in the report: https://dev.azure.com/dnceng-public/public/_build/results?buildId=300859&view=codecoverage-tab

Am I doing something wrong or missing some configuration?

@jakubch1
Copy link
Member

jakubch1 commented Jun 9, 2023

@mariam-abdulla please investigate.

@mariam-abdulla
Copy link
Contributor

@RussKie I'd like to know if you can repro this locally?
If so, can you please send over the trace data collector logs?

@RussKie
Copy link
Member Author

RussKie commented Jun 15, 2023

The issue appears to only happen on Linux - e.g., here's the latest test build, and only Linux_Ubuntu.cobertura.xml contains extraneous entries (such as Microsoft.IO.RecyclableMemoryStream, Microsoft.TestUtilities, Humanizer). The Windows version doesn't contain anything nonmatching the pattern.

You can reproduce this in WSL

# setup
git clone https://github.com/Azure/dotnet-extensions-experimental.git test33
cd ./test33
<< modify eng/CodeCoverage.config >>
./build

# run code coverage
./build -testCoverage

Change eng/CodeCoverage.config as follows:

diff --git a/eng/CodeCoverage.config b/eng/CodeCoverage.config
index 1d16457..0466174 100644
--- a/eng/CodeCoverage.config
+++ b/eng/CodeCoverage.config
@@ -11,9 +11,6 @@
         <ModulePath>.*tests\.dll</ModulePath>
         <ModulePath>.*xunit.*</ModulePath>
         <ModulePath>.*moq.*</ModulePath>
-        <!-- TODO: remove when https://github.com/microsoft/codecoverage/issues/33 resolved -->
-        <ModulePath>.*Microsoft\.IO\.[^\\]+\.dll$</ModulePath>
-        <ModulePath>.*\.TestUtilities\.dll$</ModulePath>
       </Exclude>
     </ModulePaths>
...

Time Elapsed 00:00:13.73
Code coverage results: /home/user/development/dotnet-extensions-experimental/artifacts/TestResults/Debug/local.cobertura.xml.
2023-06-15T12:36:51: Arguments
2023-06-15T12:36:51:  -reports:/home/user/development/dotnet-extensions-experimental/artifacts/TestResults/Debug/*.cobertura.xml
2023-06-15T12:36:51:  -targetdir:/home/user/development/dotnet-extensions-experimental/artifacts/TestResults/Debug/CoverageResultsHtml
2023-06-15T12:36:51:  -reporttypes:HtmlInline_AzurePipelines
2023-06-15T12:36:51: File '/_/src/RecyclableMemoryStream.cs' does not exist (any more).
2023-06-15T12:36:51: File '/_/src/RecyclableMemoryStream.cs' does not exist (any more).
2023-06-15T12:36:51: File '/_/src/RecyclableMemoryStream.cs' does not exist (any more).
2023-06-15T12:36:51: File '/_/src/EventArgs.cs' does not exist (any more).
2023-06-15T12:36:51: File '/_/src/Events.cs' does not exist (any more).
2023-06-15T12:36:51: File '/_/src/RecyclableMemoryStreamManager.cs' does not exist (any more).
2023-06-15T12:36:51: File '/_/src/EventArgs.cs' does not exist (any more).
2023-06-15T12:36:51: File '/_/src/EventArgs.cs' does not exist (any more).
2023-06-15T12:36:51: File '/_/src/Events.cs' does not exist (any more).
2023-06-15T12:36:51: File '/_/src/EventArgs.cs' does not exist (any more).
2023-06-15T12:36:51: File '/_/src/EventArgs.cs' does not exist (any more).
2023-06-15T12:36:51: File '/_/src/EventArgs.cs' does not exist (any more).
2023-06-15T12:36:51: File '/_/src/EventArgs.cs' does not exist (any more).
2023-06-15T12:36:51: File '/_/src/EventArgs.cs' does not exist (any more).
2023-06-15T12:36:51: File '/_/src/EventArgs.cs' does not exist (any more).
2023-06-15T12:36:51: File '/_/src/EventArgs.cs' does not exist (any more).
2023-06-15T12:36:51: File '/_/src/EventArgs.cs' does not exist (any more).
2023-06-15T12:36:51: File '/_/src/EventArgs.cs' does not exist (any more).
2023-06-15T12:36:51: Writing report file '/home/user/development/dotnet-extensions-experimental/artifacts/TestResults/Debug/CoverageResultsHtml/index.html'
2023-06-15T12:36:52: Report generation took 0.3 seconds

Code coverage results: /home/user/development/dotnet-extensions-experimental/artifacts/TestResults/Debug/CoverageResultsHtml/index.html

can you please send over the trace data collector logs?

I'm not sure what it is or how to get those. I can tweak our build and capture logs and traces.

@mariam-abdulla
Copy link
Contributor

@RussKie, please use the following regex:
.*Microsoft\.Azure\.Extensions\.[^/\\]+\.dll$

That regex won't match the paths on both Win and Linux.

@RussKie
Copy link
Member Author

RussKie commented Jun 19, 2023

Doh! I shouldn't have realised that myself.... /facepalm. Thank you!
I've tested this, and indeed [^/\\]+ fixes my issue.

@RussKie RussKie closed this as completed Jun 19, 2023
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

No branches or pull requests

3 participants