mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Previously the path to covered files in the __LLVM_COV / __llvm_covmap section were absolute. This made remote builds with coverage information difficult because all machines would have to have the same build root. This change uses the values for `-coverage-prefix-map` to remap files in the coverage info to relative paths. These paths work correctly with llvm-cov when it is run from the same source directory as the compilation, or from a different directory using the `-path-equivalence` argument. This is analogous to this change in clang https://reviews.llvm.org/D81122
17 lines
915 B
Swift
17 lines
915 B
Swift
// %s expands to an absolute path, so to test relative paths we need to create a
|
|
// clean directory, put the source there, and cd into it.
|
|
// RUN: rm -rf %t
|
|
// RUN: mkdir -p %t/foo/bar/baz
|
|
// RUN: cp %s %t/foo/bar/baz/coverage_relative_path.swift
|
|
// RUN: cd %t/foo/bar
|
|
|
|
// RUN: %target-swift-frontend -profile-generate -profile-coverage-mapping -Xllvm -enable-name-compression=false -emit-ir baz/coverage_relative_path.swift | %FileCheck -check-prefix=ABSOLUTE %s
|
|
//
|
|
// ABSOLUTE: @__llvm_coverage_mapping = {{.*"\\01.*foo.*bar.*baz.*coverage_relative_path\.swift}}
|
|
|
|
// RUN: %target-swift-frontend -profile-generate -profile-coverage-mapping -Xllvm -enable-name-compression=false -coverage-prefix-map $PWD=. -emit-ir baz/coverage_relative_path.swift | %FileCheck -check-prefix=RELATIVE %s
|
|
//
|
|
// RELATIVE: @__llvm_coverage_mapping = {{.*"\\01[^/]*}}.{{/|\\}}baz{{.*coverage_relative_path\.swift}}
|
|
|
|
func coverage() {}
|