Subject: bug#63550: proced-refine-with-update-test is racy

From: Laurence Warne <[email-masked]>
Date: Sun, 21 May 2023 19:45:16 +0100

One thing I've noticed about the failing test is that we should probably
use `(proced-update)` instead of `(proced-update t)` so as not to refresh
`proced-process-alist` (I've attached a patch).  When I first saw this, I
thought this would fix the failure as I thought what might have been
happening was that the process used for the refinement might have exited
between proced being called, and then `(proced-update t)` being called, but
I think the test should still pass in this case (though I've optimistically
used 'fix' in the patch commit (: ).

Mattias (or Basil), are you able to provide a backtrace?

> Is mocking out the real Proced display a good idea in this case?
> These tests test the ability to manipulate real-life process-attribute
> displays, so showing they work in synthetic environment verifies only
> part of the functionality, no?

Since systems will likely have a variety of processes running at a time, I
think you are right, mocking will result in less coverage, but then again
the processes and their attributes people have running on their machines
are not consistent.  Perhaps we could use mocking, but only for features
which are difficult to test otherwise, like refinements?

Maybe I was too fast to jump to using mocking and it's tangential to this
issue, though I'd still be interested to see if the (mocking patch) fixes
the issue.
From 59782731876e62898ee3ee2a912c935bf6b21254 Mon Sep 17 00:00:00 2001
From: Laurence Warne <[email-masked]>
Date: Sun, 21 May 2023 18:59:43 +0100
Subject: [PATCH] Fix unstable proced test

Fix unstable proced test by omitting the revert parameter in
'proced-update'.

* test/lisp/proced-tests.el (proced-refine-with-update-test): Do not
use revert parameter when calling 'proced-update'.
---
 test/lisp/proced-tests.el | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/test/lisp/proced-tests.el b/test/lisp/proced-tests.el
index d69414cf43a..fa65772076f 100644
--- a/test/lisp/proced-tests.el
+++ b/test/lisp/proced-tests.el
@@ -89,14 +89,13 @@ proced-refine-test
        (forward-line)))))
 
 (ert-deftest proced-refine-with-update-test ()
-  :tags '(:unstable)   ; There seems to be an update race here.
   (proced--within-buffer
    'medium
    'user
    (proced--move-to-column "PID")
    (let ((pid (word-at-point)))
      (proced-refine)
-     (proced-update t)
+     (proced-update)
      (while (not (eobp))
        (proced--move-to-column "PID")
        (should (string= pid (word-at-point)))
-- 
2.30.2