aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtur Malabarba2015-04-12 01:10:35 +0100
committerArtur Malabarba2015-04-12 01:12:33 +0100
commit7cae5c3cb6bcbee49e56c8d607d64071f9196952 (patch)
tree79f2eb9a4e4017f71683b68265525a9469024300
parentccade56fbee75dfebc6e1826738550a1c131d933 (diff)
downloademacs-7cae5c3cb6bcbee49e56c8d607d64071f9196952.tar.gz
emacs-7cae5c3cb6bcbee49e56c8d607d64071f9196952.zip
* test/automated/package-test.el: Test async functionality
(package-test-update-archives-async): New test
-rw-r--r--test/automated/data/package/package-test-server.py21
-rw-r--r--test/automated/package-test.el30
2 files changed, 50 insertions, 1 deletions
diff --git a/test/automated/data/package/package-test-server.py b/test/automated/data/package/package-test-server.py
new file mode 100644
index 00000000000..35ca820f31f
--- /dev/null
+++ b/test/automated/data/package/package-test-server.py
@@ -0,0 +1,21 @@
1import sys
2import BaseHTTPServer
3from SimpleHTTPServer import SimpleHTTPRequestHandler
4
5
6HandlerClass = SimpleHTTPRequestHandler
7ServerClass = BaseHTTPServer.HTTPServer
8Protocol = "HTTP/1.0"
9
10if sys.argv[1:]:
11 port = int(sys.argv[1])
12else:
13 port = 8000
14 server_address = ('127.0.0.1', port)
15
16HandlerClass.protocol_version = Protocol
17httpd = ServerClass(server_address, HandlerClass)
18
19sa = httpd.socket.getsockname()
20print "Serving HTTP on", sa[0], "port", sa[1], "..."
21httpd.serve_forever()
diff --git a/test/automated/package-test.el b/test/automated/package-test.el
index 5fae216ef7d..b343ed7285d 100644
--- a/test/automated/package-test.el
+++ b/test/automated/package-test.el
@@ -103,6 +103,7 @@
103(cl-defmacro with-package-test ((&optional &key file 103(cl-defmacro with-package-test ((&optional &key file
104 basedir 104 basedir
105 install 105 install
106 location
106 update-news 107 update-news
107 upload-base) 108 upload-base)
108 &rest body) 109 &rest body)
@@ -112,7 +113,7 @@
112 (process-environment (cons (format "HOME=%s" package-test-user-dir) 113 (process-environment (cons (format "HOME=%s" package-test-user-dir)
113 process-environment)) 114 process-environment))
114 (package-user-dir package-test-user-dir) 115 (package-user-dir package-test-user-dir)
115 (package-archives `(("gnu" . ,package-test-data-dir))) 116 (package-archives `(("gnu" . ,(or ,location package-test-data-dir))))
116 (default-directory package-test-file-dir) 117 (default-directory package-test-file-dir)
117 abbreviated-home-dir 118 abbreviated-home-dir
118 package--initialized 119 package--initialized
@@ -336,6 +337,33 @@ Must called from within a `tar-mode' buffer."
336 (package-menu-refresh) 337 (package-menu-refresh)
337 (should (package-installed-p 'simple-single '(1 4))))))) 338 (should (package-installed-p 'simple-single '(1 4)))))))
338 339
340(ert-deftest package-test-update-archives-async ()
341 "Test updating package archives asynchronously."
342 (skip-unless (executable-find "python2"))
343 (with-package-test (:basedir
344 package-test-data-dir
345 :location "http://0.0.0.0:8000/")
346 (let* ((package-menu-async t)
347 (process (start-process
348 "package-server" "package-server-buffer"
349 (executable-find "python2")
350 (expand-file-name "package-test-server.py"))))
351 (unwind-protect
352 (progn
353 (list-packages)
354 (should package--downloads-in-progress)
355 (should mode-line-process)
356 (should-not (string= (format-mode-line mode-line-process) ""))
357 (should-not
358 (with-timeout (10 'timeout)
359 (while package--downloads-in-progress
360 (accept-process-output nil 1))
361 nil))
362 (goto-char (point-min))
363 (should
364 (search-forward-regexp "^ +simple-single" nil t)))
365 (kill-process process)))))
366
339(ert-deftest package-test-describe-package () 367(ert-deftest package-test-describe-package ()
340 "Test displaying help for a package." 368 "Test displaying help for a package."
341 369