SlatherOrg / slather

Generate test coverage reports for Xcode projects & hook it into CI.
MIT License
1.55k stars 236 forks source link

2.8.1 version causing report generated empty #561

Closed ivanvillarfreire closed 3 months ago

ivanvillarfreire commented 3 months ago

Good afternoon.

After 2.8.1 release of this Saturday, I detected how the following combination on the environment causes that the SonarQube report is simply generated empty:

To be honest, I'm not sure what additional data to report. The fact is that simply rolling back to Slather 2.8.0, it works just fine again. To be more specific, the only change is

gem "slather"

To:

gem "slather","2.8.0"

And as I mentioned, with Xcode 15 + Mac OS 13, it worked again.

Please, feel free to request additional information you may consider useful

agustindeleon7 commented 3 months ago

We have the same issue; to fix it, we added the --source-files parameter to the command.

Also, we have the following issue when the SonarQube command is running

ERROR: Cobertura Report not found sonar-reports/cobertura.xml
java.io.FileNotFoundException: https://cobertura.sourceforge.net/xml/coverage-04.dtd
jarrodlombardo-EventBase commented 3 months ago

@dnedrow Could https://github.com/SlatherOrg/slather/compare/v2.8.0...v2.8.1#diff-00a272bc00e0a9bff41ccff223365b313ec7c2fc5204c512e35806802a122668R188 have caused this? I think that line may now require explicitly setting the source files.

dnedrow commented 3 months ago

I'll take a look at the logic ASAP. I'm sure I tested this, but clearly something is wrong.

scottasoutherland commented 3 months ago

Perhaps it's a different issue. But we seem to be experiencing this also when upgrading from 2.8.0 to 2.8.1 , and we do explicitly set --source-files .

jarrodlombardo-EventBase commented 3 months ago
java.io.FileNotFoundException: https://cobertura.sourceforge.net/xml/coverage-04.dtd

This issue is something separate from the 2.8.1 upgrade since it was happening in 2.8.0 also since http://cobertura.sourceforge.net/xml/coverage-04.dtd and https://cobertura.sourceforge.net/xml/coverage-04.dtd both don't exist (my change in 2.8.1 only added the s to https).

Those bad links are still used by many tools though (e.g. gcovr 7.2 https://gcovr.com/en/stable/output/cobertura.html ) and I don't yet know what url to update it to.

Update: https://raw.githubusercontent.com/cobertura/cobertura/master/cobertura/src/site/htdocs/xml/coverage-04.dtd seems to be the new/best URL. I'll update that in another PR, but that's not a fix for this issue.

gaige commented 3 months ago

I think we're seeing the same issue with 2.8.1. We're using fastlane to call slather. Version 2.8.0 worked fine, no other changes and reverting our Gemfile to 2.8.0 made the problem go away.

jarrodlombardo-EventBase commented 3 months ago

Everyone saying "same issue" means the issue in the OP, right?

After 2.8.1 release of this Saturday, I detected how the following combination on the environment causes that the SonarQube report is simply generated empty:

  • Xcode 15
  • Mac OS 13

To be honest, I'm not sure what additional data to report. The fact is that simply rolling back to Slather 2.8.0, it works just fine again. To be more specific, the only change is

gem "slather"

To:

gem "slather","2.8.0"

And as I mentioned, with Xcode 15 + Mac OS 13, it worked again.

Please, feel free to request additional information you may consider useful

Anyone seeing that, please post the log output of your slather run on 2.8.1 and also on 2.8.0 here so we can continue to investigate.

cah-iswaria-sasi commented 3 months ago

Even i am facing the same kinda problem, i was generating slather(sonarqube_xml: true) for sonarqube generic coverage format, .xml file is empty with no data.. verified that profdata and binary files are properly generated

gaige commented 3 months ago

@jarrodlombardo-EventBase Yes, in my case, same problem as the OP. After upgrading to 2.8.1 report is empty. Backing off to 2.8.0 resumes reporting the same information as I was seeing prior to the attempted upgrade. I’m using macOS 14.5 (and beta macOS 15) and Xcode 15.4 (although same problem with 16.0).

jarrodlombardo-EventBase commented 3 months ago

After upgrading to 2.8.1 report is empty. Backing off to 2.8.0 resumes reporting the same information as I was seeing prior to the attempted upgrade. I’m using macOS 14.5 (and beta macOS 15) and Xcode 15.4 (although same problem with 16.0).

Please share the slather output though. Just "report is empty" isn't enough for us to debug what has gone wrong.

gaige commented 3 months ago

@jarrodlombardo-EventBase Sure. Not a ton to go on here. I run through fast lane, although I think the messages are representative. They are also (except for the timestamps) identical to what I get with 2.8.0 that works:

INFO [2024-06-19 03:18:27.03]: ▸ Slathering...
INFO [2024-06-19 03:18:27.95]: ▸ warning: /Users/buildbot/Library/Developer/Xcode/DerivedData/CTUtils-bpbkyopbzzryfjdfgbjduymttvbs/Build/Products/Debug-iphonesimulator/CTUtils.framework/CTUtils: profile data may be out of date - object is newer
INFO [2024-06-19 03:18:27.97]: ▸ warning: /Users/buildbot/Library/Developer/Xcode/DerivedData/CTUtils-bpbkyopbzzryfjdfgbjduymttvbs/Build/Products/Debug-iphonesimulator/CTUtils.framework/CTUtils: profile data may be out of date - object is newer
INFO [2024-06-19 03:18:28.01]: ▸ warning: /Users/buildbot/Library/Developer/Xcode/DerivedData/CTUtils-bpbkyopbzzryfjdfgbjduymttvbs/Build/Products/Debug-iphonesimulator/CTUtilsTest.xctest/CTUtilsTest: profile data may be out of date - object is newer
INFO [2024-06-19 03:18:28.01]: ▸ warning: 1 functions have mismatched data
INFO [2024-06-19 03:18:28.02]: ▸ warning: /Users/buildbot/Library/Developer/Xcode/DerivedData/CTUtils-bpbkyopbzzryfjdfgbjduymttvbs/Build/Products/Debug-iphonesimulator/CTUtilsTest.xctest/CTUtilsTest: profile data may be out of date - object is newer
INFO [2024-06-19 03:18:28.02]: ▸ warning: 1 functions have mismatched data
INFO [2024-06-19 03:18:28.16]: ▸ Slathered
<?xml version="1.0"?>
<!DOCTYPE coverage SYSTEM "https://cobertura.sourceforge.net/xml/coverage-04.dtd">
<coverage line-rate="1.0000000000000000" branch-rate="1.0000000000000000" lines-covered="0" lines-valid="0" branches-covered="0" branches-valid="0" complexity="0.0" timestamp="1718702245" version="Slather 2.8.1">
  <sources>
    <source>/Users/buildbot/builds/gaige/CTUtils</source>
  </sources>
  <packages/>
</coverage>

The path is the same as in versions that succeed. The full file is ~.5M, but the start is:

<?xml version="1.0"?>
<!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-04.dtd">
<coverage line-rate="0.8789649415692822" branch-rate="0.8459418837675351" lines-covered="4212" lines-valid="4792" branches-covered="3377" branches-valid="3992" complexity="0.0" timestamp="1718780850" version="Slather 2.8.0">
  <sources>
    <source>/Users/buildbot/builds/gaige/CTUtils</source>
  </sources>
  <packages>
    <package name="." line-rate="0.8789649415692822" branch-rate="0.8459418837675351" complexity="0.0">
      <classes>
        <class name="CTArrayUtils.m" filename="CTArrayUtils.m" line-rate="1.0000000000000000" branch-rate="1.0000000000000000" complexity="0.0">
          <methods/>
          <lines>
            <line number="19" branch="true" hits="3" condition-coverage="100% (1/1)">
              <conditions>
                <condition number="0" type="jump" coverage="100%"/>
              </conditions>
            </line>

Let me know if you think the full file would help.

cah-iswaria-sasi commented 3 months ago

This is what i am getting for sonarqube_xml format:

sonarqube-generic-coverage.xml: report is empty. i have verified .profdata nd binary files are generating properly under each packages. earlier was using 2.7.5 slather, was working fine.. suddenly it stopped working.

means, .xml file is empty . i am using slather 2.8.0 fastlane 2.221.1 ruby 3.3.3 bundler 2.5.13 xcode version 15+

its working fine in my local, can see .xml fine.. i have upgraded versions on Build Machine (Mac) same to my local , but in BM its not working as expected. .xml file is empty

sonarqube_xml, its failing to generate .xml file for coverage

cah-iswaria-sasi commented 3 months ago

pls fix as soon as possible.

jarrodlombardo-EventBase commented 3 months ago

@dnedrow Could v2.8.0...v2.8.1#diff-00a272bc00e0a9bff41ccff223365b313ec7c2fc5204c512e35806802a122668R188 have caused this? I think that line may now require explicitly setting the source files.

In my testing today, coverage_file.include_file? is always false when --source_files is not included. I've got a PR I'll put up shortly to fix it.

jarrodlombardo-EventBase commented 3 months ago

Also, it seems that the --source_files and --ignore globs have to be relative to the dir slather was called from (there's a relative_path_from(Pathname("./").realpath) called on each potential source file), not globs relative to the project path.

ksuther commented 3 months ago

563 released as 2.8.2. Thanks for the fix!