]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
fix: Don’t increment direct_cache_miss for forced recache
authorJoel Rosdahl <joel@rosdahl.net>
Tue, 22 Feb 2022 20:55:02 +0000 (21:55 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 27 Feb 2022 18:57:43 +0000 (19:57 +0100)
src/ccache.cpp
test/suites/secondary_file.bash

index 5cd02468077e3b1fd5f07d332bb5f1e28ea4987f..a9e4b21951505a97631033b4e27cc8b053b25117 100644 (file)
@@ -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()) {
index 0878a0ffda056be8aa829d800a7700f1b209009c..3c539874f224da7e4ad3d16860363bd9787d5534 100644 (file)
@@ -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
 }