test-ob-eshell.el 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. ;;; test-ob-eshell.el -*- lexical-binding: t; -*-
  2. ;; Copyright (c) 2018 stardiviner
  3. ;; Authors: stardiviner
  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 <https://www.gnu.org/licenses/>.
  15. ;;; Comment:
  16. ;; Template test file for Org tests
  17. ;;; Code:
  18. (unless (featurep 'ob-eshell)
  19. (signal 'missing-test-dependency "Support for Eshell code blocks"))
  20. (ert-deftest ob-eshell/execute ()
  21. "Test ob-eshell execute."
  22. (should
  23. (string=
  24. (org-test-with-temp-text
  25. "#+begin_src eshell
  26. echo 2
  27. #+end_src"
  28. (org-babel-execute-src-block))
  29. ": 2")))
  30. (ert-deftest ob-eshell/variables-assignment ()
  31. "Test ob-eshell variables assignment."
  32. (should
  33. (string=
  34. (org-test-with-temp-text
  35. "#+begin_src eshell :var hi=\"hello, world\"
  36. echo $hi
  37. #+end_src"
  38. (org-babel-execute-src-block))
  39. ": hello, world")))
  40. (ert-deftest ob-eshell/session ()
  41. "Test ob-eshell session."
  42. (should
  43. (string=
  44. (org-test-with-temp-text
  45. "#+begin_src eshell :session
  46. (setq hi \"hello, world\")
  47. #+end_src
  48. #+begin_src eshell :session
  49. echo $hi
  50. #+end_src"
  51. (org-babel-execute-src-block)
  52. (org-babel-next-src-block)
  53. (org-babel-execute-src-block)
  54. (goto-char (org-babel-where-is-src-block-result))
  55. (forward-line)
  56. (buffer-substring-no-properties (point) (line-end-position)))
  57. ": hello, world")))
  58. (provide 'test-ob-eshell)
  59. ;;; test-ob-eshell.el ends here