all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#64800: [PATCH] Fix unstable Proced Refine Tests
@ 2023-07-23 10:00 Laurence Warne
  2023-07-23 10:24 ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Laurence Warne @ 2023-07-23 10:00 UTC (permalink / raw)
  To: 64800


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

Hi, this patch fixes a couple of unstable tests for 'proced-refine' I found
whilst running tests for https://debbugs.gnu.org/cgi/bugreport.cgi?bug=64752
yesterday.

Thanks, Laurence

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

[-- Attachment #2: 0001-Fix-unstable-Proced-refine-tests.patch --]
[-- Type: text/x-patch, Size: 3026 bytes --]

From f59f30d2ff1d1f0cb531490584cb9821ae799c08 Mon Sep 17 00:00:00 2001
From: Laurence Warne <laurencewarne@gmail.com>
Date: Sat, 22 Jul 2023 20:47:21 +0100
Subject: [PATCH] Fix unstable Proced refine tests

* test/lisp/proced-tests.el (proced-refine-test)
(proced-refine-with-update-test): Refine on session id (sess) rather
than process id (pid) as the refiner for pid keeps processes with
a parent process id equal to the pid refined on, which lead to
intermittent test failures as the refine tests checked pids matched
the pid refined on for all remaining processes.
---
 test/lisp/proced-tests.el | 37 +++++++++++++++++++++----------------
 1 file changed, 21 insertions(+), 16 deletions(-)

diff --git a/test/lisp/proced-tests.el b/test/lisp/proced-tests.el
index d53f25b00d8..71511705cf2 100644
--- a/test/lisp/proced-tests.el
+++ b/test/lisp/proced-tests.el
@@ -75,25 +75,30 @@ proced-color-test
 (ert-deftest proced-refine-test ()
   ;;(skip-unless (memq system-type '(gnu/linux gnu/kfreebsd darwin)))
   (proced--within-buffer
-   'medium
+   'verbose
    'user
-   ;; When refining on PID for process A, a process is kept if and only
-   ;; if its PID are the same as process A, which more or less guarentees
-   ;; the refinement will remove some processes.
-   (proced--move-to-column "PID")
-   (let ((pid (word-at-point)))
-     (proced-refine)
-     (while (not (eobp))
-       (proced--move-to-column "PID")
-       (should (string= pid (word-at-point)))
-       (forward-line)))))
+   ;; We refine on an attribute which:
+   ;; 1. Has a refiner which keeps a process if and only if the process
+   ;;    attribute value is equal to the value for the process used to perform
+   ;;    the refinement
+   ;; 2. Always has a value set for the attribute
+   ;; 3. Will (likely) cause some refinement to occur (e.g. we're not filtering
+   ;;    on an attribute with values which could be common to all processes like
+   ;;    user)
+  (proced--move-to-column "Sess")
+  (let ((sess (word-at-point)))
+    (proced-refine)
+    (while (not (eobp))
+      (proced--move-to-column "Sess")
+      (should (string= sess (word-at-point)))
+      (forward-line)))))
 
 (ert-deftest proced-refine-with-update-test ()
   (proced--within-buffer
-   'medium
+   'verbose
    'user
-   (proced--move-to-column "PID")
-   (let ((pid (word-at-point)))
+   (proced--move-to-column "Sess")
+   (let ((sess (word-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
@@ -101,8 +106,8 @@ proced-refine-with-update-test
      ;; processes again, causing the test to fail.
      (proced-update)
      (while (not (eobp))
-       (proced--move-to-column "PID")
-       (should (string= pid (word-at-point)))
+       (proced--move-to-column "Sess")
+       (should (string= sess (word-at-point)))
        (forward-line)))))
 
 (ert-deftest proced-update-preserves-pid-at-point-test ()
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#64800: [PATCH] Fix unstable Proced Refine Tests
  2023-07-23 10:00 bug#64800: [PATCH] Fix unstable Proced Refine Tests Laurence Warne
@ 2023-07-23 10:24 ` Eli Zaretskii
  2023-07-23 13:20   ` Laurence Warne
  0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2023-07-23 10:24 UTC (permalink / raw)
  To: Laurence Warne; +Cc: 64800

> From: Laurence Warne <laurencewarne@gmail.com>
> Date: Sun, 23 Jul 2023 11:00:08 +0100
> 
> * test/lisp/proced-tests.el (proced-refine-test)
> (proced-refine-with-update-test): Refine on session id (sess) rather
> than process id (pid) as the refiner for pid keeps processes with
> a parent process id equal to the pid refined on, which lead to
> intermittent test failures as the refine tests checked pids matched
> the pid refined on for all remaining processes.

When I run "M-x proced", I don't see "Sess" on the heading.  I do see
PID, of course.

To remind you: we selected PID because it's portable: it exists in the
Proced display on every supported platform.

Thanks.





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#64800: [PATCH] Fix unstable Proced Refine Tests
  2023-07-23 10:24 ` Eli Zaretskii
@ 2023-07-23 13:20   ` Laurence Warne
  2023-07-26 14:10     ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Laurence Warne @ 2023-07-23 13:20 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 64800


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

With non-nix systems, that's a fair point I guess session id might not be
supported (though if you're on a nix system my guess would be you're using
a proced format with session id omitted, in general the tests should guard
against this by setting the format for duration of the test).  I've
attached a new patch which makes the tests still check against PID, but
also makes the tests check if PPID matches as a fallback before failing.

Thanks, Laurence

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

[-- Attachment #2: 0001-Fix-unstable-Proced-refine-tests.patch --]
[-- Type: text/x-patch, Size: 2909 bytes --]

From 3826e7b5fe98c2051dedeb4a1d6b768cb6c018ad Mon Sep 17 00:00:00 2001
From: Laurence Warne <laurencewarne@gmail.com>
Date: Sat, 22 Jul 2023 20:47:21 +0100
Subject: [PATCH] Fix unstable Proced refine tests

* test/lisp/proced-tests.el (proced-refine-test)
(proced-refine-with-update-test): Also check if the parent process id
of each process matches the process id refined on before failing,
since the refiner for process id returns the children of a process in
addition to the process itself.
---
 test/lisp/proced-tests.el | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/test/lisp/proced-tests.el b/test/lisp/proced-tests.el
index d53f25b00d8..bffbf5486d3 100644
--- a/test/lisp/proced-tests.el
+++ b/test/lisp/proced-tests.el
@@ -44,6 +44,17 @@ proced--move-to-column
   "Move to the column under ATTRIBUTE in the current proced buffer."
   (move-to-column (string-match attribute proced-header-line)))
 
+(defun proced--assert-process-valid-pid-refinement (pid)
+  "Fail unless the process at point could be present after a refinment using PID."
+  (proced--move-to-column "PID")
+  (let ((pid-equal (string= pid (word-at-point))))
+    (should
+     (or pid-equal
+         ;; Guard against the unlikely event a platform doesn't support PPID
+         (when (string-match "PPID" proced-header-line)
+           (proced--move-to-column "PPID")
+           (string= pid (word-at-point)))))))
+
 (ert-deftest proced-format-test ()
   (dolist (format '(short medium long verbose))
     (proced--within-buffer
@@ -75,22 +86,21 @@ proced-color-test
 (ert-deftest proced-refine-test ()
   ;;(skip-unless (memq system-type '(gnu/linux gnu/kfreebsd darwin)))
   (proced--within-buffer
-   'medium
+   'verbose
    'user
    ;; When refining on PID for process A, a process is kept if and only
-   ;; if its PID are the same as process A, which more or less guarentees
-   ;; the refinement will remove some processes.
+   ;; if its PID is the same as process A, or its parent process is
+   ;; process A.
    (proced--move-to-column "PID")
    (let ((pid (word-at-point)))
      (proced-refine)
      (while (not (eobp))
-       (proced--move-to-column "PID")
-       (should (string= pid (word-at-point)))
+       (proced--assert-process-valid-pid-refinement pid)
        (forward-line)))))
 
 (ert-deftest proced-refine-with-update-test ()
   (proced--within-buffer
-   'medium
+   'verbose
    'user
    (proced--move-to-column "PID")
    (let ((pid (word-at-point)))
@@ -101,8 +111,7 @@ proced-refine-with-update-test
      ;; processes again, causing the test to fail.
      (proced-update)
      (while (not (eobp))
-       (proced--move-to-column "PID")
-       (should (string= pid (word-at-point)))
+       (proced--assert-process-valid-pid-refinement pid)
        (forward-line)))))
 
 (ert-deftest proced-update-preserves-pid-at-point-test ()
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#64800: [PATCH] Fix unstable Proced Refine Tests
  2023-07-23 13:20   ` Laurence Warne
@ 2023-07-26 14:10     ` Eli Zaretskii
  0 siblings, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2023-07-26 14:10 UTC (permalink / raw)
  To: Laurence Warne; +Cc: 64800-done

> From: Laurence Warne <laurencewarne@gmail.com>
> Date: Sun, 23 Jul 2023 14:20:33 +0100
> Cc: 64800@debbugs.gnu.org
> 
> With non-nix systems, that's a fair point I guess session id might not be supported (though if you're on
> a nix system my guess would be you're using a proced format with session id omitted, in general the
> tests should guard against this by setting the format for duration of the test).  I've attached a new patch
> which makes the tests still check against PID, but also makes the tests check if PPID matches as a
> fallback before failing.

Thanks, installed on the master branch, and closing the bug.





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-07-26 14:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-23 10:00 bug#64800: [PATCH] Fix unstable Proced Refine Tests Laurence Warne
2023-07-23 10:24 ` Eli Zaretskii
2023-07-23 13:20   ` Laurence Warne
2023-07-26 14:10     ` Eli Zaretskii

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.