Subject: Re: bug#9147: 6 test failures on Fedora 15 with latest from git

From: Stefano Lattarini <[email-masked]>
Date: Sat, 23 Jul 2011 14:43:11 +0200

On Friday 22 July 2011, Jim Meyering wrote:
> Stefano Lattarini wrote:
> > Hi Jim, thanks for the report.
> 
> Hi Stefano,
> 
> Thanks for the quick response.
> 
> >> I built the latest and ran "make check TESTSUITEFLAGS=-j20" on Fedora 15.
> >>
> > Note that the `TESTSUITEFLAGS' variable has no effect on Automake-generated
> > testsuite harness.  What you probably wanted was simply "make check -j20".
> ...
> >
> > A fix for these failures (which I've only encountered when running the
> > automake testsuite with Linux -> MinGW cross compilers) should have
> > been applied to the testsuite-work branch some time ago (see commit
> > `v1.11-871-geb147a1', "lex tests: avoid spurious failures when LEXLIB
> > isn't found").
> 
> Good!  Will this fix make it to "master" soon?
>
I don't really know; the idea is to eventually merge 'testsuite-work' into
'master', but Ralf wants to take a look at its (many) commits before doing
the merge (and I agree with him that such a review would be useful).

In the meantime, when you want to test the "bleeding-edge" automake, I
suggest that you use 'testsuite-work' instead of 'master' (notice that
the latter branch is routinely merged into the former one, so you aren't
going to loose coverage).

> >> FAIL: txinfo21.test (exit: 1)
> >> =============================
> ...
> >> + test -d rec/main3.html
> >> + is_newest main.html main.texi
> >> ++ find main.html main.texi -newer main.html
> >> + is_newest_files=main.html/index.html
> >> + test -z main.html/index.html
> >> + exit_status=1
> >> + set +e
> >> + cd /h/j/w/co/automake/tests
> >> + case $exit_status,$keep_testdirs in
> >> + test 0 '!=' 0
> >> + echo 'txinfo21: exit 1'
> >> txinfo21: exit 1
> >> + exit 1
> >>
> > Ah, a failure I've introduced in 'maint' with commit `v1.11-360-ga370e2f'
> > "tests: fix spurious failure of txinfo21.test on FreeBSD".  It is due
> > to a limitation of the `is_newest' subroutine I hadn't thought about
> > (i.e., it doesn't work as expected on directories).  Should we hack
> > around this, or try to fix the `is_newest' subroutine instead?  I think
> > fixing `is_newest' is the best route. Anyway, I'll be AFK until tomorrow,
> > but then I'll give it a try (unless someone wants to beat me ;-)
> 
> I can wait ;-)
> Thanks.
>
Fixed by the attached patch (tested with GNU find and Solaris find).
I will allow a day or so for comments before pushing.

> A quick note about quoting: when there are hundreds of lines of
> quoted text, and you insert a couple groups of 5-6 lines, it's
> good to remove as much of that context as possible, if only
> so that those trying to read your reply will not accidentally
> skip over some part of it (I nearly did just that).
> 
Noted (BTW, I had deleted most of the log text you had originally
posted, but I can see that I had indeed still kept too much irrelevant
context).

Thanks,
  Stefano
From b6a40fa2d2c08f71f9aeced063a36a27f657da6b Mon Sep 17 00:00:00 2001
Message-Id: <b6a40fa2d[email-masked]>
From: Stefano Lattarini <[email-masked]>
Date: Sat, 23 Jul 2011 13:55:20 +0200
Subject: [PATCH] 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.
---
 ChangeLog                       |    9 +++++++++
 tests/defs                      |    2 +-
 tests/self-check-is_newest.test |   33 +++++++++++++++++++++++++++++++++
 3 files changed, 43 insertions(+), 1 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f5fd899..0aedd52 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2011-07-23  Stefano Lattarini  <[email-masked]>
+
+	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  <[email-masked]>
 
 	docs: add references between the 2 sections on java support
diff --git a/tests/defs b/tests/defs
index fb0b535..dc7add0 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 f179229..832d352 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
+
 :
-- 
1.7.2.3