Subject: Re: bug#70196: 30.0.50; sh-script-tests fails

From: Eli Zaretskii <[email-masked]>
Date: Thu, 04 Apr 2024 18:46:57 +0300

> From: Michael Albinus <[email-masked]>
> Cc: [email-masked]
> Date: Thu, 04 Apr 2024 17:02:22 +0200
> 
> The following works for me w/o problems:
> 
> --8<---------------cut here---------------start------------->8---
> # bash -ic "make -C test sh-script-tests"
> --8<---------------cut here---------------end--------------->8---
> 
> And the following shows the errors:
> 
> --8<---------------cut here---------------start------------->8---
> # tcsh -ic "make -C test sh-script-tests"
> --8<---------------cut here---------------end--------------->8---
> 
> So I guess one must check the used shell, when starting the tests.

Thanks, does the below fix the problem?

diff --git a/test/lisp/progmodes/sh-script-tests.el b/test/lisp/progmodes/sh-script-tests.el
index e73d523..3f810e8 100644
--- a/test/lisp/progmodes/sh-script-tests.el
+++ b/test/lisp/progmodes/sh-script-tests.el
@@ -25,11 +25,15 @@
 (require 'ert)
 (require 'ert-x)
 
+(defun sh-script-tests-shell-script-mode ()
+  (sh-set-shell "/bin/sh")
+  (shell-script-mode))
+
 (ert-deftest test-sh-script-indentation ()
   (with-temp-buffer
     (insert "relative-path/to/configure --prefix=$prefix\\
              --with-x")
-    (shell-script-mode)
+    (sh-script-tests-shell-script-mode)
     (goto-char (point-min))
     (forward-line 1)
     (indent-for-tab-command)
@@ -41,7 +45,7 @@ test-sh-script-indentation
 (ert-deftest test-basic-sh-indentation ()
   (with-temp-buffer
     (insert "myecho () {\necho foo\n}\n")
-    (shell-script-mode)
+    (sh-script-tests-shell-script-mode)
     (indent-region (point-min) (point-max))
     (should (equal (buffer-string)
   "myecho () {
@@ -55,7 +59,7 @@ test-indentation
 (ert-deftest test-indent-after-continuation ()
   (with-temp-buffer
     (insert "for f \\\nin a; do \\\ntoto; \\\ndone\n")
-    (shell-script-mode)
+    (sh-script-tests-shell-script-mode)
     (let ((sh-indent-for-continuation '++))
       (let ((sh-indent-after-continuation t))
         (indent-region (point-min) (point-max))
@@ -72,7 +76,7 @@ test-indent-after-continuation
 
 (defun test-sh-back (string &optional pos)
   (with-temp-buffer
-    (shell-script-mode)
+    (sh-script-tests-shell-script-mode)
     (insert string)
     (sh-smie--default-backward-token)
     (= (point) (or pos 1))))
@@ -90,7 +94,7 @@ test-backward-token
 (ert-deftest sh-script-test-do-fontification ()
   "Test that \"do\" gets fontified correctly, even with no \";\"."
   (with-temp-buffer
-    (shell-script-mode)
+    (sh-script-tests-shell-script-mode)
     (insert "for i do echo 1; done")
     (font-lock-ensure)
     (goto-char (point-min))