test-ob-sed.el 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. ;;; test-ob-sed.el --- tests for ob-sed.el
  2. ;; Copyright (c) 2015 Bjarte Johansen
  3. ;; Authors: Bjarte Johansen
  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. ;;; Code:
  16. (org-test-for-executable "sed")
  17. (unless (featurep 'ob-sed)
  18. (signal 'missing-test-dependency "Support for Sed code blocks"))
  19. (ert-deftest ob-sed-test/simple-execution-of-script ()
  20. "Test simple execution of script."
  21. (org-test-at-id "C7E7CA6A-2601-42C9-B534-4102D62E458D"
  22. (org-babel-next-src-block)
  23. (should (string= "A processed sentence.\n"
  24. (org-babel-execute-src-block)))))
  25. (ert-deftest ob-sed-test/in-file-header-argument ()
  26. "Test :in-file header argument."
  27. (org-test-at-id "54EC49AA-FE9F-4D58-812E-00FC87FAF562"
  28. (let ((default-directory temporary-file-directory))
  29. (with-temp-buffer
  30. (insert "A test file.")
  31. (write-file "test1.txt"))
  32. (org-babel-next-src-block)
  33. (should (string= "A tested file.\n"
  34. (org-babel-execute-src-block))))))
  35. (ert-deftest ob-sed-test/cmd-line-header-argument ()
  36. "Test :cmd-line header argument."
  37. (org-test-at-id "E3C6A8BA-39FF-4840-BA8E-90D5C4365AB1"
  38. (let ((default-directory temporary-file-directory))
  39. (with-temp-buffer
  40. (insert "A test file.")
  41. (write-file "test2.txt"))
  42. (org-babel-next-src-block)
  43. (org-babel-execute-src-block)
  44. (should (string= "A tested again file.\n"
  45. (with-temp-buffer
  46. (insert-file-contents "test2.txt")
  47. (buffer-string)))))))
  48. ;;; test-ob-sed ends here