-
Notifications
You must be signed in to change notification settings - Fork 391
Description
Describe the bug
I am trying to collect coverage for a C# assembly and while things work just fine locally I'm having difficulties getting it to work in CI as I'm building my assembly on one runner then running the tests on another runner using that assembly.
I've tried doing this just normally without any special setup but this doesn't work as expected on different hosts because the paths inside the pdb are different on Linux vs Windows. For example the base build https://github.com/jborean93/CoverletTesting/actions/runs/7080112125/job/19267536711 produces a PDB with
I could not find any configuration option to map paths to an equivalent alternative that I've seen in other coverage tools like python coverage paths provide.
The next thing I tried was to use SourceLink and deterministic builds. I created a POC for this in the PR branch jborean93/CoverletTesting#1. When inspecting the pdb generated for the net6.0 build I can see the SourceLink was configured with a deterministic path
But unfortunately both the Linux and Windows runners report 0% coverage for the assemblies built like this.
There is a reference that deterministic builds only work for msbuild and collectors at https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/DeterministicBuild.md but I was hoping whether to clarify
- if this also includes the global tool, if so why does it have
--enable-source-link - if there are plans on adding support for it in the future
- if there are any workarounds for collecting in a subprocess not through dotnet test
To Reproduce
I've created a very basic repo that reproduces the issue when run in it https://github.com/jborean93/CoverletTesting. It can also be run locally if you have PowerShell installed on Linux or manually rename the checkout after building it.
Expected behavior
Coverage is collected
Actual behavior
No coverage is collected, there is no error but coverlet is unable to find any coverage.
Configuration (please complete the following information):
Please provide more information on your .NET configuration:
* Which coverlet package and version was used?
* 6.0.0
* Which version of .NET is the code running on?
* net6.0 (compiled with net8.0)
* What OS and version, and what distro if applicable?
* All
* What is the architecture (x64, x86, ARM, ARM64)?
* Tested on x64
* Do you know whether it is specific to that configuration?
* I don't believe so but could be wrong
Additional context
This is for PowerShell binary modules which are compiled dotnet assemblies. I'm trying to ensure that what I'm testing against is the same assembly being built which is why I'm building it first on one host then testing. I could technically build and test in the same step but that feels wrong to me especially since it may not be the same assembly that I publish. Also using a deterministic build would be nice but I don't care about that as much.
❗ Please also read Known Issues

