Cover LSP transport write failures

ober

3f6ca57e86ce8e9060bc750ada6d6368c53b8094

diff --git a/tests/test-qt.ss b/tests/test-qt.ss
index 2a83b65..305cc88 100644
--- a/tests/test-qt.ss
+++ b/tests/test-qt.ss
@@ -31,6 +31,7 @@
         (jerboa-emacs qt buffer)
         (jerboa-emacs qt highlight)
         (jerboa-emacs qt commands)
+        (jerboa-emacs qt lsp-client)
         (only (jerboa-emacs qt commands-core) *winner-history* *winner-future*)
         (jerboa-emacs qt magit)
         (jerboa-emacs qt modeline)
@@ -1468,7 +1469,34 @@
       ;; Provider may or may not be set depending on init order.
       ;; If set, calling it when LSP is not running should return #f.
       ;; If not set, that is also acceptable.
-      (check (or (not provider) (not (provider))) ? values))))
+      (check (or (not provider) (not (provider))) ? values)))
+
+  (test-case "LSP write failure marks transport dead and reports"
+    (let ((old-proc *lsp-process*)
+          (old-initialized *lsp-initialized*)
+          (old-initializing *lsp-initializing*)
+          (old-handler (unbox *lsp-show-message-handler*))
+          (messages '())
+          (port (open-output-string)))
+      (close-output-port port)
+      (unwind-protect
+        (begin
+          (set! *lsp-process* port)
+          (set! *lsp-initialized* #t)
+          (set! *lsp-initializing* #f)
+          (set-box! *lsp-show-message-handler*
+                    (lambda (params)
+                      (set! messages
+                        (cons (hash-get params "message") messages))))
+          (lsp-send-notification! "workspace/didChangeConfiguration" #f)
+          (check (lsp-running?) => #f)
+          (check (pair? messages) ? values)
+          (check (string-prefix? "LSP transport failed:" (car messages)) => #t))
+        (begin
+          (set! *lsp-process* old-proc)
+          (set! *lsp-initialized* old-initialized)
+          (set! *lsp-initializing* old-initializing)
+          (set-box! *lsp-show-message-handler* old-handler))))))
 
 ;;;============================================================================
 ;;; Phase 20: Code folding (Group 15 from upstream)