From: Joel Rosdahl Date: Tue, 22 Feb 2022 20:55:02 +0000 (+0100) Subject: fix: Don’t increment direct_cache_miss for forced recache X-Git-Tag: v4.6~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1dd9b23081a2af2aa67888c750f28f433b3559ae;p=thirdparty%2Fccache.git fix: Don’t increment direct_cache_miss for forced recache --- 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 }