summaryrefslogtreecommitdiffstats
path: root/Tests/CTestCoverageCollectGCOV/test.cmake.in
diff options
context:
space:
mode:
authorWilliam R. Dieter <william.r.dieter@intel.com>2020-12-03 23:49:57 (GMT)
committerBrad King <brad.king@kitware.com>2021-01-28 14:05:35 (GMT)
commit49d7e0c91dffe3cae50d174474f69716632eb866 (patch)
tree8a0b96634f3b1012e021c8cd51bbcf78a2736fc6 /Tests/CTestCoverageCollectGCOV/test.cmake.in
parentf905cfdc773f8fc1221b01b74292b8d9e8140242 (diff)
downloadCMake-49d7e0c91dffe3cae50d174474f69716632eb866.zip
CMake-49d7e0c91dffe3cae50d174474f69716632eb866.tar.gz
CMake-49d7e0c91dffe3cae50d174474f69716632eb866.tar.bz2
Tests: Make GCOV test more robust to symbolic links in paths
Symbolic links in the path to the cmake build directory caused some paths to have '..' directories in the path, which are equivalent, but not a string match for the expected path. As a result, some tests fail. Signed-off-by: William R. Dieter <william.r.dieter@intel.com>
Diffstat (limited to 'Tests/CTestCoverageCollectGCOV/test.cmake.in')
-rw-r--r--Tests/CTestCoverageCollectGCOV/test.cmake.in19
1 files changed, 19 insertions, 0 deletions
diff --git a/Tests/CTestCoverageCollectGCOV/test.cmake.in b/Tests/CTestCoverageCollectGCOV/test.cmake.in
index 1818888..a36f374 100644
--- a/Tests/CTestCoverageCollectGCOV/test.cmake.in
+++ b/Tests/CTestCoverageCollectGCOV/test.cmake.in
@@ -29,6 +29,20 @@ set(expected_out
uncovered/uncovered2.cpp
)
+# A symbolic link in the path can cause tar to put an equivalent, but not
+# minimal file name to some files in the tar file. Convert paths to absolute
+# then back to relative to get them in canonical form (or maybe this is a bug
+# in how the tarball is generated?)
+function(to_relative_paths real_paths paths)
+ foreach(file ${paths})
+ file(REAL_PATH "${file}" real_path BASE_DIRECTORY "${CTEST_BINARY_DIRECTORY}")
+ file(RELATIVE_PATH relative_path "${CTEST_BINARY_DIRECTORY}" "${real_path}")
+ list(APPEND local_real_paths "${relative_path}")
+ message(DEBUG "${file} -> ${real_path} -> ${relative_path}")
+ endforeach()
+ set("${real_paths}" "${local_real_paths}" PARENT_SCOPE)
+endfunction()
+
#------------------------------------------------------------------------------#
# Test 1: with standard arguments
#------------------------------------------------------------------------------#
@@ -50,6 +64,7 @@ execute_process(COMMAND
)
string(REPLACE "\n" ";" out "${out}")
+to_relative_paths(out "${out}")
list(SORT out)
if("${out}" STREQUAL "${expected_out}")
@@ -80,6 +95,7 @@ execute_process(COMMAND
)
string(REPLACE "\n" ";" out "${out}")
+to_relative_paths(out "${out}")
list(SORT out)
if("${out}" STREQUAL "${expected_out}")
@@ -110,6 +126,7 @@ execute_process(COMMAND
)
string(REPLACE "\n" ";" out "${out}")
+to_relative_paths(out "${out}")
list(SORT out)
if("${out}" STREQUAL "${expected_out}")
@@ -140,6 +157,7 @@ execute_process(COMMAND
)
string(REPLACE "\n" ";" out "${out}")
+to_relative_paths(out "${out}")
list(SORT out)
if("${out}" STREQUAL "${expected_out}")
@@ -170,6 +188,7 @@ execute_process(COMMAND
)
string(REPLACE "\n" ";" out "${out}")
+to_relative_paths(out "${out}")
list(SORT out)
if("${out}" STREQUAL "${expected_out}")