Subject: Re: bug#76549: 30.1; Intermittent proced-refine test failires

From: Michael Albinus <[email-masked]>
Date: Fri, 28 Feb 2025 12:22:15 +0100

Eli Zaretskii <[email-masked]> writes:

Hi,

>> From: Laurence Warne <[email-masked]>
>> Date: Wed, 26 Feb 2025 22:03:49 +0000
>> Cc: Peter Oliver <[email-masked]>, [email-masked]
>>
>> Hi, I don't seem to be able to see the ERT explainer output in the logs added in
>> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=73441 for proced-refine-test.
>>
>> Has that patch been applied here or am I missing it?  If not it would possibly explain the flakiness fixed by
>> that patch too.
>
> Which patch are you referring to?  Bug#73441 has more than one.

I don't believe this belongs to Bug#73441. Patches there have added an
ert explainer, which isn't triggered here. And FWIW, proced-tests.el is
the same in the meacs-30 and master branches.

The backtrace Peter has provided us is

--8<---------------cut here---------------start------------->8---
Test proced-refine-test backtrace:
  proced-<(nil 88.88888888888889)
  proced-update()
  proced-refine()
  #f(compiled-function () #<bytecode 0x90a95dc86d9c8dd>)()
  #f(compiled-function () #<bytecode 0x81d18e5e5e509e9>)()
  handler-bind-1(#f(compiled-function () #<bytecode 0x81d18e5e5e509e9>
  ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test
  ert-run-test(#s(ert-test :name proced-refine-test :documentation nil
  ert-run-or-rerun-test(#s(ert--stats :selector ... :tests ... :test-m
  ert-run-tests((not (or (tag :expensive-test) (tag :unstable))) #f(co
  ert-run-tests-batch((not (or (tag :expensive-test) (tag :unstable)))
  ert-run-tests-batch-and-exit((not (or (tag :expensive-test) (tag :un
  eval((ert-run-tests-batch-and-exit '(not (or (tag :expensive-test) (
  command-line-1(("-L" ":." "-l" "ert" "--eval" "(setq treesit-extra-l
  command-line()
  normal-top-level()
Test proced-refine-test condition:
    (wrong-type-argument number-or-marker-p nil)
   FAILED  3/6  proced-refine-test (0.083490 sec) at lisp/proced-tests.el:117
   passed  4/6  proced-refine-with-update-test (0.089915 sec)
   passed  5/6  proced-revert-test (0.101340 sec)
   passed  6/6  proced-update-test (0.071953 sec)
Ran 6 tests, 5 results as expected, 1 unexpected (2025-02-24 22:08:35+0000, 0.735331 sec)
1 unexpected results:
   FAILED  proced-refine-test
--8<---------------cut here---------------end--------------->8---

The error has appeared in proced-refine, before any ert-specific macro,
carrying the explainer, could run.

Likely, we must improve proced-<. If either NUM1 or NUM2 is not a
number, this shouldn't raise an arror.

Peter, are you able to reproduce the problem? Does the appended patch
help?

Best regards, Michael.

diff --git a/lisp/proced.el b/lisp/proced.el
index 51fc39328b7..a60f70c949e 100644
--- a/lisp/proced.el
+++ b/lisp/proced.el
@@ -1423,10 +1423,12 @@ proced-refine

 (defun proced-< (num1 num2)
   "Return t if NUM1 less than NUM2.
-Return `equal' if NUM1 equals NUM2.  Return nil if NUM1 greater than NUM2."
-  (if (= num1 num2)
-      'equal
-    (< num1 num2)))
+Return `equal' if NUM1 equals NUM2.  Return nil if NUM1 greater than NUM2.
+If either NUM1 or NUM2 is not a number, return nil."
+  (when (and (numberp num1) (numberp num2))
+    (if (= num1 num2)
+        'equal
+      (< num1 num2))))

 (defun proced-string-lessp (s1 s2)
   "Return t if string S1 is less than S2 in lexicographic order.