Last active
November 26, 2021 09:49
-
-
Save Alexander-Ignition/ec2ace26adcdd8e94fe23c3c75980430 to your computer and use it in GitHub Desktop.
Swift pacakge manager code coverage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'pathname' | |
| # Swift pacakge manager code coverage | |
| # | |
| # Usage: | |
| # ruby codecov.rb $(swift test --show-codecov-path) | |
| class Codecov | |
| def initialize(path) | |
| # /Users/<user-name>/<package-name>/.build/x86_64-apple-macosx/debug/codecov/<package-name>.json | |
| @path = Pathname.new(path) | |
| end | |
| def profdata | |
| @path.parent + 'default.profdata' | |
| end | |
| def package_name | |
| @package_name ||= @path.basename(".json") | |
| end | |
| def executable | |
| @path.parent.parent + "#{package_name}PackageTests.xctest/Contents/MacOS/#{package_name}PackageTests" | |
| end | |
| def report | |
| command = %Q(xcrun llvm-cov report #{executable} -instr-profile=#{profdata} -ignore-filename-regex=".build|Tests") | |
| system(command, exception: true) | |
| end | |
| end | |
| Codecov.new(*ARGV).report |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment