From: Stefano Lattarini Date: Sat, 23 Jul 2011 11:55:20 +0000 (+0200) Subject: test defs: function 'is_newest' now works also with directories X-Git-Tag: ng-0.5a~148 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b6a40fa2d2c08f71f9aeced063a36a27f657da6b;p=thirdparty%2Fautomake.git 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. --- diff --git a/ChangeLog b/ChangeLog index f5fd899b4..0aedd52ab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2011-07-23 Stefano Lattarini + + 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 docs: add references between the 2 sections on java support diff --git a/tests/defs b/tests/defs index fb0b535f5..dc7add076 100644 --- a/tests/defs +++ b/tests/defs @@ -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" } diff --git a/tests/self-check-is_newest.test b/tests/self-check-is_newest.test index f17922952..832d35203 100755 --- a/tests/self-check-is_newest.test +++ b/tests/self-check-is_newest.test @@ -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 + :