GNU bug report logs -
#23708
[PATCH] package: don’t hard code port number in test
Previous Next
Reported by: Michal Nazarewicz <mina86 <at> mina86.com>
Date: Mon, 6 Jun 2016 19:54:01 UTC
Severity: minor
Tags: patch
Fixed in version 26.1
Done: Glenn Morris <rgm <at> gnu.org>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 23708 in the body.
You can then email your comments to 23708 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23708
; Package
emacs
.
(Mon, 06 Jun 2016 19:54:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Michal Nazarewicz <mina86 <at> mina86.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Mon, 06 Jun 2016 19:54:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Hard coding port 8000 in package-tests.el causes the test to fail if
something is already listening on that port. Change code so it uses
any available port.
* tests/lisp/emacs-lisp/package-tests.el
(package-test-update-archives-async): Do not hard code port number
and instead parse it from server’s standard output.
* tests/lisp/emacs-lisp/package-resources/package-test-server.py:
Do not hard code port number. Use any available one instead.
---
.../package-resources/package-test-server.py | 15 ++----
test/lisp/emacs-lisp/package-tests.el | 54 ++++++++++++----------
2 files changed, 34 insertions(+), 35 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 35ca820..78e40b3 100644
--- a/test/lisp/emacs-lisp/package-resources/package-test-server.py
+++ b/test/lisp/emacs-lisp/package-resources/package-test-server.py
@@ -1,21 +1,16 @@
-import sys
+import os
import BaseHTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
-
HandlerClass = SimpleHTTPRequestHandler
ServerClass = BaseHTTPServer.HTTPServer
Protocol = "HTTP/1.0"
-if sys.argv[1:]:
- port = int(sys.argv[1])
-else:
- port = 8000
- server_address = ('127.0.0.1', port)
+os.chdir(os.path.dirname(__file__))
HandlerClass.protocol_version = Protocol
-httpd = ServerClass(server_address, HandlerClass)
+httpd = ServerClass(('127.0.0.1', 0), HandlerClass)
-sa = httpd.socket.getsockname()
-print "Serving HTTP on", sa[0], "port", sa[1], "..."
+# This printed line is parsed by test code, don't change its format.
+print "Serving on http://%s:%s/" % httpd.socket.getsockname()
httpd.serve_forever()
diff --git a/test/lisp/emacs-lisp/package-tests.el b/test/lisp/emacs-lisp/package-tests.el
index c7a5cc7..4ffb173 100644
--- a/test/lisp/emacs-lisp/package-tests.el
+++ b/test/lisp/emacs-lisp/package-tests.el
@@ -372,31 +372,35 @@ package-test-desc-version-string
(skip-unless (executable-find "python2"))
;; For some reason this test doesn't work reliably on hydra.nixos.org.
(skip-unless (not (getenv "NIX_STORE")))
- (with-package-test (:basedir
- package-test-data-dir
- :location "http://0.0.0.0:8000/")
- (let* ((package-menu-async t)
- (process (start-process
- "package-server" "package-server-buffer"
- (executable-find "python2")
- (expand-file-name "package-test-server.py"))))
- (unwind-protect
- (progn
- (list-packages)
- (should package--downloads-in-progress)
- (should mode-line-process)
- (should-not
- (with-timeout (10 'timeout)
- (while package--downloads-in-progress
- (accept-process-output nil 1))
- nil))
- ;; If the server process died, there's some non-Emacs problem.
- ;; Eg maybe the port was already in use.
- (skip-unless (process-live-p process))
- (goto-char (point-min))
- (should
- (search-forward-regexp "^ +simple-single" nil t)))
- (if (process-live-p process) (kill-process process))))))
+
+ (with-temp-buffer
+ (cd package-test-data-dir)
+ (let ((package-menu-async t)
+ (process (start-process "package-server" (current-buffer)
+ (executable-find "python2")
+ (expand-file-name "package-test-server.py"))))
+ ;; Killing temp buffer will kill the process.
+ (set-process-query-on-exit-flag process nil)
+
+ (with-package-test
+ (:location (with-timeout (5 (should-not 'timeout))
+ (while (and (goto-char (point-min))
+ (not (re-search-forward
+ "^Serving on \\(http://.*/\\)" nil t)))
+ (accept-process-output process 1))
+ (match-string 1)))
+ (list-packages)
+ (should package--downloads-in-progress)
+ (should mode-line-process)
+ (should-not (with-timeout (10 'timeout)
+ (while package--downloads-in-progress
+ (accept-process-output nil 1))
+ nil))
+ ;; If the server process died, there's some non-Emacs problem.
+ ;; Eg maybe the port was already in use.
+ (skip-unless (process-live-p process))
+ (goto-char (point-min))
+ (should (search-forward-regexp "^ +simple-single" nil t))))))
(ert-deftest package-test-describe-package ()
"Test displaying help for a package."
--
2.8.0.rc3.226.g39d4020
Reply sent
to
Glenn Morris <rgm <at> gnu.org>
:
You have taken responsibility.
(Wed, 08 Jun 2016 01:27:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
Michal Nazarewicz <mina86 <at> mina86.com>
:
bug acknowledged by developer.
(Wed, 08 Jun 2016 01:27:02 GMT)
Full text and
rfc822 format available.
Message #10 received at 23708-done <at> debbugs.gnu.org (full text, mbox):
Version: 25.2
Thanks; I installed something similar.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23708
; Package
emacs
.
(Wed, 08 Jun 2016 12:35:02 GMT)
Full text and
rfc822 format available.
Message #13 received at 23708 <at> debbugs.gnu.org (full text, mbox):
Glenn Morris <rgm <at> gnu.org> wrote:
> Thanks; I installed something similar.
Note that currently argument parsing in package-test-server.py is
dysfunctional (passing an argument causes server_address to never be
set) so while my patch would fix that (by removing that unused feature).
--
Best regards
ミハウ “𝓶𝓲𝓷𝓪86” ナザレヴイツ
«If at first you don’t succeed, give up skydiving»
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23708
; Package
emacs
.
(Wed, 08 Jun 2016 16:04:02 GMT)
Full text and
rfc822 format available.
Message #16 received at 23708 <at> debbugs.gnu.org (full text, mbox):
Michal Nazarewicz wrote:
> Note that currently argument parsing in package-test-server.py is
> dysfunctional (passing an argument causes server_address to never be
> set) so while my patch would fix that (by removing that unused feature).
(Sorry, I did not notice that you have write access.) Feel free to fix
that if it bothers you.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Thu, 07 Jul 2016 11:24:03 GMT)
Full text and
rfc822 format available.
bug unarchived.
Request was from
Glenn Morris <rgm <at> gnu.org>
to
control <at> debbugs.gnu.org
.
(Mon, 17 Oct 2016 06:29:01 GMT)
Full text and
rfc822 format available.
bug Marked as fixed in versions 26.1.
Request was from
Glenn Morris <rgm <at> gnu.org>
to
control <at> debbugs.gnu.org
.
(Mon, 17 Oct 2016 06:29:01 GMT)
Full text and
rfc822 format available.
bug No longer marked as fixed in versions 25.2.
Request was from
Glenn Morris <rgm <at> gnu.org>
to
control <at> debbugs.gnu.org
.
(Mon, 17 Oct 2016 06:29:01 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Mon, 14 Nov 2016 12:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 8 years and 221 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.