codecov / codecov-bash

Global coverage report uploader for Codecov
https://codecov.io
Apache License 2.0
234 stars 155 forks source link

[Swift] Implement support for llvm-cov json exporter #431

Open valeriomazzeo opened 3 years ago

valeriomazzeo commented 3 years ago

swift package generate-xcodeproj is deprecated and will soon be removed.

This means that the preferred way to generate code coverage for projects that only supports Swift SPM going forward, will be to use:

swift test --enable-code-coverage

The above command generates a codecov directory with a *.profdata file and a JSON with the code coverage information in the following format https://github.com/llvm/llvm-project/blob/main/llvm/tools/llvm-cov/CoverageExporterJson.cpp.

Although codecov-bash could use *.profdata to build a txt report. It fails because it expects *.xctests file to be available in the same directory as *.profdata; this is the case when using Xcode but not when using swift tests - in the latter *.xctests files are in the directory one level above.

codecov-bash could be modified to find the proper input files when using SPM and generate the txt coverage file as usual. Although, it's a redundant operation since the code coverage file has already been exported in JSON; it would make more sense then to just allow codecov-bash to find and parse this file directly.