branch: externals/websocket
commit a28e8bdd1521789c7969008389f91c5f3b50e044
Author: Andrew Hyatt <[email protected]>
Commit: Andrew Hyatt <[email protected]>

    Update unit tests to pass with lex binding, add uv for func testing
---
 README.org                   |  2 +-
 testserver.py                |  8 +++++++-
 websocket-functional-test.el | 20 ++++++++++++++------
 websocket-test.el            |  4 ++--
 4 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/README.org b/README.org
index 83f00cb6bd..2de8b392f2 100644
--- a/README.org
+++ b/README.org
@@ -16,7 +16,7 @@ This library is compatible with emacs 23 and 24, although 
only emacs
 Each version that is released should be checked with this checklist:
 
 - [ ] All ert test passing
-- [ ] Functional test passing on emacs 23 and 24
+- [ ] Functional tests passing
 - [ ] websocket.el byte compiling cleanly.
 
 * Existing clients:
diff --git a/testserver.py b/testserver.py
index 46cf62d94d..3f325bb725 100755
--- a/testserver.py
+++ b/testserver.py
@@ -1,4 +1,10 @@
-#!/usr/bin/env python3
+#!/usr/bin/env -S uv run --script
+# /// script
+# requires-python = ">3.6"
+# dependencies = [
+#   "tornado",
+# ]
+# ///
 import logging
 import tornado
 import tornado.web
diff --git a/websocket-functional-test.el b/websocket-functional-test.el
index 8fbcdf3d8b..3d13694720 100644
--- a/websocket-functional-test.el
+++ b/websocket-functional-test.el
@@ -1,6 +1,6 @@
-;;; websocket-functional-test.el --- Simple functional testing
+;;; websocket-functional-test.el --- Simple functional testing -*- 
lexical-binding:t -*-
 
-;; Copyright (c) 2013, 2016  Free Software Foundation, Inc.
+;; Copyright (c) 2013, 2016, 2026  Free Software Foundation, Inc.
 
 ;; This program is free software; you can redistribute it and/or
 ;; modify it under the terms of the GNU General Public License as
@@ -22,12 +22,15 @@
 ;; the Emacs bin directory for this to work. A firewall may also interfere with
 ;; these tests.
 ;;
+;; This test requires `uv' to be installed.
+;;
 ;; These tests are written to test the basic connectivity and message-sending.
 ;; Corner-cases and error handling is tested in websocket-test.el.
 
 (require 'tls)   ;; tests a particular bug we had on Emacs 23
 (require 'websocket)
 (require 'cl)
+(require 'f)
 
 ;;; Code:
 
@@ -64,11 +67,16 @@ written to be used widely."
     (should (websocket-test-wait-with-timeout 5 (equal wstest-msg "Hi!")))
     (websocket-close wstest-ws)))
 
+;; Hack because we have to be able to find the testserver.py script.
+(defconst websocket-ft-testserver (format "%s/testserver.py"
+                                          (file-name-directory
+                                           (f-this-file))))
+
 (ert-deftest websocket-client-with-local-server ()
   ;; If testserver.py cannot start, this test will fail.
   (let ((proc (start-process
                "websocket-testserver" "*websocket-testserver*"
-               "python3" "testserver.py" "--log_to_stderr" "--logging=debug")))
+               websocket-ft-testserver)))
     (when proc
       (sleep-for 1)
       (websocket-functional-client-test "ws://127.0.0.1:9999"))))
@@ -85,9 +93,9 @@ written to be used widely."
                        :on-close (lambda (_websocket)
                                    (setq wstest-closed t))))
          (wstest-ws (websocket-open
-                    "ws://localhost:9998"
-                    :on-message (lambda (_websocket frame)
-                                  (setq wstest-msg (websocket-frame-text 
frame))))))
+                     "ws://localhost:9998"
+                     :on-message (lambda (_websocket frame)
+                                   (setq wstest-msg (websocket-frame-text 
frame))))))
     (should (websocket-test-wait-with-timeout 1 (websocket-openp wstest-ws)))
     (websocket-send-text wstest-ws "你好")
     (should (websocket-test-wait-with-timeout 1 (equal wstest-msg "你好")))
diff --git a/websocket-test.el b/websocket-test.el
index 0613e22b01..35589dd0a1 100644
--- a/websocket-test.el
+++ b/websocket-test.el
@@ -439,7 +439,8 @@
       (should (equal processes-deleted '("fake-conn"))))))
 
 (ert-deftest websocket-outer-filter ()
-  (let* ((fake-ws (websocket-inner-create
+  (let* ((open-callback-called)
+         (fake-ws (websocket-inner-create
                    :conn t :url t :accept-string t
                    :on-open (lambda (websocket)
                               (should (eq (websocket-ready-state websocket)
@@ -452,7 +453,6 @@
                                        :length 9))
          (frame2 (make-websocket-frame :opcode 'text :payload "bar" :completep 
t
                                        :length 9))
-         (open-callback-called)
          (websocket-frames
           (concat
            (websocket-encode-frame frame1 t)

Reply via email to