From f59f30d2ff1d1f0cb531490584cb9821ae799c08 Mon Sep 17 00:00:00 2001 From: Laurence Warne 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