Kill gpg agent in package-test.el to avoid a race
authorRob Browning <rlb@defaultvalue.org>
Mon, 10 Oct 2016 22:35:56 +0000 (17:35 -0500)
committerRob Browning <rlb@defaultvalue.org>
Sun, 26 Aug 2018 16:49:09 +0000 (17:49 +0100)
package-test.el should no longer fail during clean up.

* Previously a delete-directories call raced with the gpg agent's own
  cleanup process (presumably triggered by the first deletion of one of
  the agent's sockets).  As a result, it looks like the agent might
  delete one of its sockets after delete-directories had decided to
  delete the socket, but before it made the attempt, causing an
  exception.

* To fix the problem, explicitly ask gpg-connect-agent to kill the agent
  before attempting to delete the gnupg home directory, and then delete
  via "rm -rf" to ignore any vanishing files.

Gbp-Pq: Name 0007-Kill-gpg-agent-in-package-test.el-to-avoid-a-race.patch

test/automated/package-test.el

index 637a94bb3308463c29c8fdc3205a6f20b812abab..05272736881f3fc7da71a5ac51ca4b90d0c7528e 100644 (file)
                ,@body)))
 
        (when (file-directory-p package-test-user-dir)
-         (delete-directory package-test-user-dir t))
+         (call-process "gpg-connect-agent" nil nil nil
+                       "--homedir" (concat package-test-user-dir "/gnupg")
+                       "--no-autostart"
+                       "killagent" "/bye")
+         ;; Call "rm -rf" instead of delete-directory so that it won't
+         ;; choke if the gpg-agent sockets disappear during the
+         ;; recursive traversal.
+         (call-process "rm" nil nil nil "-r" package-test-user-dir))
 
        (when (and (boundp 'package-test-archive-upload-base)
                   (file-directory-p package-test-archive-upload-base))