diff options
Diffstat (limited to 'test/src/process-tests.el')
| -rw-r--r-- | test/src/process-tests.el | 63 |
1 files changed, 53 insertions, 10 deletions
diff --git a/test/src/process-tests.el b/test/src/process-tests.el index 7745fccaf9d..158c036aaa7 100644 --- a/test/src/process-tests.el +++ b/test/src/process-tests.el | |||
| @@ -22,6 +22,7 @@ | |||
| 22 | ;;; Code: | 22 | ;;; Code: |
| 23 | 23 | ||
| 24 | (require 'ert) | 24 | (require 'ert) |
| 25 | (require 'puny) | ||
| 25 | 26 | ||
| 26 | ;; Timeout in seconds; the test fails if the timeout is reached. | 27 | ;; Timeout in seconds; the test fails if the timeout is reached. |
| 27 | (defvar process-test-sentinel-wait-timeout 2.0) | 28 | (defvar process-test-sentinel-wait-timeout 2.0) |
| @@ -154,24 +155,30 @@ | |||
| 154 | (concat invocation-directory invocation-name) | 155 | (concat invocation-directory invocation-name) |
| 155 | "-Q" "--batch" "--eval" | 156 | "-Q" "--batch" "--eval" |
| 156 | (prin1-to-string | 157 | (prin1-to-string |
| 157 | '(let (s) | 158 | '(let ((s nil) (count 0)) |
| 158 | (while (setq s (read-from-minibuffer "$ ")) | 159 | (while (setq s (read-from-minibuffer |
| 160 | (format "%d> " count))) | ||
| 159 | (princ s) | 161 | (princ s) |
| 160 | (princ "\n"))))))) | 162 | (princ "\n") |
| 163 | (setq count (1+ count)))))))) | ||
| 161 | (set-process-query-on-exit-flag proc nil) | 164 | (set-process-query-on-exit-flag proc nil) |
| 162 | (send-string proc "one\n") | 165 | (send-string proc "one\n") |
| 163 | (should | 166 | (while (not (equal (buffer-substring |
| 164 | (accept-process-output proc 1)) ; Read "one". | 167 | (line-beginning-position) (point-max)) |
| 165 | (should (equal (buffer-string) "$ one\n$ ")) | 168 | "1> ")) |
| 169 | (accept-process-output proc)) ; Read "one". | ||
| 170 | (should (equal (buffer-string) "0> one\n1> ")) | ||
| 166 | (set-process-filter proc t) ; Stop reading from proc. | 171 | (set-process-filter proc t) ; Stop reading from proc. |
| 167 | (send-string proc "two\n") | 172 | (send-string proc "two\n") |
| 168 | (should-not | 173 | (should-not |
| 169 | (accept-process-output proc 1)) ; Can't read "two" yet. | 174 | (accept-process-output proc 1)) ; Can't read "two" yet. |
| 170 | (should (equal (buffer-string) "$ one\n$ ")) | 175 | (should (equal (buffer-string) "0> one\n1> ")) |
| 171 | (set-process-filter proc nil) ; Resume reading from proc. | 176 | (set-process-filter proc nil) ; Resume reading from proc. |
| 172 | (should | 177 | (while (not (equal (buffer-substring |
| 173 | (accept-process-output proc 1)) ; Read "two" from proc. | 178 | (line-beginning-position) (point-max)) |
| 174 | (should (equal (buffer-string) "$ one\n$ two\n$ "))))) | 179 | "2> ")) |
| 180 | (accept-process-output proc)) ; Read "Two". | ||
| 181 | (should (equal (buffer-string) "0> one\n1> two\n2> "))))) | ||
| 175 | 182 | ||
| 176 | (ert-deftest start-process-should-not-modify-arguments () | 183 | (ert-deftest start-process-should-not-modify-arguments () |
| 177 | "`start-process' must not modify its arguments in-place." | 184 | "`start-process' must not modify its arguments in-place." |
| @@ -322,5 +329,41 @@ See Bug#30460." | |||
| 322 | invocation-directory)) | 329 | invocation-directory)) |
| 323 | :stop t))) | 330 | :stop t))) |
| 324 | 331 | ||
| 332 | ;; All the following tests require working DNS, which appears not to | ||
| 333 | ;; be the case for hydra.nixos.org, so disable them there for now. | ||
| 334 | |||
| 335 | (ert-deftest lookup-family-specification () | ||
| 336 | "network-lookup-address-info should only accept valid family symbols." | ||
| 337 | (skip-unless (not (getenv "EMACS_HYDRA_CI"))) | ||
| 338 | (should-error (network-lookup-address-info "google.com" 'both)) | ||
| 339 | (should (network-lookup-address-info "google.com" 'ipv4)) | ||
| 340 | (should (network-lookup-address-info "google.com" 'ipv6))) | ||
| 341 | |||
| 342 | (ert-deftest lookup-unicode-domains () | ||
| 343 | "Unicode domains should fail" | ||
| 344 | (skip-unless (not (getenv "EMACS_HYDRA_CI"))) | ||
| 345 | (should-error (network-lookup-address-info "faß.de")) | ||
| 346 | (should (network-lookup-address-info (puny-encode-domain "faß.de")))) | ||
| 347 | |||
| 348 | (ert-deftest unibyte-domain-name () | ||
| 349 | "Unibyte domain names should work" | ||
| 350 | (skip-unless (not (getenv "EMACS_HYDRA_CI"))) | ||
| 351 | (should (network-lookup-address-info (string-to-unibyte "google.com")))) | ||
| 352 | |||
| 353 | (ert-deftest lookup-google () | ||
| 354 | "Check that we can look up google IP addresses" | ||
| 355 | (skip-unless (not (getenv "EMACS_HYDRA_CI"))) | ||
| 356 | (let ((addresses-both (network-lookup-address-info "google.com")) | ||
| 357 | (addresses-v4 (network-lookup-address-info "google.com" 'ipv4)) | ||
| 358 | (addresses-v6 (network-lookup-address-info "google.com" 'ipv6))) | ||
| 359 | (should addresses-both) | ||
| 360 | (should addresses-v4) | ||
| 361 | (should addresses-v6))) | ||
| 362 | |||
| 363 | (ert-deftest non-existent-lookup-failure () | ||
| 364 | (skip-unless (not (getenv "EMACS_HYDRA_CI"))) | ||
| 365 | "Check that looking up non-existent domain returns nil" | ||
| 366 | (should (eq nil (network-lookup-address-info "emacs.invalid")))) | ||
| 367 | |||
| 325 | (provide 'process-tests) | 368 | (provide 'process-tests) |
| 326 | ;; process-tests.el ends here. | 369 | ;; process-tests.el ends here. |