emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/org 6e0012867d 2/8: test-ob-shell.el: Refactor test-ob-


From: ELPA Syncer
Subject: [elpa] externals/org 6e0012867d 2/8: test-ob-shell.el: Refactor test-ob-shell/session
Date: Wed, 11 Jan 2023 11:58:07 -0500 (EST)

branch: externals/org
commit 6e0012867d8594913cf4783d7afdc109b8307de3
Author: Matt Trzcinski <matt@excalamus.com>
Commit: Matt Trzcinski <matt@excalamus.com>

    test-ob-shell.el: Refactor test-ob-shell/session
    
    * testing/lisp/test-ob-shell.el (ob-shell/session): Split
    `ob-shell/session' into
    `test-ob-shell/session-single-return-returns-string' and
    `test-ob-shell/session-multiple-returns-returns-list'.
    (ob-shell/session): Rename comint from to test name. On
    pass, kill process and remove process buffer.
---
 testing/lisp/test-ob-shell.el | 32 +++++++++++++++++++++-----------
 1 file changed, 21 insertions(+), 11 deletions(-)

diff --git a/testing/lisp/test-ob-shell.el b/testing/lisp/test-ob-shell.el
index fc3ecd3c8f..b08bf84131 100644
--- a/testing/lisp/test-ob-shell.el
+++ b/testing/lisp/test-ob-shell.el
@@ -45,18 +45,28 @@ unless the body of the tangled block does."
   (if (should (null (org-babel-execute:sh "ls NoSuchFileOrDirectory.txt" nil)))
       (kill-buffer "*Org-Babel Error Output*")))
 
-(ert-deftest test-ob-shell/session ()
-  "This also tests `org-babel-comint-with-output' in
-ob-comint.el, which was not previously tested."
-  (let ((res (org-babel-execute:sh "echo 1; echo 2" '((:session . "yes")))))
-    (should res)
-    (should (listp res)))
-  ;; Test multi-line input.
-  (let ((result (org-babel-execute:sh
-                "if true \n then \n echo yes \n fi"
-                '((:session . "yes")))))
+(ert-deftest test-ob-shell/session-single-return-returns-string ()
+  "Sessions with a single result should return a string."
+  (let* ((session-name 
"test-ob-shell/session-evaluation-single-return-returns-string")
+         (kill-buffer-query-functions nil)
+         (result (org-babel-execute:sh
+                  (format "echo %s" session-name)
+                  `((:session . ,session-name)))))
     (should result)
-    (should (string= "yes" result))))
+    (if (should (string= session-name result))
+        (kill-buffer session-name))))
+
+(ert-deftest test-ob-shell/session-multiple-returns-returns-list ()
+  "Sessions with multiple results should return a list."
+  (let* ((session-name "test-ob-shell/session-multiple-returns-returns-list")
+         (kill-buffer-query-functions nil)
+         (result (org-babel-execute:sh
+                  "echo 1; echo 2"
+                  `((:session . ,session-name)))))
+    (should result)
+    (should (listp result))
+    (if (should (equal '((1) (2)) result))
+        (kill-buffer session-name))))
 
 ; A list of tests using the samples in ob-shell-test.org
 (ert-deftest ob-shell/generic-uses-no-arrays ()



reply via email to

[Prev in Thread] Current Thread [Next in Thread]