summaryrefslogtreecommitdiff
path: root/unittest
diff options
context:
space:
mode:
authorJoel Rosdahl <joel@rosdahl.net>2022-04-03 08:59:46 +0200
committerJoel Rosdahl <joel@rosdahl.net>2022-04-03 09:06:17 +0200
commit492f3e4ab3f06694cf7cc86ead49fc7876080cc6 (patch)
treedb231d457370742aa181e27753caef043dccacd4 /unittest
parent836f76e9c02acc00925f0b3ed2ba9ae9d379b823 (diff)
downloadccache-492f3e4ab3f06694cf7cc86ead49fc7876080cc6.tar.gz
fix: Improve handling of .gcno files
When support for caching a compilation with coverage (producing a .gcno file), the commit[1] made sure to avoid rewriting the input path to relative with the motivation “also make sure to use the source file path, since this is in the notes”. However, this seems to be unnecessary since a relative input file path will be written as is to the .gcno, not the absolute path. This is the case for at least GCC 4.7+ and Clang 3.6+. Fix this by potentially converting the input path to relative even when generating coverage. When investigating the above issue, I noticed that GCC 9+ includes the current working directory (CWD) in the .gcno file. This means that we have include the CWD in the hash when compiling with -ftest-coverage/--coverage in order to replicate what the compiler would produce. Since this makes it impossible get cache hits when compiling in different directories, a new gcno_cwd sloppiness has been added for opting out of hashing the CWD, with the tradeoff of potentially getting an incorrect directory in the .gcno file. [1]: 02d3f078bd2495b8db2264ae0b2c692b4c5ba1bd Fixes #1032.
Diffstat (limited to 'unittest')
-rw-r--r--unittest/test_Config.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/unittest/test_Config.cpp b/unittest/test_Config.cpp
index c5ff92ad..07443ecb 100644
--- a/unittest/test_Config.cpp
+++ b/unittest/test_Config.cpp
@@ -130,7 +130,7 @@ TEST_CASE("Config::update_from_file")
"run_second_cpp = false\n"
"sloppiness = time_macros ,include_file_mtime"
" include_file_ctime,file_stat_matches,file_stat_matches_ctime,pch_defines"
- " , no_system_headers,system_headers,clang_index_store,ivfsoverlay\n"
+ " , no_system_headers,system_headers,clang_index_store,ivfsoverlay,gcno_cwd\n"
"stats = false\n"
"temporary_dir = ${USER}_foo\n"
"umask = 777"); // Note: no newline.
@@ -172,6 +172,7 @@ TEST_CASE("Config::update_from_file")
== (static_cast<uint32_t>(core::Sloppy::clang_index_store)
| static_cast<uint32_t>(core::Sloppy::file_stat_matches)
| static_cast<uint32_t>(core::Sloppy::file_stat_matches_ctime)
+ | static_cast<uint32_t>(core::Sloppy::gcno_cwd)
| static_cast<uint32_t>(core::Sloppy::include_file_ctime)
| static_cast<uint32_t>(core::Sloppy::include_file_mtime)
| static_cast<uint32_t>(core::Sloppy::ivfsoverlay)
@@ -415,7 +416,7 @@ TEST_CASE("Config::visit_items")
"secondary_storage = ss\n"
"sloppiness = include_file_mtime, include_file_ctime, time_macros,"
" file_stat_matches, file_stat_matches_ctime, pch_defines, system_headers,"
- " clang_index_store, ivfsoverlay\n"
+ " clang_index_store, ivfsoverlay, gcno_cwd\n"
"stats = false\n"
"stats_log = sl\n"
"temporary_dir = td\n"
@@ -474,8 +475,9 @@ TEST_CASE("Config::visit_items")
"(test.conf) run_second_cpp = false",
"(test.conf) secondary_storage = ss",
"(test.conf) sloppiness = clang_index_store, file_stat_matches,"
- " file_stat_matches_ctime, include_file_ctime, include_file_mtime,"
- " ivfsoverlay, pch_defines, system_headers, time_macros",
+ " file_stat_matches_ctime, gcno_cwd, include_file_ctime,"
+ " include_file_mtime, ivfsoverlay, pch_defines, system_headers,"
+ " time_macros",
"(test.conf) stats = false",
"(test.conf) stats_log = sl",
"(test.conf) temporary_dir = td",