]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
test: Add and use postdate function for making future filestamps
authorJoel Rosdahl <joel@rosdahl.net>
Tue, 22 Oct 2024 16:48:27 +0000 (18:48 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Tue, 22 Oct 2024 16:48:27 +0000 (18:48 +0200)
test/run
test/suites/base.bash

index cb176050947d9fe32f9a52e17d704182458450a6..e098875a2322bf6e5998c7a4d65491b8ef0167e7 100755 (executable)
--- a/test/run
+++ b/test/run
@@ -141,6 +141,10 @@ backdate() {
     touch -t $((199901010000 + m)) "$@"
 }
 
+postdate() {
+    touch -t "$(($(date -u +%Y) + 1))01030000" "$@"
+}
+
 file_size() {
     wc -c $1 | awk '{print $1}'
 }
index f2af87009fcfff347a1e18acc886041f4e3164c8..6cbbaaeb6f33fd154c68c90a68a8a2bd6e6a4613 100644 (file)
@@ -284,9 +284,7 @@ fi
     # -------------------------------------------------------------------------
     TEST "Too new source file"
 
-    futuretimestamp=$(expr 1 + $(date -u +%Y))01030000
-    touch new.c
-    touch -t $futuretimestamp new.c
+    postdate new.c
 
     $CCACHE_COMPILE -c new.c
     expect_stat modified_input_file 1
@@ -305,7 +303,7 @@ EOF
     cat <<EOF >new.h
 int test;
 EOF
-    touch -t $futuretimestamp new.h
+    postdate new.h
 
     $CCACHE_COMPILE -c new.c
     expect_stat modified_input_file 1
@@ -318,8 +316,7 @@ EOF
     # -------------------------------------------------------------------------
     TEST "Too new source file ignored if sloppy"
 
-    touch new.c
-    touch -t $futuretimestamp new.c
+    postdate new.c
 
     CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS include_file_mtime" $CCACHE_COMPILE -c new.c
     expect_stat cache_miss 1