]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
test defs: function 'is_newest' now works also with directories
authorStefano Lattarini <stefano.lattarini@gmail.com>
Sat, 23 Jul 2011 11:55:20 +0000 (13:55 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Sat, 23 Jul 2011 11:55:20 +0000 (13:55 +0200)
* tests/defs (is_newest): Call `find' with the `-prune' option,
so that it won't descend in the directories (which could cause
spurious results).
* tests/self-check-is_newest: Extend accordingly.

From a report by Jim Meyering, see automake bug#9147.

ChangeLog
tests/defs
tests/self-check-is_newest.test

index f5fd899b4ea79add1f295811ef5a00d120428522..0aedd52ab8af56e037e7829bd0f2bfa2a8ea7895 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2011-07-23  Stefano Lattarini  <stefano.lattarini@gmail.com>
+
+       test defs: function 'is_newest' now works also with directories
+       * tests/defs (is_newest): Call `find' with the `-prune' option,
+       so that it won't descend in the directories (which could cause
+       spurious results).
+       * tests/self-check-is_newest: Extend accordingly.
+       From a report by Jim Meyering, see automake bug#9147.
+
 2011-07-15  Benoit Sigoure  <tsunanet@gmail.com>
 
        docs: add references between the 2 sections on java support
index fb0b535f5e7d6b7b8e69ee4c62202e94e42d06fe..dc7add07624fd8e1c645b670cba07781a9881b5c 100644 (file)
@@ -147,7 +147,7 @@ cross_compiling ()
 # Resolve ties in favor of FILE.
 is_newest ()
 {
-  is_newest_files=`find "$@" -newer "$1"`
+  is_newest_files=`find "$@" -prune -newer "$1"`
   test -z "$is_newest_files"
 }
 
index f179229528920f1f9fddb0b6ea1073ec8705295d..832d3520392607ca90161d87e4659fbd043ceb02 100755 (executable)
@@ -39,4 +39,37 @@ stat c d || : # for debugging
 
 is_newest c d
 
+# Should work on directories too, both empty and not-empty.  An older
+# implementation of `is_newest' failed if the first argument was a
+# directory containing files newer than itself (see automake bug#9147).
+mkdir u x
+touch x/foo
+$sleep
+touch x/foo
+$sleep
+mkdir v y
+touch y/foo
+$sleep
+touch y/foo
+
+stat u v x y x/foo y/foo || : # For debugging.
+
+for older in u x; do
+  for newer in v y; do
+    is_newest $newer $older
+    is_newest $older $newer && Exit 1
+  done
+done
+
+is_newest x/foo x
+is_newest x x/foo && Exit 1
+
+touch -r x u
+is_newest x u
+is_newest u x
+
+# A couple of mild "stress" tests.
+is_newest y x u v
+is_newest y u x/foo a b c
+
 :