From 406b5ba68537af2ce8f391eba070f99a1705e354 Mon Sep 17 00:00:00 2001 From: Jim Porter Date: Sun, 9 Jun 2024 11:53:29 -0700 Subject: [PATCH] ; Add another test for 'eshell-batch-script' * lisp/eshell/em-script.el (eshell-close-target): New function. * test/lisp/eshell/em-script-tests.el (em-script-test/batch-file): New test; rename old one to... (em-script-test/batch-file/shebang): ... this. (cherry picked from commit b91b81957c52306b68b9c122311eb6463343e539) --- lisp/eshell/em-script.el | 4 ++++ test/lisp/eshell/em-script-tests.el | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/lisp/eshell/em-script.el b/lisp/eshell/em-script.el index 88dad840eaa..6cddffdcf5f 100644 --- a/lisp/eshell/em-script.el +++ b/lisp/eshell/em-script.el @@ -137,6 +137,10 @@ Comments begin with `#'." "Return non-nil to indicate that the display is line-oriented." t) +(cl-defmethod eshell-close-target ((_target eshell-princ-target) _status) + "Close the `princ' function TARGET." + nil) + ;;;###autoload (defun eshell-batch-file () "Execute an Eshell script as a batch script from the command line. diff --git a/test/lisp/eshell/em-script-tests.el b/test/lisp/eshell/em-script-tests.el index 94afe775a3b..224e9162461 100644 --- a/test/lisp/eshell/em-script-tests.el +++ b/test/lisp/eshell/em-script-tests.el @@ -116,6 +116,18 @@ (ert-deftest em-script-test/batch-file () "Test running an Eshell script file as a batch script." (skip-unless (not (memq system-type '(windows-nt ms-dos)))) + (ert-with-temp-file temp-file + :text "echo hi" + (with-temp-buffer + (with-temp-eshell-settings + (call-process (expand-file-name invocation-name invocation-directory) + nil '(t nil) nil + "--batch" "-f" "eshell-batch-file" temp-file)) + (should (equal (buffer-string) "hi\n"))))) + +(ert-deftest em-script-test/batch-file/shebang () + "Test running an Eshell script file as a batch script via a shebang." + (skip-unless (not (memq system-type '(windows-nt ms-dos)))) (ert-with-temp-file temp-file :text (format "#!/usr/bin/env -S %s --batch -f eshell-batch-file\necho hi" -- 2.39.2