emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 546d30e: Don't use IP 0.0.0.0 for package test serv


From: Noam Postavsky
Subject: [Emacs-diffs] master 546d30e: Don't use IP 0.0.0.0 for package test server (Bug#22582)
Date: Sat, 25 Feb 2017 12:57:16 -0500 (EST)

branch: master
commit 546d30ed1400d5a434886790a102bd37ec852919
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>

    Don't use IP 0.0.0.0 for package test server (Bug#22582)
    
    * test/lisp/emacs-lisp/package-resources/package-test-server.py: Set
    'server_address' when port number is given on the command line.  Print
    IP and port number as a URL, and flush it after printing.
    * test/lisp/emacs-lisp/package-tests.el:
    (package-test-update-archives-async): Grab the whole URL from server
    output.
---
 .../emacs-lisp/package-resources/package-test-server.py   | 10 +++++++---
 test/lisp/emacs-lisp/package-tests.el                     | 15 ++++++---------
 2 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/test/lisp/emacs-lisp/package-resources/package-test-server.py 
b/test/lisp/emacs-lisp/package-resources/package-test-server.py
index 1acd9f7..128b424 100644
--- a/test/lisp/emacs-lisp/package-resources/package-test-server.py
+++ b/test/lisp/emacs-lisp/package-resources/package-test-server.py
@@ -11,11 +11,15 @@ if sys.argv[1:]:
     port = int(sys.argv[1])
 else:
     port = 0
-    server_address = ('127.0.0.1', port)
+server_address = ('127.0.0.1', port)
 
 HandlerClass.protocol_version = Protocol
 httpd = ServerClass(server_address, HandlerClass)
 
-sa = httpd.socket.getsockname()
-print "Serving HTTP on", sa[0], "port", sa[1], "..."
+ip, port = httpd.socket.getsockname()[0:2]
+print ("Server started, http://%s:%s/"; % (ip, port))
+# Flush in case we're in full buffering mode (instead of line
+# buffering), this might happen if python is a cygwin program and we
+# run it from a native w32 program.
+sys.stdout.flush()
 httpd.serve_forever()
diff --git a/test/lisp/emacs-lisp/package-tests.el 
b/test/lisp/emacs-lisp/package-tests.el
index 2e4666e..5172b48 100644
--- a/test/lisp/emacs-lisp/package-tests.el
+++ b/test/lisp/emacs-lisp/package-tests.el
@@ -376,22 +376,19 @@ Must called from within a `tar-mode' buffer."
                    "package-server" "package-server-buffer"
                    (executable-find "python2")
                    "package-test-server.py"))
-         port)
+         (addr nil))
     (unwind-protect
         (progn
           (with-current-buffer "package-server-buffer"
             (should
              (with-timeout (10 nil)
-               (while (not port)
+               (while (not addr)
                  (accept-process-output nil 1)
                  (goto-char (point-min))
-                 (if (re-search-forward "Serving HTTP on .* port \\([0-9]+\\) "
-                                        nil t)
-                     (setq port (match-string 1))))
-               port)))
-          (with-package-test (:basedir
-                              package-test-data-dir
-                              :location (format "http://0.0.0.0:%s/"; port))
+                 (when (re-search-forward "Server started, \\(.*\\)\n" nil t)
+                   (setq addr (match-string 1))))
+               addr)))
+          (with-package-test (:basedir package-test-data-dir :location addr)
             (list-packages)
             (should package--downloads-in-progress)
             (should mode-line-process)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]