-
Notifications
You must be signed in to change notification settings - Fork 386
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
lcov file is empty when using C# source generator #1099
Comments
Here's a portion of the host log:
Do all this "no"s mean there's something wrong? |
Am I correct in that unit test only references this project file: It has these two project references in turn:
For which of the projects are you getting coverage output? |
@petli Hi! I'm using GitHub actions to build the solution. Let me point to results that I'm getting. On the name: Build and test
on: [push]
jobs:
windows:
runs-on: windows-latest
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1.7.2
with:
dotnet-version: '5.0.x'
- name: Test source generator
run: dotnet test ./NetFabric.Hyperlinq.SourceGenerator.UnitTests/NetFabric.Hyperlinq.SourceGenerator.UnitTests.csproj
- name: Build solution
run: dotnet build
- name: Tests and coverage
run: dotnet test ./NetFabric.Hyperlinq.UnitTests/NetFabric.Hyperlinq.UnitTests.csproj -f:net5.0 -p:CollectCoverage=true -p:CoverletOutputFormat=lcov -p:CoverletOutput=TestResults/ /p:ExcludeByAttribute="GeneratedCodeAttribute" /p:ExcludeByFile="../NetFabric.Hyperlinq.Interfaces/*.cs"
- name: Publish coverage report to coveralls.io
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ./NetFabric.Hyperlinq.UnitTests/TestResults/coverage.net5.0.info You can see in Coveralls that it only includes coverage from classes in Please ignore the After many attempts, I decided to try VS Test integration instead. It can be found in the name: Build and test
on: [push]
jobs:
windows:
runs-on: windows-latest
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1.7.2
with:
dotnet-version: '5.0.x'
- name: Test source generator
run: dotnet test ./NetFabric.Hyperlinq.SourceGenerator.UnitTests/NetFabric.Hyperlinq.SourceGenerator.UnitTests.csproj
- name: Build solution
run: dotnet build
- name: Tests and coverage
run: dotnet test ./NetFabric.Hyperlinq.UnitTests/NetFabric.Hyperlinq.UnitTests.csproj -f:net5.0 -c:Release --collect:"XPlat Code Coverage" --settings coverlet.runsettings
- name: Get path to lcov file
id: get_lcov_path
shell: bash
run: printf '::set-output name=lcov_path::%s\n' ./NetFabric.Hyperlinq.UnitTests/TestResults/*/coverage.info
- name: Publish coverage report to coveralls.io
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ${{ steps.get_lcov_path.outputs.lcov_path }} with the <?xml version="1.0" encoding="utf-8" ?>
<RunSettings>
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="XPlat code coverage">
<Configuration>
<Format>lcov</Format>
<Include>[NetFabric.Hyperlinq]*</Include>
<Exclude>[NetFabric.Assertive]*</Exclude>
<UseSourceLink>true</UseSourceLink>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
</RunSettings> Now I get the following:
This is because the file Sorry for wasting your time but I've tried everything I could... |
EDIT: I think I misunderstood, so I've removed this comment. I need to think a bit more to understand what's happening. |
I think I found it, have a look at this comment: #1084 (comment) When I modify https://github.com/NetFabric/NetFabric.Hyperlinq/blob/Coverage/NetFabric.Hyperlinq.SourceGenerator/OverloadsGenerator.cs#L40 to change the file ending to |
Oh! So, it was the source generator... |
Hi! Opening this issue again because it's still not fully working.
Should |
That logs looks strange we generate only |
That JSON is from the Comparing the two outputs, as you suggested: When I use VSTest integration the result is
and generates a 2,293 KB When I use MSBuild integration the result is
and generates a 2,296 KB The diff shows that the So, this is no longer related to the C# code generator. Maybe I should file a different issue... |
If you see difference between VSTest integration(collectors) and msbuild integration(less coverage) it's likely you're hitting a known issue related to test engine behavior https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/KnownIssues.md#vstest-stops-process-execution-early The most reliable way for coverlet is VSTest collectors integration. |
It's good to know that the most reliable is VSTest collectors integration and that's what I'm trying to use but unsuccessfully. For me, it's not reporting 0% coverage. It's not reporting. The outputs I show above come from the command line, not CI. Note that for VSTest integration there are no tables shown. I have it working with MSBUILD integration: https://coveralls.io/github/NetFabric/NetFabric.Hyperlinq |
These are the differences between integrations https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/DriversFeatures.md |
Do you have the filename/class/lines details? |
I'm going to close this issue. I'm not sure if the issue is with coverlet or CoverAlls. It works with MSBUILD integration but not with VSTest integration. |
Sorry for delay @aalmada super busy period, anyway should work also with vstest, I'll keep this open for future investigation |
I ran into a similar issue and was able to replicate it using a simple hello world project and the command line. Repo repository here - https://github.com/potatopeelings/coverlet1099 with coverlet.msbuild 3.0.3 I have 3 projects
If I do
I get no
If I simply remove the reference to the generator project, I get the expected
Note: I was running into some weird caching like issues when trying to replicate (I had to sometimes remove and re-add the generator project reference for it to stick). Usually toggling the project reference and rerunning a couple of times sorted that out. |
@potatopeelings Your issue is likely that the generated file does not end in |
@petli I don't emit any files in that - the source generator generated classes get directly added to the compilation. edits:
|
As I understand it a source generator always emits files, and you say what file name should be when it is generated with the first parameter to |
Thanks! That worked. I seem to have misunderstood the Apologies for the false alarm. |
Glad it worked, @potatopeelings! Those files end up in the |
Closing for stale conversation, feel free to reopen if needed. |
I've been using Coverlet with Coveralls on my project for a long time. I don't know when it started happening but now the report only includes methods from a dependent project.
I'm using the latest versions of
xunit
,Microsoft.NET.Test.Sdk
, andcoverlet.collector
. I'm usingnet5. 0
.In the command line I'm typing:
dotnet test ./NetFabric.Hyperlinq.UnitTests/NetFabric.Hyperlinq.UnitTests.csproj -f:net5.0 -c:Release --collect:"XPlat Code Coverage" --settings coverlet.runsettings --diag:log.txt
The
coverlet.runsettings
file only has the following:In the generated logs I can see references to the classes of my main project but they keep not showing up in the
coverage.info
file.The text was updated successfully, but these errors were encountered: