test-ob-sed.el 2.1 KB

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