From d37dc7b6cd9daf2fdacd653ede2decb8f7e13a6a Mon Sep 17 00:00:00 2001 From: Po Lu <luangruo@yahoo.com> Date: Wed, 26 Feb 2025 16:03:12 +0800 Subject: [PATCH] Port Eshell tests to Android * test/infra/android/test-controller.el (ats-run-test): Run tests in a temp buffer. * test/lisp/eshell/em-alias-tests.el (ert, em-alias) (eshell-tests-helpers): * test/lisp/eshell/em-basic-tests.el (em-basic) (eshell-tests-helpers): * test/lisp/eshell/em-cmpl-tests.el (em-unix) (eshell-tests-helpers): * test/lisp/eshell/em-dirs-tests.el (em-dirs) (eshell-tests-helpers): * test/lisp/eshell/em-extpipe-tests.el (ert-x) (eshell-tests-helpers): * test/lisp/eshell/em-glob-tests.el (ert, eshell-tests-helpers): * test/lisp/eshell/em-hist-tests.el (eshell) (eshell-tests-helpers): * test/lisp/eshell/em-pred-tests.el (em-pred) (eshell-tests-helpers): * test/lisp/eshell/em-prompt-tests.el (em-prompt) (eshell-tests-helpers): * test/lisp/eshell/em-script-tests.el (em-script) (eshell-tests-helpers): * test/lisp/eshell/em-unix-tests.el (ert-x) (eshell-tests-helpers): * test/lisp/eshell/esh-arg-tests.el (eshell) (eshell-tests-helpers): * test/lisp/eshell/esh-cmd-tests.el (eshell) (eshell-tests-helpers): * test/lisp/eshell/esh-ext-tests.el (eshell) (eshell-tests-helpers): * test/lisp/eshell/esh-io-tests.el (eshell) (eshell-tests-helpers): * test/lisp/eshell/esh-mode-tests.el (em-prompt) (eshell-tests-helpers): * test/lisp/eshell/esh-proc-tests.el (em-prompt) (eshell-tests-helpers): * test/lisp/eshell/esh-util-tests.el (esh-util) (eshell-tests-helpers): * test/lisp/eshell/esh-var-tests.el (eshell) (eshell-tests-helpers): * test/lisp/eshell/eshell-tests.el (esh-mode) (eshell-tests-helpers): Load `eshell-tests-helpers' from the resource directory. * test/lisp/eshell/resources/eshell-tests-helpers.el: Move from `test/lisp/eshell'. (cherry picked from commit 3e496fc31746517440285c2cd9f2b4a09c227d7b) --- test/infra/android/test-controller.el | 6 +++++- test/lisp/eshell/em-alias-tests.el | 6 +++--- test/lisp/eshell/em-basic-tests.el | 5 ++--- test/lisp/eshell/em-cmpl-tests.el | 5 ++--- test/lisp/eshell/em-dirs-tests.el | 5 ++--- test/lisp/eshell/em-extpipe-tests.el | 5 ++--- test/lisp/eshell/em-glob-tests.el | 5 ++--- test/lisp/eshell/em-hist-tests.el | 5 ++--- test/lisp/eshell/em-pred-tests.el | 5 ++--- test/lisp/eshell/em-prompt-tests.el | 5 ++--- test/lisp/eshell/em-script-tests.el | 5 ++--- test/lisp/eshell/em-unix-tests.el | 3 ++- test/lisp/eshell/esh-arg-tests.el | 5 ++--- test/lisp/eshell/esh-cmd-tests.el | 5 ++--- test/lisp/eshell/esh-ext-tests.el | 5 ++--- test/lisp/eshell/esh-io-tests.el | 5 ++--- test/lisp/eshell/esh-mode-tests.el | 5 ++--- test/lisp/eshell/esh-proc-tests.el | 5 ++--- test/lisp/eshell/esh-util-tests.el | 5 ++--- test/lisp/eshell/esh-var-tests.el | 5 ++--- test/lisp/eshell/eshell-tests.el | 5 ++--- test/lisp/eshell/{ => resources}/eshell-tests-helpers.el | 0 22 files changed, 46 insertions(+), 59 deletions(-) rename test/lisp/eshell/{ => resources}/eshell-tests-helpers.el (100%) diff --git a/test/infra/android/test-controller.el b/test/infra/android/test-controller.el index 89b9b93f7b1..d318c9a0d4b 100644 --- a/test/infra/android/test-controller.el +++ b/test/infra/android/test-controller.el @@ -2442,7 +2442,11 @@ Display the output of the tests executed in a buffer." (with-current-buffer temp-buffer (insert message "\n"))))) (let ((noninteractive t)) - (ert-run-tests-batch ',selector)) + ;; Prevent activation of the mark and + ;; other actions taken by the tests + ;; from affecting the test buffer. + (with-temp-buffer + (ert-run-tests-batch ',selector))) (insert "=== Test execution complete ===\n") (buffer-substring-no-properties (point-min) (point-max))))))) diff --git a/test/lisp/eshell/em-alias-tests.el b/test/lisp/eshell/em-alias-tests.el index 2386e04bbd3..51af80af148 100644 --- a/test/lisp/eshell/em-alias-tests.el +++ b/test/lisp/eshell/em-alias-tests.el @@ -24,14 +24,14 @@ ;;; Code: (require 'ert) +(require 'ert-x) (require 'esh-mode) (require 'eshell) (require 'em-alias) +(require 'ert-x) (require 'eshell-tests-helpers - (expand-file-name "eshell-tests-helpers" - (file-name-directory (or load-file-name - default-directory)))) + (ert-resource-file "eshell-tests-helpers")) ;;; Tests: (ert-deftest em-alias-test/simple-alias () diff --git a/test/lisp/eshell/em-basic-tests.el b/test/lisp/eshell/em-basic-tests.el index ee2a624cf6f..cd141dc440e 100644 --- a/test/lisp/eshell/em-basic-tests.el +++ b/test/lisp/eshell/em-basic-tests.el @@ -25,11 +25,10 @@ (require 'ert) (require 'em-basic) +(require 'ert-x) (require 'eshell-tests-helpers - (expand-file-name "eshell-tests-helpers" - (file-name-directory (or load-file-name - default-directory)))) + (ert-resource-file "eshell-tests-helpers")) ;;; Tests: diff --git a/test/lisp/eshell/em-cmpl-tests.el b/test/lisp/eshell/em-cmpl-tests.el index 5b4fc5b48b1..f7f8958d816 100644 --- a/test/lisp/eshell/em-cmpl-tests.el +++ b/test/lisp/eshell/em-cmpl-tests.el @@ -30,11 +30,10 @@ (require 'em-hist) (require 'em-tramp) (require 'em-unix) +(require 'ert-x) (require 'eshell-tests-helpers - (expand-file-name "eshell-tests-helpers" - (file-name-directory (or load-file-name - default-directory)))) + (ert-resource-file "eshell-tests-helpers")) (defvar eshell-test-value nil) diff --git a/test/lisp/eshell/em-dirs-tests.el b/test/lisp/eshell/em-dirs-tests.el index ae3c19aa022..a3e2ad7287c 100644 --- a/test/lisp/eshell/em-dirs-tests.el +++ b/test/lisp/eshell/em-dirs-tests.el @@ -27,11 +27,10 @@ (require 'esh-mode) (require 'eshell) (require 'em-dirs) +(require 'ert-x) (require 'eshell-tests-helpers - (expand-file-name "eshell-tests-helpers" - (file-name-directory (or load-file-name - default-directory)))) + (ert-resource-file "eshell-tests-helpers")) ;;; Tests: diff --git a/test/lisp/eshell/em-extpipe-tests.el b/test/lisp/eshell/em-extpipe-tests.el index ed7ed2a35b8..b2c55256341 100644 --- a/test/lisp/eshell/em-extpipe-tests.el +++ b/test/lisp/eshell/em-extpipe-tests.el @@ -27,11 +27,10 @@ (require 'cl-lib) (require 'ert) (require 'ert-x) +(require 'ert-x) (require 'em-extpipe) (require 'eshell-tests-helpers - (expand-file-name "eshell-tests-helpers" - (file-name-directory (or load-file-name - default-directory)))) + (ert-resource-file "eshell-tests-helpers")) (defmacro em-extpipe-tests--deftest (name input &rest body) (declare (indent 2)) diff --git a/test/lisp/eshell/em-glob-tests.el b/test/lisp/eshell/em-glob-tests.el index 4bc32848518..fd5ef537a0b 100644 --- a/test/lisp/eshell/em-glob-tests.el +++ b/test/lisp/eshell/em-glob-tests.el @@ -25,12 +25,11 @@ (require 'tramp) (require 'ert) +(require 'ert-x) (require 'em-glob) (require 'eshell-tests-helpers - (expand-file-name "eshell-tests-helpers" - (file-name-directory (or load-file-name - default-directory)))) + (ert-resource-file "eshell-tests-helpers")) (defvar eshell-prefer-lisp-functions) diff --git a/test/lisp/eshell/em-hist-tests.el b/test/lisp/eshell/em-hist-tests.el index f0bb4dd16c3..6288ae071dc 100644 --- a/test/lisp/eshell/em-hist-tests.el +++ b/test/lisp/eshell/em-hist-tests.el @@ -26,11 +26,10 @@ (require 'ert-x) (require 'em-hist) (require 'eshell) +(require 'ert-x) (require 'eshell-tests-helpers - (expand-file-name "eshell-tests-helpers" - (file-name-directory (or load-file-name - default-directory)))) + (ert-resource-file "eshell-tests-helpers")) (cl-defun em-hist-test/check-history-file (file-name expected &optional (expected-ring t)) diff --git a/test/lisp/eshell/em-pred-tests.el b/test/lisp/eshell/em-pred-tests.el index a050c6426e9..05ee5d4c4c3 100644 --- a/test/lisp/eshell/em-pred-tests.el +++ b/test/lisp/eshell/em-pred-tests.el @@ -28,11 +28,10 @@ (require 'eshell) (require 'em-glob) (require 'em-pred) +(require 'ert-x) (require 'eshell-tests-helpers - (expand-file-name "eshell-tests-helpers" - (file-name-directory (or load-file-name - default-directory)))) + (ert-resource-file "eshell-tests-helpers")) (defvar eshell-test-value nil) diff --git a/test/lisp/eshell/em-prompt-tests.el b/test/lisp/eshell/em-prompt-tests.el index 62ad76f644b..73cd6b14478 100644 --- a/test/lisp/eshell/em-prompt-tests.el +++ b/test/lisp/eshell/em-prompt-tests.el @@ -26,11 +26,10 @@ (require 'ert) (require 'eshell) (require 'em-prompt) +(require 'ert-x) (require 'eshell-tests-helpers - (expand-file-name "eshell-tests-helpers" - (file-name-directory (or load-file-name - default-directory)))) + (ert-resource-file "eshell-tests-helpers")) (defmacro em-prompt-test--with-multiline (&rest body) "Execute BODY with a multiline Eshell prompt." diff --git a/test/lisp/eshell/em-script-tests.el b/test/lisp/eshell/em-script-tests.el index 3259022957b..01dc5fd9a72 100644 --- a/test/lisp/eshell/em-script-tests.el +++ b/test/lisp/eshell/em-script-tests.el @@ -28,11 +28,10 @@ (require 'esh-mode) (require 'eshell) (require 'em-script) +(require 'ert-x) (require 'eshell-tests-helpers - (expand-file-name "eshell-tests-helpers" - (file-name-directory (or load-file-name - default-directory)))) + (ert-resource-file "eshell-tests-helpers")) (defvar eshell-execute-file-output) diff --git a/test/lisp/eshell/em-unix-tests.el b/test/lisp/eshell/em-unix-tests.el index 59cd0034507..b8969c5568a 100644 --- a/test/lisp/eshell/em-unix-tests.el +++ b/test/lisp/eshell/em-unix-tests.el @@ -30,8 +30,9 @@ (defvar this-directory (file-name-directory (or load-file-name default-directory)))) +(require 'ert-x) (require 'eshell-tests-helpers - (expand-file-name "eshell-tests-helpers" this-directory)) + (ert-resource-file "eshell-tests-helpers")) ;;; Tests: diff --git a/test/lisp/eshell/esh-arg-tests.el b/test/lisp/eshell/esh-arg-tests.el index f498cf6674c..4c34711ec2e 100644 --- a/test/lisp/eshell/esh-arg-tests.el +++ b/test/lisp/eshell/esh-arg-tests.el @@ -26,11 +26,10 @@ (require 'ert) (require 'esh-mode) (require 'eshell) +(require 'ert-x) (require 'eshell-tests-helpers - (expand-file-name "eshell-tests-helpers" - (file-name-directory (or load-file-name - default-directory)))) + (ert-resource-file "eshell-tests-helpers")) (defvar eshell-test-value nil) diff --git a/test/lisp/eshell/esh-cmd-tests.el b/test/lisp/eshell/esh-cmd-tests.el index 7c04749e7ec..25e6c0fda7c 100644 --- a/test/lisp/eshell/esh-cmd-tests.el +++ b/test/lisp/eshell/esh-cmd-tests.el @@ -26,11 +26,10 @@ (require 'ert) (require 'esh-mode) (require 'eshell) +(require 'ert-x) (require 'eshell-tests-helpers - (expand-file-name "eshell-tests-helpers" - (file-name-directory (or load-file-name - default-directory)))) + (ert-resource-file "eshell-tests-helpers")) (defvar eshell-test-value nil) diff --git a/test/lisp/eshell/esh-ext-tests.el b/test/lisp/eshell/esh-ext-tests.el index 696e679ccec..c6f5c48ae3e 100644 --- a/test/lisp/eshell/esh-ext-tests.el +++ b/test/lisp/eshell/esh-ext-tests.el @@ -28,11 +28,10 @@ (require 'esh-mode) (require 'esh-ext) (require 'eshell) +(require 'ert-x) (require 'eshell-tests-helpers - (expand-file-name "eshell-tests-helpers" - (file-name-directory (or load-file-name - default-directory)))) + (ert-resource-file "eshell-tests-helpers")) ;;; Tests: diff --git a/test/lisp/eshell/esh-io-tests.el b/test/lisp/eshell/esh-io-tests.el index 0b25ad812fa..d95b52297c7 100644 --- a/test/lisp/eshell/esh-io-tests.el +++ b/test/lisp/eshell/esh-io-tests.el @@ -23,11 +23,10 @@ (require 'ert-x) (require 'esh-mode) (require 'eshell) +(require 'ert-x) (require 'eshell-tests-helpers - (expand-file-name "eshell-tests-helpers" - (file-name-directory (or load-file-name - default-directory)))) + (ert-resource-file "eshell-tests-helpers")) (defvar eshell-test-value nil) diff --git a/test/lisp/eshell/esh-mode-tests.el b/test/lisp/eshell/esh-mode-tests.el index 052f62d6b9b..b8023029369 100644 --- a/test/lisp/eshell/esh-mode-tests.el +++ b/test/lisp/eshell/esh-mode-tests.el @@ -28,11 +28,10 @@ (require 'eshell) (require 'em-banner) (require 'em-prompt) +(require 'ert-x) (require 'eshell-tests-helpers - (expand-file-name "eshell-tests-helpers" - (file-name-directory (or load-file-name - default-directory)))) + (ert-resource-file "eshell-tests-helpers")) ;;; Tests: diff --git a/test/lisp/eshell/esh-proc-tests.el b/test/lisp/eshell/esh-proc-tests.el index 16f8d82e976..2ef8b9d7536 100644 --- a/test/lisp/eshell/esh-proc-tests.el +++ b/test/lisp/eshell/esh-proc-tests.el @@ -24,11 +24,10 @@ (require 'esh-mode) (require 'eshell) (require 'em-prompt) ; For `eshell-previous-prompt' +(require 'ert-x) (require 'eshell-tests-helpers - (expand-file-name "eshell-tests-helpers" - (file-name-directory (or load-file-name - default-directory)))) + (ert-resource-file "eshell-tests-helpers")) (defvar esh-proc-test--output-cmd (concat "sh -c '" diff --git a/test/lisp/eshell/esh-util-tests.el b/test/lisp/eshell/esh-util-tests.el index 6967dbcf012..39fc6288110 100644 --- a/test/lisp/eshell/esh-util-tests.el +++ b/test/lisp/eshell/esh-util-tests.el @@ -22,11 +22,10 @@ (require 'tramp) (require 'ert) (require 'esh-util) +(require 'ert-x) (require 'eshell-tests-helpers - (expand-file-name "eshell-tests-helpers" - (file-name-directory (or load-file-name - default-directory)))) + (ert-resource-file "eshell-tests-helpers")) ;;; Tests: diff --git a/test/lisp/eshell/esh-var-tests.el b/test/lisp/eshell/esh-var-tests.el index 153f8418153..20575d93407 100644 --- a/test/lisp/eshell/esh-var-tests.el +++ b/test/lisp/eshell/esh-var-tests.el @@ -28,11 +28,10 @@ (require 'esh-mode) (require 'esh-var) (require 'eshell) +(require 'ert-x) (require 'eshell-tests-helpers - (expand-file-name "eshell-tests-helpers" - (file-name-directory (or load-file-name - default-directory)))) + (ert-resource-file "eshell-tests-helpers")) (defvar eshell-test-value nil) (defvar eshell-test-begin nil) diff --git a/test/lisp/eshell/eshell-tests.el b/test/lisp/eshell/eshell-tests.el index 6565a4be65c..99e4528ab00 100644 --- a/test/lisp/eshell/eshell-tests.el +++ b/test/lisp/eshell/eshell-tests.el @@ -28,11 +28,10 @@ (require 'ert) (require 'ert-x) (require 'esh-mode) +(require 'ert-x) (require 'eshell) (require 'eshell-tests-helpers - (expand-file-name "eshell-tests-helpers" - (file-name-directory (or load-file-name - default-directory)))) + (ert-resource-file "eshell-tests-helpers")) (defvar eshell-test-value nil) (defvar eshell-command-output) diff --git a/test/lisp/eshell/eshell-tests-helpers.el b/test/lisp/eshell/resources/eshell-tests-helpers.el similarity index 100% rename from test/lisp/eshell/eshell-tests-helpers.el rename to test/lisp/eshell/resources/eshell-tests-helpers.el -- 2.39.5