From 1dd9b23081a2af2aa67888c750f28f433b3559ae Mon Sep 17 00:00:00 2001 From: Joel Rosdahl Date: Tue, 22 Feb 2022 21:55:02 +0100 Subject: [PATCH] =?utf8?q?fix:=20Don=E2=80=99t=20increment=20direct=5Fcach?= =?utf8?q?e=5Fmiss=20for=20forced=20recache?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/ccache.cpp | 4 +++- test/suites/secondary_file.bash | 30 ++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/ccache.cpp b/src/ccache.cpp index 5cd024680..a9e4b2195 100644 --- a/src/ccache.cpp +++ b/src/ccache.cpp @@ -2244,7 +2244,9 @@ do_cache_compilation(Context& ctx, const char* const* argv) put_result_in_manifest = true; } - ctx.storage.primary.increment_statistic(Statistic::direct_cache_miss); + if (!ctx.config.recache()) { + ctx.storage.primary.increment_statistic(Statistic::direct_cache_miss); + } } if (ctx.config.read_only_direct()) { diff --git a/test/suites/secondary_file.bash b/test/suites/secondary_file.bash index 0878a0ffd..3c539874f 100644 --- a/test/suites/secondary_file.bash +++ b/test/suites/secondary_file.bash @@ -261,4 +261,34 @@ SUITE_secondary_file() { expect_stat secondary_storage_hit 2 expect_stat secondary_storage_miss 2 expect_file_count 3 '*' secondary # CACHEDIR.TAG + result + manifest + + # ------------------------------------------------------------------------- + TEST "Recache" + + CCACHE_RECACHE=1 $CCACHE_COMPILE -c test.c + expect_stat direct_cache_hit 0 + expect_stat direct_cache_miss 0 + expect_stat cache_miss 0 + expect_stat recache 1 + expect_stat files_in_cache 2 + expect_stat primary_storage_hit 0 + expect_stat primary_storage_miss 1 # Try to read manifest for updating + expect_stat secondary_storage_hit 0 + expect_stat secondary_storage_miss 1 # Try to read manifest for updating + expect_file_count 3 '*' secondary # CACHEDIR.TAG + result + manifest + + $CCACHE -C >/dev/null + expect_stat files_in_cache 0 + expect_file_count 3 '*' secondary # CACHEDIR.TAG + result + manifest + + CCACHE_RECACHE=1 $CCACHE_COMPILE -c test.c + expect_stat direct_cache_hit 0 + expect_stat direct_cache_miss 0 + expect_stat cache_miss 0 + expect_stat recache 2 + expect_stat files_in_cache 2 + expect_stat primary_storage_hit 0 + expect_stat primary_storage_miss 2 # Try to read manifest for updating + expect_stat secondary_storage_hit 1 # Read manifest for updating + expect_stat secondary_storage_miss 1 } -- 2.47.2