[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#46641: process-tests assume network connection
From: |
Robert Pluim |
Subject: |
bug#46641: process-tests assume network connection |
Date: |
Sun, 21 Feb 2021 17:19:12 +0100 |
>>>>> On Sun, 21 Feb 2021 14:41:11 +0100, Lars Ingebrigtsen <larsi@gnus.org>
>>>>> said:
>> I guess we could wrap them all in
>>
>> (skip-unless (dns-query "google.com"))
Lars> It'd be nice if Emacs did have a predicate for "is there any network
Lars> here?" But I don't know what that would look like. That is, there's
a
Lars> difference between having a local network (i.e., 127.0.0.1), and being
Lars> on the Internet.
Lars> But if any of our tests require Emacs to be on a functioning internet
Lars> connection, they should indeed be guarded by something like the
Lars> `skip-unless' you propose.
Well, the tests in question are asking 'does emacs have a correctly
functioning internet connection', so making that a prerequisite for
the test seems kind of redundant, but we can do it. But first:
disabling my network connection causes dns-query to hang, so something
like this is needed, I think (we can skip the first hunk if you want):
diff --git a/lisp/net/dns.el b/lisp/net/dns.el
index 2045d4dfca..598ceebab8 100644
--- a/lisp/net/dns.el
+++ b/lisp/net/dns.el
@@ -332,7 +332,7 @@ dns-set-servers
(setq dns-servers (nreverse dns-servers))))
(when (executable-find "nslookup")
(with-temp-buffer
- (call-process "nslookup" nil t nil "localhost")
+ (call-process "nslookup" nil t nil "-retry=0" "-timeout=2"
"localhost")
(goto-char (point-min))
(when (re-search-forward
"^Address:[
\t]*\\([0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\\|[[:xdigit:]:]*\\)" nil t)
@@ -496,15 +496,17 @@ dns-query
"Query a DNS server for NAME of TYPE.
If FULL, return the entire record returned.
If REVERSE, look up an IP address."
- (let ((result nil))
- (dns-query-asynchronous
- name
- (lambda (response)
- (setq result (list response)))
- type full reverse)
- ;; Loop until we get the callback.
- (while (not result)
- (sleep-for 0.01))
+ (let ((result nil)
+ (query-started
+ (dns-query-asynchronous
+ name
+ (lambda (response)
+ (setq result (list response)))
+ type full reverse)))
+ (if query-started
+ ;; Loop until we get the callback.
+ (while (not result)
+ (sleep-for 0.01)))
(car result)))
(provide 'dns)
bug#46641: process-tests assume network connection, Philipp, 2021/02/21