test-ob-shell.el 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. ;;; test-ob-shell.el
  2. ;; Copyright (c) 2010-2014 Eric Schulte
  3. ;; Authors: Eric Schulte
  4. ;; This file is not part of GNU Emacs.
  5. ;; This program is free software; you can redistribute it and/or modify
  6. ;; it under the terms of the GNU General Public License as published by
  7. ;; the Free Software Foundation, either version 3 of the License, or
  8. ;; (at your option) any later version.
  9. ;; This program is distributed in the hope that it will be useful,
  10. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. ;; GNU General Public License for more details.
  13. ;; You should have received a copy of the GNU General Public License
  14. ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. ;;; Comment:
  16. ;; Template test file for Org-mode tests
  17. ;;; Code:
  18. (org-test-for-executable "sh")
  19. (unless (featurep 'ob-shell)
  20. (signal 'missing-test-dependency "Support for Shell code blocks"))
  21. (ert-deftest test-ob-shell/dont-insert-spaces-on-expanded-bodies ()
  22. "Expanded shell bodies should not start with a blank line
  23. unless the body of the tangled block does."
  24. (should-not (string-match "^[\n\r][\t ]*[\n\r]"
  25. (org-babel-expand-body:generic "echo 2" '())))
  26. (should (string-match "^[\n\r][\t ]*[\n\r]"
  27. (org-babel-expand-body:generic "\n\necho 2" '()))))
  28. (ert-deftest test-ob-shell/dont-error-on-empty-results ()
  29. "Was throwing an elisp error when shell blocks threw errors and
  30. returned empty results."
  31. (should (null (org-babel-execute:sh "ls NoSuchFileOrDirectory.txt" nil))))
  32. (ert-deftest test-ob-shell/session ()
  33. "This also tests `org-babel-comint-with-output' in
  34. ob-comint.el, which was not previously tested."
  35. (let ((res (org-babel-execute:sh "echo 1; echo 2" '((:session . "yes")))))
  36. (should res)
  37. (should (listp res))))
  38. (provide 'test-ob-shell)
  39. ;;; test-ob-shell.el ends here