From e8a7a82ad10073172eef2ef9e215860af56feb82 Mon Sep 17 00:00:00 2001
From: Matt <matt@excalamus.com>
Date: Tue, 20 Dec 2022 18:10:52 -0500
Subject: [PATCH 4/7] Refactor ob-shell/generic-uses-no-arrays

- Introduce `multiline-string` macro
- Rename from "ob-shell" to "test-ob-shell"
- Remove external file dependency
---
 testing/lisp/test-ob-shell.el | 29 ++++++++++++++++++++++++-----
 1 file changed, 24 insertions(+), 5 deletions(-)

diff --git a/testing/lisp/test-ob-shell.el b/testing/lisp/test-ob-shell.el
index ecdc461d3..9c80aa1af 100644
--- a/testing/lisp/test-ob-shell.el
+++ b/testing/lisp/test-ob-shell.el
@@ -23,6 +23,18 @@
 ;; Template test file for Org tests
 
 ;;; Code:
+(defmacro multiline-string (&rest body)
+  "Join BODY with newlines.
+
+BODY is made of successive strings.
+
+    (multiline-string \"first\" \"second\" \"third\")
+    ⇒ \"first\\nsecond\\nthird\"
+
+\(fn BODY)"
+  (declare (indent nil) (debug t))
+  `(string-join (quote ,body) "\n"))
+
 (org-test-for-executable "sh")
 (require 'ob-core)
 (unless (featurep 'ob-shell)
@@ -62,11 +74,18 @@ the body of the tangled block does."
   (let ((kill-buffer-query-functions nil))
     (kill-buffer "test-ob-shell/session-parameter-results-in-list")))
 
-; A list of tests using the samples in ob-shell-test.org
-(ert-deftest ob-shell/generic-uses-no-arrays ()
-  "No arrays for generic"
-  (org-test-at-id "0ba56632-8dc1-405c-a083-c204bae477cf"
-    (org-babel-next-src-block)
+(ert-deftest test-ob-shell/generic-uses-no-arrays ()
+  (org-test-with-temp-text
+      (multiline-string
+       "#+NAME: sample_array"
+       "| one   |"
+       "| two   |"
+       "| three |"
+       ""
+       "#+begin_src sh :exports results :results output :var array=sample_array"
+       "echo ${array}"
+       "<point>"
+       "#+end_src")
     (should (equal "one two three" (org-trim (org-babel-execute-src-block))))))
 
 (ert-deftest ob-shell/bash-uses-arrays ()
-- 
2.38.1

