codecov-bash icon indicating copy to clipboard operation
codecov-bash copied to clipboard

[Swift] Implement support for llvm-cov json exporter

Open valeriomazzeo opened this issue 4 years ago • 0 comments

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.

valeriomazzeo avatar May 12 '21 15:05 valeriomazzeo