Subject: bug#73036: 29.4; Test failure in erc-networks--id-sort-buffers

From: Ulrich Mueller <[email-masked]>
Date: Thu, 05 Sep 2024 07:59:14 +0200

Forwarding Gentoo bug 920696 <https://bugs.gentoo.org/920696>.

We see the following test failure on an hppa2.0-unknown-linux-gnu
(Linux-6.9.8-gentoo-parisc64-parisc64-PA8900_-Shortfin-with-glibc2.39)
system:

Test erc-networks--id-sort-buffers condition:
    (ert-test-failed
     ((should
       (equal
        (erc-networks--id-sort-buffers ...)
        (list newest middle oldest)))
      :form
      (equal
       (#<killed buffer> #<killed buffer> #<killed buffer>)
       (#<killed buffer> #<killed buffer> #<killed buffer>))
      :value nil :explanation
      (list-elt 0
                (different-atoms #<killed buffer> #<killed buffer>))))
   FAILED   6/41  erc-networks--id-sort-buffers (0.000000 sec) at lisp/erc/erc-networks-tests.el:133

[...]

Ran 41 tests, 40 results as expected, 1 unexpected (2024-09-03 20:09:01+0000, 14
.712021 sec)

1 unexpected results:
   FAILED  erc-networks--id-sort-buffers  ((should (equal (erc-networks--id-sort
-buffers (list oldest newest middle)) (list newest middle oldest))) :form (equal
 (#<killed buffer> #<killed buffer> #<killed buffer>) (#<killed buffer> #<killed buffer> #<killed buffer>)) :value nil :explanation (list-elt 0 (different-atoms #<killed buffer> #<killed buffer>)))

[...]

SUMMARY OF TEST RESULTS
-----------------------
Files examined: 465
Ran 6939 tests, 6675 results as expected, 1 unexpected, 263 skipped
1 files contained unexpected results:
  lisp/erc/erc-networks-tests.log

Looking at the code, the test creates three buffers, then sorts them by
time. Clock resolution on HPPA appears to be 4 milliseconds, so it is
not unlikely that the buffers end up with exactly the same timestamp and
sorting fails.

Attached patch fixes the problem. Is it OK to install it on the emacs-30
branch?

>From bf42248be8e795d591ce97c1d161d73d98038db6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ulrich=20M=C3=BCller?= <[email-masked]>
Date: Wed, 4 Sep 2024 13:35:51 +0200
Subject: [PATCH] Fix test failure in erc-networks-tests

* test/lisp/erc/erc-networks-tests.el
(erc-networks--id-sort-buffers): Make sure that buffers have
different timestamps.
---
 test/lisp/erc/erc-networks-tests.el | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/test/lisp/erc/erc-networks-tests.el b/test/lisp/erc/erc-networks-tests.el
index f0a7c37ddf2..e84cca68cdd 100644
--- a/test/lisp/erc/erc-networks-tests.el
+++ b/test/lisp/erc/erc-networks-tests.el
@@ -133,10 +133,12 @@ erc-networks--id-sort-buffers
     (with-temp-buffer
       (setq erc-networks--id (erc-networks--id-fixed-create 'oldest)
             oldest (current-buffer))
+      (sleep-for 0.02)
 
       (with-temp-buffer
         (setq erc-networks--id (erc-networks--id-fixed-create 'middle)
               middle (current-buffer))
+        (sleep-for 0.02)
 
         (with-temp-buffer
           (setq erc-networks--id (erc-networks--id-fixed-create 'newest)
-- 
2.46.0