What is the Linux equivalent of `xcrun llvm-cov ...`?

After running swift test I am currently running llvm-cov-9 export -format="lcov" .build/debug/MyPackageTests.xctest -instr-profile .build/debug/codecov/default.profdata > info.lcov on Linux (inside a GitHub Workflow) but what I actually want is to use the llvm-cov version that is appropriate for the current swift installation. On macOS I could just use xcrun llvm-cov ... (If Xcode didn't generate coverage for me automatically), is there an equivalent to that on Linux?

llvm-cov is included into the Swift toolchains on Linux, under swift-VERSION-platform/usr/bin โ€“ you could just call it by its path, if you know where the Swift toolchain is installed.

1 Like

So in my case (GitHub Actions) it is /usr/share/swift/usr/bin/llvm-cov according to this: virtual-environments/swift.sh at af562625fc7b77ba4edf64b9be33de7d5746b541 ยท actions/virtual-environments (github.com)

But I think this should be a universal solution: "$(dirname "$(realpath "$(which swift)")")/llvm-cov"

I tested it and it works, thanks for the help!

2 Likes