branch: externals/hyperbole
commit 9b8d38635a6cf5c9606bdee3cef4c3d185c92882
Author: Mats Lidell <[email protected]>
Commit: GitHub <[email protected]>
Test for shell commands in view mode (#310)
---
ChangeLog | 6 ++++++
test/demo-tests.el | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 53 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 0f71db6e52..ec1fc1643c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2023-02-20 Mats Lidell <[email protected]>
+
+* test/demo-tests.el (fast-demo-key-series-shell-cd-hyperb-dir-view-mode)
+ (fast-demo-key-series-shell-grep-view-mode): Add tests for acting on
+ key series in view-mode.
+
2023-02-19 Mats Lidell <[email protected]>
* hypb.el (hypb:display-file-with-logo): Use view-mode for fast demo.
diff --git a/test/demo-tests.el b/test/demo-tests.el
index 6ecd0592a8..26eaae7287 100644
--- a/test/demo-tests.el
+++ b/test/demo-tests.el
@@ -3,7 +3,7 @@
;; Author: Mats Lidell <[email protected]>
;;
;; Orig-Date: 30-Jan-21 at 12:00:00
-;; Last-Mod: 6-Nov-22 at 12:23:00 by Bob Weiner
+;; Last-Mod: 19-Feb-23 at 23:16:00 by Mats Lidell
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -595,6 +595,52 @@ enough files with matching mode loaded."
(set-process-query-on-exit-flag (get-buffer-process shell-buffer-name)
nil)
(hy-test-helpers:kill-buffer shell-buffer-name)))))
+(ert-deftest fast-demo-key-series-shell-cd-hyperb-dir-view-mode ()
+ "Action key executes cd shell command from buffer in `view-mode`."
+ (skip-unless (not noninteractive))
+ (let* ((shell-file-name (executable-find "sh"))
+ (shell-buffer-name "*shell*")
+ (existing-shell-flag (get-buffer-process shell-buffer-name)))
+ (unwind-protect
+ (with-temp-buffer
+ (insert "{ M-x shell RET M-> (cd ${hyperb:dir} && echo
\"PWD=$(pwd)\") RET }")
+ (goto-char 5)
+ (view-mode)
+ (action-key)
+ (hy-test-helpers:consume-input-events)
+ (with-current-buffer shell-buffer-name
+ (goto-char (point-min))
+ (end-of-line)
+ (with-timeout (5 (ert-fail "Test timed out"))
+ (while (not (search-forward "PWD=" nil t))
+ (accept-process-output (get-buffer-process
shell-buffer-name))))
+ (should (looking-at-p (directory-file-name hyperb:dir)))))
+ (unless existing-shell-flag
+ (set-process-query-on-exit-flag (get-buffer-process shell-buffer-name)
nil)
+ (hy-test-helpers:kill-buffer shell-buffer-name)))))
+
+(ert-deftest fast-demo-key-series-shell-grep-view-mode ()
+ "Action key executes grep shell command from buffer in `view-mode`."
+ (skip-unless (not noninteractive))
+ (let* ((shell-file-name (executable-find "sh"))
+ (shell-buffer-name "*shell*")
+ (existing-shell-flag (get-buffer-process shell-buffer-name)))
+ (unwind-protect
+ (with-temp-buffer
+ (insert "{M-x shell RET M-> (export HYPERBOLE_DIR=${hyperb:dir} &&
cd $HYPERBOLE_DIR && grep -n gbut:label-list *.el) RET}")
+ (goto-char 5)
+ (view-mode)
+ (action-key)
+ (hy-test-helpers:consume-input-events)
+ (with-current-buffer shell-buffer-name
+ (with-timeout (5 (ert-fail "Test timed out"))
+ (while (not (string-match-p
"\n.*\\.el:[0-9]+:.*defun.*gbut:label-list ()" (buffer-substring-no-properties
(point-min) (point-max))))
+ (accept-process-output (get-buffer-process
shell-buffer-name))))
+ (should (string-match-p "\n.*\\.el:[0-9]+:.*defun.*gbut:label-list
()" (buffer-substring-no-properties (point-min) (point-max))))))
+ (unless existing-shell-flag
+ (set-process-query-on-exit-flag (get-buffer-process shell-buffer-name)
nil)
+ (hy-test-helpers:kill-buffer shell-buffer-name)))))
+
;; This file can't be byte-compiled without the `el-mock' package (because of
;; the use of the `with-mock' macro), which is not a dependency of Hyperbole.
;; Local Variables: