test-ob-eshell.el 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. (goto-char (org-babel-where-is-src-block-result))
  30. (forward-line)
  31. (buffer-substring-no-properties (point) (line-end-position)))
  32. ": 2")))
  33. (ert-deftest ob-eshell/variables-assignment ()
  34. "Test ob-eshell variables assignment."
  35. (should
  36. (string=
  37. (org-test-with-temp-text
  38. "#+begin_src eshell :var hi=\"hello, world\"
  39. echo $hi
  40. #+end_src"
  41. (org-babel-execute-src-block)
  42. (goto-char (org-babel-where-is-src-block-result))
  43. (forward-line)
  44. (buffer-substring-no-properties (point) (line-end-position)))
  45. ": hello, world")))
  46. (ert-deftest ob-eshell/session ()
  47. "Test ob-eshell session."
  48. (should
  49. (string=
  50. (org-test-with-temp-text
  51. "#+begin_src eshell :session
  52. (setq hi \"hello, world\")
  53. #+end_src
  54. #+begin_src eshell :session
  55. echo $hi
  56. #+end_src"
  57. (org-babel-execute-src-block)
  58. (org-babel-next-src-block)
  59. (org-babel-execute-src-block)
  60. (goto-char (org-babel-where-is-src-block-result))
  61. (forward-line)
  62. (buffer-substring-no-properties (point) (line-end-position)))
  63. ": hello, world")))
  64. (provide 'test-ob-eshell)
  65. ;;; test-ob-eshell.el ends here