From: F. Jason Park Date: Sat, 23 Dec 2023 23:23:44 +0000 (-0800) Subject: Allow selecting graphical ERC tests manually X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=c83a2d15097e39d2a46d898f7731ca592c59e5a7;p=emacs.git Allow selecting graphical ERC tests manually * test/lisp/erc/erc-fill-tests.el (erc-fill-wrap--monospace, erc-fill-wrap--merge, erc-fill-wrap-tests--merge-action, erc-fill-wrap-tests--merge-action/indicator-pre, erc-fill-wrap-tests--merge-action/indicator-post, erc-fill-line-spacing, erc-fill-wrap-visual-keys--body, erc-fill-wrap-visual-keys--prompt, erc-fill--left-hand-stamps): Tag as :erc--graphcial. * test/lisp/erc/erc-scenarios-internal.el (erc-scenarios-internal--run-interactive-all): New test to assist ERC contributors in -jN parallel runs. * test/lisp/erc/erc-scenarios-scrolltobottom-relaxed.el (erc-scenarios-scrolltobottom--relaxed): Tag as :erc--graphical. * test/lisp/erc/erc-scenarios-scrolltobottom.el (erc-scenarios-scrolltobottom--normal, erc-scenarios-scrolltobottom--all): Tag as :erc--graphical. * test/lisp/erc/erc-scenarios-status-sidebar.el (erc-scenarios-status-sidebar--nickbar): Tag as :erc--graphical. * test/lisp/erc/erc-tests.el (erc--channel-modes/graphic-p): Tag as :erc--graphical. * test/lisp/erc/resources/base/local-modules/first.eld: Timeouts. * test/lisp/erc/resources/erc-scenarios-common.el (erc-scenarios-common--graphical-p): New variable. (erc-scenarios-common--make-bindings): Don't enable `inhibit-interaction' when interactive. Set `erc-scenarios-common--graphical-p' flag when `:erc--graphical' tag present and running interactively. (erc-scenarios-common-with-cleanup): Account for variable `erc-scenarios-common--graphical-p'. (erc-scenarios-common-scrolltobottom--normal): Turn off `erc-scrolltobottom-mode' when test finishes so as not to pollute when running multiple interactive tests. ; * test/lisp/erc/resources/join/network-id/barnet.eld: Timeouts. --- diff --git a/test/lisp/erc/erc-fill-tests.el b/test/lisp/erc/erc-fill-tests.el index 8560d421cc2..5e5b1d332ac 100644 --- a/test/lisp/erc/erc-fill-tests.el +++ b/test/lisp/erc/erc-fill-tests.el @@ -210,7 +210,8 @@ ;; or similar. (ert-deftest erc-fill-wrap--monospace () - :tags '(:unstable) + :tags `(:unstable + ,@(and (getenv "ERC_TESTS_GRAPHICAL") '(:erc--graphical))) (unless (>= emacs-major-version 29) (ert-skip "Emacs version too low, missing `buffer-text-pixel-size'")) @@ -256,7 +257,8 @@ (erc-fill--wrap-rejigger-region (point-min) erc-insert-marker nil nil)))) (ert-deftest erc-fill-wrap--merge () - :tags '(:unstable) + :tags `(:unstable + ,@(and (getenv "ERC_TESTS_GRAPHICAL") '(:erc--graphical))) (unless (>= emacs-major-version 29) (ert-skip "Emacs version too low, missing `buffer-text-pixel-size'")) @@ -341,23 +343,27 @@ (erc-fill-tests--compare compare-file)))) (ert-deftest erc-fill-wrap--merge-action () - :tags '(:unstable) + :tags `(:unstable + ,@(and (getenv "ERC_TESTS_GRAPHICAL") '(:erc--graphical))) (erc-fill-wrap-tests--merge-action "merge-wrap-01")) (ert-deftest erc-fill-wrap--merge-action/indicator-pre () - :tags '(:unstable) + :tags `(:unstable + ,@(and (getenv "ERC_TESTS_GRAPHICAL") '(:erc--graphical))) (let ((erc-fill-wrap-merge-indicator '(pre ?> shadow))) (erc-fill-wrap-tests--merge-action "merge-wrap-indicator-pre-01"))) ;; One crucial thing this test asserts is that the indicator is ;; omitted when the previous line ends in a stamp. (ert-deftest erc-fill-wrap--merge-action/indicator-post () - :tags '(:unstable) + :tags `(:unstable + ,@(and (getenv "ERC_TESTS_GRAPHICAL") '(:erc--graphical))) (let ((erc-fill-wrap-merge-indicator '(post ?~ shadow))) (erc-fill-wrap-tests--merge-action "merge-wrap-indicator-post-01"))) (ert-deftest erc-fill-line-spacing () - :tags '(:unstable) + :tags `(:unstable + ,@(and (getenv "ERC_TESTS_GRAPHICAL") '(:erc--graphical))) (unless (>= emacs-major-version 29) (ert-skip "Emacs version too low, missing `buffer-text-pixel-size'")) @@ -371,7 +377,8 @@ (erc-fill-tests--compare "spacing-01-mono"))))) (ert-deftest erc-fill-wrap-visual-keys--body () - :tags '(:unstable) + :tags `(:unstable + ,@(and (getenv "ERC_TESTS_GRAPHICAL") '(:erc--graphical))) (erc-fill-tests--wrap-populate (lambda () @@ -413,7 +420,8 @@ (should-not (looking-at (rx " "))))))) (ert-deftest erc-fill-wrap-visual-keys--prompt () - :tags '(:unstable) + :tags `(:unstable + ,@(and (getenv "ERC_TESTS_GRAPHICAL") '(:erc--graphical))) (erc-fill-tests--wrap-populate (lambda () @@ -456,7 +464,8 @@ (execute-kbd-macro "\C-a"))))) (ert-deftest erc-fill--left-hand-stamps () - :tags '(:unstable) + :tags `(:unstable + ,@(and (getenv "ERC_TESTS_GRAPHICAL") '(:erc--graphical))) (unless (>= emacs-major-version 29) (ert-skip "Emacs version too low, missing `buffer-text-pixel-size'")) diff --git a/test/lisp/erc/erc-scenarios-internal.el b/test/lisp/erc/erc-scenarios-internal.el index 18eb94e24b0..4ec94cedf0e 100644 --- a/test/lisp/erc/erc-scenarios-internal.el +++ b/test/lisp/erc/erc-scenarios-internal.el @@ -28,4 +28,34 @@ load-path))) (load "erc-d-tests" nil 'silent))) +;; Run all tests tagged `:erc--graphical' in an "interactive" +;; subprocess. Time out after 90 seconds. +(ert-deftest erc-scenarios-internal--run-graphical-all () + :tags '(:expensive-test :unstable) + (unless (and (getenv "ERC_TESTS_GRAPHICAL_ALL") + (not (getenv "ERC_TESTS_GRAPHICAL")) + (not (getenv "CI"))) + (ert-skip "Environmental conditions unmet")) + + (let* ((default-directory (expand-file-name "../" (ert-resource-directory))) + (libs (directory-files default-directory 'full (rx ".el" eot))) + (process-environment (cons "ERC_TESTS_GRAPHICAL=1" + process-environment)) + (program '(progn (ert (quote (tag :erc--graphical))) + (with-current-buffer ert--output-buffer-name + (kill-emacs (ert--stats-failed-unexpected + ert--results-stats))))) + (args `("erc-interactive-all" ,(current-buffer) + ,(concat invocation-directory invocation-name) + "-Q" "-L" "." "-l" "ert" + ,@(let (o) (while libs (push (pop libs) o) (push "-l" o)) o) + "-eval" ,(format "%S" program))) + (proc (apply #'start-process args))) + (set-process-query-on-exit-flag proc nil) + + (erc-d-t-wait-for 90 "interactive tests to complete" + (not (process-live-p proc))) + + (should (zerop (process-exit-status proc))))) + ;;; erc-scenarios-internal.el ends here diff --git a/test/lisp/erc/erc-scenarios-scrolltobottom-relaxed.el b/test/lisp/erc/erc-scenarios-scrolltobottom-relaxed.el index 68ea0b1b070..e99a05526f3 100644 --- a/test/lisp/erc/erc-scenarios-scrolltobottom-relaxed.el +++ b/test/lisp/erc/erc-scenarios-scrolltobottom-relaxed.el @@ -30,7 +30,8 @@ (require 'erc-goodies) (ert-deftest erc-scenarios-scrolltobottom--relaxed () - :tags '(:expensive-test) + :tags `(:expensive-test + ,@(and (getenv "ERC_TESTS_GRAPHICAL") '(:erc--graphical))) (when (version< emacs-version "29") (ert-skip "Times out")) (should-not erc-scrolltobottom-all) diff --git a/test/lisp/erc/erc-scenarios-scrolltobottom.el b/test/lisp/erc/erc-scenarios-scrolltobottom.el index 206687ccab5..25b5c09577f 100644 --- a/test/lisp/erc/erc-scenarios-scrolltobottom.el +++ b/test/lisp/erc/erc-scenarios-scrolltobottom.el @@ -30,7 +30,8 @@ ;; now to stay in sync with `erc-scenarios-scrolltobottom--relaxed'. (ert-deftest erc-scenarios-scrolltobottom--normal () - :tags '(:expensive-test) + :tags `(:expensive-test ,@(and (getenv "ERC_TESTS_GRAPHICAL") + '(:erc--graphical))) (when (version< emacs-version "29") (ert-skip "Times out")) (should-not erc-scrolltobottom-all) @@ -45,7 +46,8 @@ (not (erc-scenarios-common--at-win-end-p w)))))))) (ert-deftest erc-scenarios-scrolltobottom--all () - :tags '(:expensive-test) + :tags `(:expensive-test ,@(and (getenv "ERC_TESTS_GRAPHICAL") + '(:erc--graphical))) (when (version< emacs-version "29") (ert-skip "Times out")) (should-not erc-scrolltobottom-all) diff --git a/test/lisp/erc/erc-scenarios-status-sidebar.el b/test/lisp/erc/erc-scenarios-status-sidebar.el index b2b6351e333..d447817e307 100644 --- a/test/lisp/erc/erc-scenarios-status-sidebar.el +++ b/test/lisp/erc/erc-scenarios-status-sidebar.el @@ -99,7 +99,8 @@ (defvar speedbar-buffer) (ert-deftest erc-scenarios-status-sidebar--nickbar () - :tags '(:unstable :expensive-test) + :tags `(:expensive-test :unstable ,@(and (getenv "ERC_TESTS_GRAPHICAL") + '(:erc--graphical))) (when noninteractive (ert-skip "Interactive only")) (erc-scenarios-common-with-cleanup diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el index 1d2090e1027..ffc96eb4f1d 100644 --- a/test/lisp/erc/erc-tests.el +++ b/test/lisp/erc/erc-tests.el @@ -886,7 +886,8 @@ (should (equal (erc--channel-modes 0) "klt "))) ; 2 spaces (ert-deftest erc--channel-modes/graphic-p () - :tags '(:unstable) + :tags `(:unstable ,@(and (getenv "ERC_TESTS_GRAPHICAL") + '(:erc--graphical))) (unless (display-graphic-p) (ert-skip "See non-/graphic-p variant")) (erc-tests--set-fake-server-process "sleep" "1") diff --git a/test/lisp/erc/resources/base/local-modules/first.eld b/test/lisp/erc/resources/base/local-modules/first.eld index f9181a80fb7..4e923270e24 100644 --- a/test/lisp/erc/resources/base/local-modules/first.eld +++ b/test/lisp/erc/resources/base/local-modules/first.eld @@ -1,7 +1,7 @@ ;; -*- mode: lisp-data; -*- ((cap 10 "CAP REQ :sasl")) -((nick 1 "NICK tester")) -((user 1 "USER tester 0 * :tester")) +((nick 10 "NICK tester")) +((user 10 "USER tester 0 * :tester")) ((authenticate 5 "AUTHENTICATE PLAIN") (0.0 ":irc.foonet.org CAP * ACK sasl") @@ -11,7 +11,7 @@ (0.0 ":irc.foonet.org 900 * * tester :You are now logged in as tester") (0.01 ":irc.foonet.org 903 * :Authentication successful")) -((cap 3.2 "CAP END") +((cap 10 "CAP END") (0.0 ":irc.foonet.org 001 tester :Welcome to the foonet IRC Network tester") (0.0 ":irc.foonet.org 002 tester :Your host is irc.foonet.org, running version ergo-v2.8.0") (0.2 ":irc.foonet.org 003 tester :This server was created Sun, 20 Nov 2022 23:10:36 UTC") diff --git a/test/lisp/erc/resources/erc-scenarios-common.el b/test/lisp/erc/resources/erc-scenarios-common.el index 311d8a82d72..d842454d085 100644 --- a/test/lisp/erc/resources/erc-scenarios-common.el +++ b/test/lisp/erc/resources/erc-scenarios-common.el @@ -61,6 +61,25 @@ ;; always associated with the fake network FooNet, while nicks Joe and ;; Mike are always on BarNet. (Networks are sometimes downcased.) ;; +;; Environment variables: +;; +;; `ERC_TESTS_GRAPHICAL': Internal variable to unskip those few tests +;; capable of running consecutively while interactive on a graphical +;; display. This triggers both the tests and the suite to commence +;; with teardown activities normally skipped to allow for inspection +;; while interactive. This is also handy when needing to quickly +;; run `ert-results-rerun-test-at-point-debugging-errors' on a +;; failing test because you don't have to go around hunting for and +;; killing associated buffers and processes. +;; +;; `ERC_TESTS_GRAPHICAL_ALL': Currently targets a single "meta" test, +;; `erc-scenarios-internal--run-interactive-all', that runs all +;; tests tagged `:erc--graphical' in an interactive subprocess. +;; +;; `ERC_TESTS_SUBPROCESS': Used internally to detect nested tests. +;; +;; `ERC_D_DEBUG': Tells `erc-d' to emit debugging info to stderr. +;; ;; XXX This file should *not* contain any test cases. ;;; Code: @@ -91,6 +110,7 @@ (defvar erc-scenarios-common-dialog nil) (defvar erc-scenarios-common-extra-teardown nil) +(defvar erc-scenarios-common--graphical-p nil) (defun erc-scenarios-common--add-silence () (advice-add #'erc-login :around #'erc-d-t-silence-around) @@ -110,7 +130,11 @@ (eval-and-compile (defun erc-scenarios-common--make-bindings (bindings) - `((erc-d-u-canned-dialog-dir (expand-file-name + `((erc-scenarios-common--graphical-p + (and (or erc-scenarios-common--graphical-p + (memq :erc--graphical (ert-test-tags (ert-running-test)))) + (not (and noninteractive (ert-skip "Interactive only"))))) + (erc-d-u-canned-dialog-dir (expand-file-name (or erc-scenarios-common-dialog (cadr (assq 'erc-scenarios-common-dialog ',bindings))) @@ -119,7 +143,7 @@ (quit . ,(erc-quit/part-reason-default)) (erc-version . ,erc-version))) (erc-modules (copy-sequence erc-modules)) - (inhibit-interaction t) + (inhibit-interaction noninteractive) (auth-source-do-cache nil) (timer-list (copy-sequence timer-list)) (timer-idle-list (copy-sequence timer-idle-list)) @@ -139,13 +163,19 @@ disabled by BODY. Other defaults common to these test cases are added below and can be overridden, except when wanting the \"real\" default value, which must be looked up or captured outside of the calling form. +When running tests tagged as serially runnable while interactive +and the flag `erc-scenarios-common--graphical-p' is non-nil, run +teardown tasks normally inhibited when interactive. That is, +behave almost as if `noninteractive' were also non-nil, and +ensure buffers and other resources are destroyed on completion. + Dialog resource directories are located by expanding the variable `erc-scenarios-common-dialog' or its value in BINDINGS." (declare (indent 1)) (let* ((orig-autojoin-mode (make-symbol "orig-autojoin-mode")) (combined `((,orig-autojoin-mode (bound-and-true-p erc-autojoin-mode)) - ,@(erc-scenarios-common--make-bindings bindings)))) + ,@(erc-scenarios-common--make-bindings bindings)))) `(erc-d-t-with-cleanup (,@combined) @@ -165,8 +195,9 @@ Dialog resource directories are located by expanding the variable (not (eq erc-autojoin-mode ,orig-autojoin-mode))) (erc-autojoin-mode (if ,orig-autojoin-mode +1 -1))) - (when noninteractive - (erc-scenarios-common--print-trace) + (when (or noninteractive erc-scenarios-common--graphical-p) + (when noninteractive + (erc-scenarios-common--print-trace)) (erc-d-t-kill-related-buffers) (delete-other-windows))) @@ -179,7 +210,8 @@ Dialog resource directories are located by expanding the variable (erc-d-t-search-for 3 "Starting"))))) (ert-info ("Activate erc-debug-irc-protocol") - (unless (and noninteractive (not erc-debug-irc-protocol)) + (unless (and (or noninteractive erc-scenarios-common--graphical-p) + (not erc-debug-irc-protocol)) (erc-toggle-debug-irc-protocol))) ,@body))) @@ -417,7 +449,9 @@ See Info node `(emacs) Term Mode' for the various commands." (erc-scenarios-common-say "/msg NickServ help identify") ;; New arriving messages trigger a snap when inserted. (erc-d-t-wait-for 10 (erc-scenarios-common--at-win-end-p)) - (funcall expect 10 "IDENTIFY lets you login"))))) + (funcall expect 10 "IDENTIFY lets you login")) + + (erc-scrolltobottom-mode -1)))) (cl-defun erc-scenarios-common--base-network-id-bouncer ((&key autop foo-id bar-id after diff --git a/test/lisp/erc/resources/join/network-id/barnet.eld b/test/lisp/erc/resources/join/network-id/barnet.eld index e33dd6be29e..ad6a7c820a9 100644 --- a/test/lisp/erc/resources/join/network-id/barnet.eld +++ b/test/lisp/erc/resources/join/network-id/barnet.eld @@ -40,4 +40,4 @@ (0.05 ":mike!~u@6yximxrnkg65a.irc PRIVMSG #chan :joe: And now, dear maid, be you as free to us.") (0.00 ":joe!~u@6yximxrnkg65a.irc PRIVMSG #chan :mike: He hath an uncle here in Messina will be very much glad of it.")) -((linger 3.5 LINGER)) +((linger 30 LINGER))