From f84829428d2e912f925ceccd95c1d81aebe64108 Mon Sep 17 00:00:00 2001 From: dickmao Date: Wed, 13 Oct 2021 16:39:05 -0400 Subject: [PATCH] TLS bureaucracy flusters test It's never ideal when a test pings the internet (messes up statistics, pointlessly adds to WAN congestion), but I get it's a pain to stand up a toy https server. See also https://www.reddit.com/r/emacs/comments/pyevj8/what_should_i_do_cant_use_the_package_manager_it/?utm_source=share&utm_medium=web2x&context=3 * test/src/process-tests.el (process-async-https-with-delay): Dial down the security. --- test/src/process-tests.el | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/test/src/process-tests.el b/test/src/process-tests.el index 44f3ea2fbb..ee64a145b7 100644 --- a/test/src/process-tests.el +++ b/test/src/process-tests.el @@ -920,31 +920,27 @@ process-sentinel-interrupt-event (ert-deftest process-async-https-with-delay () "Bug#49449: asynchronous TLS connection with delayed completion." (skip-unless (and internet-is-working (gnutls-available-p))) - (let* ((status nil) + (let* (status + (network-security-level 'low) (buf (url-http - #s(url "https" nil nil "elpa.gnu.org" nil - "/packages/archive-contents" nil nil t silent t t) - (lambda (s) (setq status s)) - '(nil) nil 'tls))) + #s(url "https" nil nil "elpa.gnu.org" nil + "/packages/archive-contents" nil nil t silent t t) + (lambda (s) (setq status s)) + '(nil) nil 'tls))) (unwind-protect (progn - ;; Busy-wait for 1 s to allow for the TCP connection to complete. - (let ((delay 1.0) - (t0 (float-time))) - (while (< (float-time) (+ t0 delay)))) - ;; Wait for the entire operation to finish. - (let ((limit 4.0) - (t0 (float-time))) - (while (and (null status) - (< (float-time) (+ t0 limit))) - (sit-for 0.1))) + (catch 'done + (dotimes (_i 40) + (when status + (throw 'done status)) + (accept-process-output nil 0.1))) (should status) - (should-not (assq :error status)) - (should buf) - (should (> (buffer-size buf) 0)) - ) - (when buf - (kill-buffer buf))))) + (should-not (plist-get status :error)) + (should (buffer-live-p buf)) + (should (> (buffer-size buf) 0))) + (when (buffer-live-p buf) + (let (kill-buffer-query-functions) + (kill-buffer buf)))))) (ert-deftest process-num-processors () "Sanity checks for num-processors." -- 2.26.2