;; 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'"))
(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'"))
(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'"))
(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 ()
(should-not (looking-at (rx "<alice> ")))))))
(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 ()
(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'"))
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
(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)
;; 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)
(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)
(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
(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")
;; -*- 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")
(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")
;; 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:
(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)
(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)))
(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))
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)
(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)))
(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)))
(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
(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))