ob-forth: Silence byte-compiler
[org-mode.git] / testing / lisp / test-ob-shell.el
blob58a7859ad28ab404fa74ecfddb41d5175358e5b9
1 ;;; test-ob-shell.el
3 ;; Copyright (c) 2010-2014 Eric Schulte
4 ;; Authors: Eric Schulte
6 ;; This file is not part of GNU Emacs.
8 ;; This program is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation, either version 3 of the License, or
11 ;; (at your option) any later version.
13 ;; This program is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
21 ;;; Comment:
23 ;; Template test file for Org-mode tests
25 ;;; Code:
26 (org-test-for-executable "sh")
27 (unless (featurep 'ob-shell)
28 (signal 'missing-test-dependency "Support for Shell code blocks"))
30 (ert-deftest test-ob-shell/dont-insert-spaces-on-expanded-bodies ()
31 "Expanded shell bodies should not start with a blank line
32 unless the body of the tangled block does."
33 (should-not (string-match "^[\n\r][\t ]*[\n\r]"
34 (org-babel-expand-body:generic "echo 2" '())))
35 (should (string-match "^[\n\r][\t ]*[\n\r]"
36 (org-babel-expand-body:generic "\n\necho 2" '()))))
38 (ert-deftest test-ob-shell/dont-error-on-empty-results ()
39 "Was throwing an elisp error when shell blocks threw errors and
40 returned empty results."
41 (should (null (org-babel-execute:sh "ls NoSuchFileOrDirectory.txt" nil))))
43 (ert-deftest test-ob-shell/session ()
44 "This also tests `org-babel-comint-with-output' in
45 ob-comint.el, which was not previously tested."
46 (let ((res (org-babel-execute:sh "echo 1; echo 2" '((:session . "yes")))))
47 (should res)
48 (should (listp res))))
50 ; A list of tests using the samples in ob-shell-test.org
51 (ert-deftest ob-shell/generic-uses-no-arrays ()
52 "No arrays for generic"
53 (org-test-at-id "0ba56632-8dc1-405c-a083-c204bae477cf"
54 (org-babel-next-src-block)
55 (should (equal "one two three" (org-babel-execute-src-block)))))
57 (ert-deftest ob-shell/bash-uses-arrays ()
58 "Bash arrays"
59 (org-test-at-id "0ba56632-8dc1-405c-a083-c204bae477cf"
60 (org-babel-next-src-block 2)
61 (should (equal "one" (org-babel-execute-src-block)))))
63 (ert-deftest ob-shell/generic-uses-no-assoc-arrays ()
64 "No associative arrays for generic"
65 (org-test-at-id "bec1a5b0-4619-4450-a8c0-2a746b44bf8d"
66 (org-babel-next-src-block)
67 (should (equal "first one second two third three"
68 (org-babel-execute-src-block)))))
70 (ert-deftest ob-shell/bash-uses-assoc-arrays ()
71 "Bash associative arrays"
72 (org-test-at-id "bec1a5b0-4619-4450-a8c0-2a746b44bf8d"
73 (org-babel-next-src-block 2)
74 (should (equal "two" (org-babel-execute-src-block)))))
76 (ert-deftest ob-shell/generic-uses-no-assoc-arrays ()
77 "No associative arrays for generic"
78 (org-test-at-id "82320a48-3409-49d7-85c9-5de1c6d3ff87"
79 (org-babel-next-src-block)
80 (should (equal "bread 2 kg spaghetti 20 cm milk 50 dl"
81 (org-babel-execute-src-block)))))
83 (ert-deftest ob-shell/bash-uses-assoc-arrays ()
84 "Bash associative arrays as strings for the row"
85 (org-test-at-id "82320a48-3409-49d7-85c9-5de1c6d3ff87"
86 (org-babel-next-src-block 2)
87 (should (equal "20 cm" (org-babel-execute-src-block)))))
90 (provide 'test-ob-shell)
92 ;;; test-ob-shell.el ends here