]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Remove any previous .stderr from cache if recaching
authorJoel Rosdahl <joel@rosdahl.net>
Thu, 9 Aug 2012 13:04:26 +0000 (15:04 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Thu, 9 Aug 2012 13:04:26 +0000 (15:04 +0200)
ccache.c
test.sh

index ccb1299970f4062894b5f04a67edf7ae73de768a..0e9348603b9d9ef4f360a03c5d964ad0cacf766e 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -722,6 +722,10 @@ to_cache(struct args *args)
                added_files += 1;
        } else {
                tmp_unlink(tmp_stderr);
+               if (conf->recache) {
+                       /* If recaching, we need to remove any previous .stderr. */
+                       x_unlink(cached_stderr);
+               }
        }
 
        if (output_to_real_object_first) {
diff --git a/test.sh b/test.sh
index 72da50b088140f1c671166d9abe29f9ab2c88cab..f1362f814d67ec5fff021302f5567350d800fb1e 100755 (executable)
--- a/test.sh
+++ b/test.sh
@@ -446,7 +446,26 @@ EOF
     fi
     checkstat 'compiler check failed' 1
 
+    testname="recache should remove previous .stderr"
+    $CCACHE -Cz >/dev/null
+    $CCACHE_COMPILE -c test1.c
+    checkstat 'cache hit (preprocessed)' 0
+    checkstat 'cache miss' 1
+    num=`find $CCACHE_DIR -name '*.stderr' | wc -l`
+    if [ $num -ne 0 ]; then
+        test_failed "$num stderr files found, expected 0 (#1)"
+    fi
+    obj_file=`find $CCACHE_DIR -name '*.o'`
+    stderr_file=`echo $obj_file | sed 's/..$/.stderr/'`
+    echo "Warning: foo" >$stderr_file
+    CCACHE_RECACHE=1 $CCACHE_COMPILE -c test1.c
+    num=`find $CCACHE_DIR -name '*.stderr' | wc -l`
+    if [ $num -ne 0 ]; then
+        test_failed "$num stderr files found, expected 0 (#2)"
+    fi
+
     testname="no object file"
+    $CCACHE -Cz >/dev/null
     cat <<'EOF' >test_no_obj.c
 int test_no_obj;
 EOF