emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
blob 8f6def8cadab3771d2c38a2a035daa7d0b25267f 3122 bytes (raw)
name: testing/lisp/test-ob-comint.el 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
 
;;; test-ob-comint.el  -*- lexical-binding: t; -*-

;; Copyright (c) 2024 Matthew Trzcinski
;; Authors: Matthew Trzcinski

;; This file is not part of GNU Emacs.

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program.  If not, see <https://www.gnu.org/licenses/>.

\f
;;; Comment:

;; See testing/README for how to run tests.

\f
;;; Requirements:

\f
;;; Code:
(ert-deftest test-org-babel-comint/prompt-filter-removes-prompt ()
  "Test that prompt is actually removed."
  (let* ((prompt "org_babel_sh_prompt> ")
         (results "org_babel_sh_prompt> echo 'ob_comint_async_shell_start_d78ac49f-dc8a-4c39-827c-c93225484d59'
# print message
echo \"hello world\"
echo 'ob_comint_async_shell_end_d78ac49f-dc8a-4c39-827c-c93225484d59'
ob_comint_async_shell_start_d78ac49f-dc8a-4c39-827c-c93225484d59
org_babel_sh_prompt> org_babel_sh_prompt> \"hello world\"
org_babel_sh_prompt> ob_comint_async_shell_end_d78ac49f-dc8a-4c39-827c-c93225484d59
org_babel_sh_prompt> "))
    (should (string=
             (org-trim (string-join (mapcar #'org-trim (org-babel-comint--prompt-filter results prompt)) "\n") "\n")
             "echo 'ob_comint_async_shell_start_d78ac49f-dc8a-4c39-827c-c93225484d59'
# print message
echo \"hello world\"
echo 'ob_comint_async_shell_end_d78ac49f-dc8a-4c39-827c-c93225484d59'
ob_comint_async_shell_start_d78ac49f-dc8a-4c39-827c-c93225484d59
\"hello world\"
ob_comint_async_shell_end_d78ac49f-dc8a-4c39-827c-c93225484d59"))))

(ert-deftest test-org-babel-comint/echo-filter-removes-echo ()
  "Test that echo is actually removed."
  (let* ((echo "echo 'ob_comint_async_shell_start_d78ac49f-dc8a-4c39-827c-c93225484d59'
# print message
echo \"hello world\"
echo 'ob_comint_async_shell_end_d78ac49f-dc8a-4c39-827c-c93225484d59'")
         (result "org_babel_sh_prompt> echo 'ob_comint_async_shell_start_d78ac49f-dc8a-4c39-827c-c93225484d59'
# print message
echo \"hello world\"
echo 'ob_comint_async_shell_end_d78ac49f-dc8a-4c39-827c-c93225484d59'
ob_comint_async_shell_start_d78ac49f-dc8a-4c39-827c-c93225484d59
org_babel_sh_prompt> org_babel_sh_prompt> \"hello world\"
org_babel_sh_prompt> ob_comint_async_shell_end_d78ac49f-dc8a-4c39-827c-c93225484d59
org_babel_sh_prompt> "))
    (should (string=
             (org-babel-comint--echo-filter result echo)
             "\nob_comint_async_shell_start_d78ac49f-dc8a-4c39-827c-c93225484d59
org_babel_sh_prompt> org_babel_sh_prompt> \"hello world\"
org_babel_sh_prompt> ob_comint_async_shell_end_d78ac49f-dc8a-4c39-827c-c93225484d59
org_babel_sh_prompt> "))))

(provide 'test-ob-comint)

;;; test-ob-comint.el ends here

debug log:

solving 8f6def8ca ...
found 8f6def8ca in https://git.savannah.gnu.org/cgit/emacs/org-mode.git

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).