Handle missing dependency file in cache correctly

This commit is contained in:
Joel Rosdahl 2009-12-09 20:08:06 +01:00
parent 0139d90fb9
commit 8d121763f2
2 changed files with 26 additions and 2 deletions

View File

@ -814,8 +814,6 @@ static void from_cache(enum fromcache_call_mode mode, int put_object_in_manifest
if (produce_dep_file && stat(dep_file, &st) != 0) {
cc_log("Dependency file missing in cache\n");
close(fd_stderr);
unlink(stderr_file);
unlink(object_path);
free(stderr_file);
return;
}

26
test.sh
View File

@ -480,6 +480,32 @@ EOF
checkstat 'cache miss' 1
checkfile other.d "test.o: test.c test1.h test3.h test2.h"
##################################################################
# Check that a missing .d file in the cache is handled correctly.
testname="missing dependency file"
$CCACHE -z >/dev/null
$CCACHE -C >/dev/null
$CCACHE $COMPILER -c -MD test.c
checkstat 'cache hit (direct)' 0
checkstat 'cache hit (preprocessed)' 0
checkstat 'cache miss' 1
checkfile other.d "test.o: test.c test1.h test3.h test2.h"
$CCACHE $COMPILER -c -MD test.c
checkstat 'cache hit (direct)' 1
checkstat 'cache hit (preprocessed)' 0
checkstat 'cache miss' 1
checkfile other.d "test.o: test.c test1.h test3.h test2.h"
find $CCACHE_DIR -name '*.d' -exec rm -f '{}' \;
$CCACHE $COMPILER -c -MD test.c
checkstat 'cache hit (direct)' 1
checkstat 'cache hit (preprocessed)' 1
checkstat 'cache miss' 1
checkfile other.d "test.o: test.c test1.h test3.h test2.h"
##################################################################
# Reset things.
CCACHE_NODIRECT=1