test-ob-sh.el 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. ;;; test-ob-sh.el
  2. ;; Copyright (c) 2010-2012 Eric Schulte
  3. ;; Authors: Eric Schulte
  4. ;; Released under the GNU General Public License version 3
  5. ;; see: http://www.gnu.org/licenses/gpl-3.0.html
  6. ;; Template test file for Org-mode tests
  7. ;;; Code:
  8. (org-test-for-executable "sh")
  9. (unless (featurep 'ob-sh)
  10. (signal 'missing-test-dependency "Support for Sh code blocks"))
  11. (ert-deftest test-ob-sh/dont-insert-spaces-on-expanded-bodies ()
  12. "Expanded shell bodies should not start with a blank line
  13. unless the body of the tangled block does."
  14. (should-not (string-match "^[\n\r][\t ]*[\n\r]"
  15. (org-babel-expand-body:generic "echo 2" '())))
  16. (should (string-match "^[\n\r][\t ]*[\n\r]"
  17. (org-babel-expand-body:generic "\n\necho 2" '()))))
  18. (ert-deftest test-ob-sh/dont-error-on-empty-results ()
  19. "Was throwing an elisp error when shell blocks threw errors and
  20. returned empty results."
  21. (should (null (org-babel-execute:sh "ls NoSuchFileOrDirectory.txt" nil))))
  22. (ert-deftest test-ob-sh/session ()
  23. "This also tests `org-babel-comint-with-output' in
  24. ob-comint.el, which was not previously tested."
  25. (let ((res (org-babel-execute:sh "echo 1; echo 2" '((:session . "yes")))))
  26. (should res)
  27. (should (listp res))))
  28. (provide 'test-ob-sh)
  29. ;;; test-ob-sh.el ends here