I've create a project on Xcode 7 that generates code coverage data.
Inside its DerivedData folder, I can run llvm-cov show
:
/usr/local/opt/llvm/bin/llvm-cov show -instr-profile Build/Intermediates/CodeCoverage/testetestes/Coverage.profdata Build/Intermediates/CodeCoverage/testetestes/Products/Debug-iphonesimulator/testetestes.framework/testetestes
This will produce an output like this:
/Users/marcelofabri/Desktop/testetestes/testetestes/Example.swift:
| 1|//
| 2|// Example.swift
| 3|// testetestes
| 4|//
| 5|// Created by Marcelo Fabri on 09/06/15.
| 6|// Copyright © 2015 Marcelo Fabri. All rights reserved.
| 7|//
| 8|
| 9|import UIKit
| 10|
| 11|class Example: NSObject {
1| 12| func testando() {
1| 13| if let url = NSURL(string: "dasdas") {
1| 14| print("ae \(url)")
0| 15| } else {
0| 16| print("oi")
0| 17| }
1| 18| }
| 19|}
/Users/marcelofabri/Desktop/testetestes/testetestes/OutraClasse.swift:
| 1|//
| 2|// OutraClasse.swift
| 3|// testetestes
| 4|//
| 5|// Created by Marcelo Fabri on 18/06/15.
| 6|// Copyright © 2015 Marcelo Fabri. All rights reserved.
| 7|//
| 8|
| 9|import UIKit
| 10|
| 11|class OutraClasse: NSObject {
| 12|
1| 13| func outroTestando() {
1| 14| if let numero = Int("123") {
1| 15| print("ae \(numero)")
0| 16| } else {
0| 17| print("oi")
0| 18| }
1| 19| }
| 20|
| 21|}
However, I'd like to get .gcov
files, since it's what most tools use. Is there a way to do this without parsing the output and creating .gcov
file manually?