all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Laurence Warne <laurencewarne@gmail.com>
To: Michael Albinus <michael.albinus@gmx.de>
Cc: mattiase@acm.org, 73441@debbugs.gnu.org, Sam James <sam@gentoo.org>
Subject: bug#73441: 31.0.50; Unstable proced-refine-test failure
Date: Thu, 14 Nov 2024 18:24:41 +0000	[thread overview]
Message-ID: <CAE2oLqiL96o6CUuH4VSw_kpX2bAdg_XpXFTucZhWd+CU09EJmA@mail.gmail.com> (raw)
In-Reply-To: <87zfm3lfuz.fsf@gmx.de>


[-- Attachment #1.1: Type: text/plain, Size: 148 bytes --]

Hi Michael,

Makes sense, I also added the output of '(process-attributes pid)' to the
explainer (I think I mentioned it before).

Thanks, Laurence

[-- Attachment #1.2: Type: text/html, Size: 271 bytes --]

[-- Attachment #2: 0001-Don-t-error-in-Proced-tests-if-CPU-is-a-NaN.patch --]
[-- Type: text/x-patch, Size: 3966 bytes --]

From ae05a1d8fc0f6b0896ac53d5e91a1c972c52316e Mon Sep 17 00:00:00 2001
From: Laurence Warne <laurencewarne@gmail.com>
Date: Tue, 12 Nov 2024 19:42:23 +0000
Subject: [PATCH] Don't error in Proced tests if %CPU is a NaN

* test/lisp/proced-tests.el (proced--cpu-at-point): New function.
(proced--assert-process-valid-cpu-refinement)
(proced-refine-test, proced-refine-with-update-test): If %CPU for any
process visited is a NaN skip the test.
(proced-update-preserves-pid-at-point-test): Fix typo in comment.
(proced--assert-process-valid-cpu-refinement-explainer): Add process
attributes to the explainer along with tweaking how the process %CPU is
obtained to account for circumstances where it's not numeric (most
notably '-nan').
---
 test/lisp/proced-tests.el | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/test/lisp/proced-tests.el b/test/lisp/proced-tests.el
index 3dc7e065afa..65afeeb5f08 100644
--- a/test/lisp/proced-tests.el
+++ b/test/lisp/proced-tests.el
@@ -35,6 +35,15 @@ proced--within-buffer
            ,@body)
        (kill-buffer "*Proced*"))))
 
+(defun proced--cpu-at-point ()
+  "Return as an integer the current CPU value at point."
+  (if (string-suffix-p "nan" (thing-at-point 'sexp))
+      (let ((pid (proced-pid-at-point)))
+        (ert-skip
+         (format
+          "Found NaN value for %%CPU at point for process with PID %d" pid)))
+    (thing-at-point 'number)))
+
 (defun proced--assert-emacs-pid-in-buffer ()
   "Fail unless the process ID of the current Emacs process exists in buffer."
   (should (string-match-p
@@ -51,7 +60,7 @@ proced--assert-process-valid-cpu-refinement
   "Fail unless the process at point could be present after a refinement using CPU."
   (proced--move-to-column "%CPU")
   (condition-case err
-      (>= (thing-at-point 'number) cpu)
+      (>= (proced--cpu-at-point) cpu)
     (error
      (ert-fail
       (list err (proced--assert-process-valid-cpu-refinement-explainer cpu))))))
@@ -64,11 +73,14 @@ proced--assert-process-valid-cpu-refinement-explainer
     (header-line
      ,(substring-no-properties
        (string-replace "%%" "%" (cadr (proced-header-line)))))
-    (process ,(thing-at-point 'line t))
+    (buffer-process-line ,(thing-at-point 'line t))
+    (process-attributes ,(format "%s" (process-attributes (proced-pid-at-point))))
     (refined-value ,cpu)
     (process-value
      ,(save-excursion
-        (proced--move-to-column "%CPU") (thing-at-point 'number)))))
+        (proced--move-to-column "%CPU")
+        (or (thing-at-point 'number)
+            (substring-no-properties (thing-at-point 'sexp)))))))
 
 (put #'proced--assert-process-valid-cpu-refinement 'ert-explainer
      #'proced--assert-process-valid-cpu-refinement-explainer)
@@ -108,7 +120,7 @@ proced-refine-test
    ;; When refining on %CPU for process A, a process is kept if and only
    ;; if its %CPU is greater than or equal to that of process A.
    (proced--move-to-column "%CPU")
-   (let ((cpu (thing-at-point 'number)))
+   (let ((cpu (proced--cpu-at-point)))
      (proced-refine)
      (while (not (eobp))
        (should (proced--assert-process-valid-cpu-refinement cpu))
@@ -119,7 +131,7 @@ proced-refine-with-update-test
    'verbose
    'user
    (proced--move-to-column "%CPU")
-   (let ((cpu (thing-at-point 'number)))
+   (let ((cpu (proced--cpu-at-point)))
      (proced-refine)
      ;; Don't use (proced-update t) since this will reset `proced-process-alist'
      ;; and it's possible the process refined on would have exited by that
@@ -132,7 +144,7 @@ proced-refine-with-update-test
 
 (ert-deftest proced-update-preserves-pid-at-point-test ()
   ;; FIXME: Occasionally the cursor inexplicably changes to the first line which
-  ;; causes the test to file when the line isn't the Emacs process.
+  ;; causes the test to fail when the line isn't the Emacs process.
   :tags '(:unstable)
   (proced--within-buffer
    'medium
-- 
2.39.5


  reply	other threads:[~2024-11-14 18:24 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-23 13:19 bug#73441: 31.0.50; Unstable proced-refine-test failure Sam James
2024-09-27 13:00 ` Laurence Warne
2024-10-15 14:52   ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-25 16:46     ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-26 15:44       ` Laurence Warne
2024-10-26 16:59         ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-27 11:16           ` Laurence Warne
2024-10-27 11:47             ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-27 12:07               ` Eli Zaretskii
2024-10-27 15:53                 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-29  7:51         ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-29 21:26           ` Laurence Warne
2024-10-30 14:15             ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-30 18:25               ` Laurence Warne
2024-11-04 13:27                 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-09  8:31                   ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-09 14:17                     ` Laurence Warne
2024-11-09 20:06                       ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-09 21:18                         ` Laurence Warne
2024-11-10  8:35                           ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-12 20:19                             ` Laurence Warne
2024-11-13  8:04                               ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-14 18:24                                 ` Laurence Warne [this message]
2024-11-15 15:25                                   ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAE2oLqiL96o6CUuH4VSw_kpX2bAdg_XpXFTucZhWd+CU09EJmA@mail.gmail.com \
    --to=laurencewarne@gmail.com \
    --cc=73441@debbugs.gnu.org \
    --cc=mattiase@acm.org \
    --cc=michael.albinus@gmx.de \
    --cc=sam@gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.