test-ob-tangle.el 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. ;;; test-ob-tangle.el
  2. ;; Copyright (c) 2010 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. ;;;; Comments:
  7. ;; Template test file for Org-mode tests
  8. ;;; Code:
  9. (let ((load-path (cons (expand-file-name
  10. ".." (file-name-directory
  11. (or load-file-name buffer-file-name)))
  12. load-path)))
  13. (require 'org-test)
  14. (require 'org-test-ob-consts))
  15. ;;; Tests
  16. (ert-deftest ob-tangle/noweb-on-tangle ()
  17. "Noweb header arguments tangle correctly.
  18. - yes expand on both export and tangle
  19. - no expand on neither export or tangle
  20. - tangle expand on only tangle not export"
  21. (let ((target-file (make-temp-file "ob-tangle-test-")))
  22. (org-test-at-id "eb1f6498-5bd9-45e0-9c56-50717053e7b7"
  23. (org-narrow-to-subtree)
  24. (org-babel-tangle target-file))
  25. (let ((tang (with-temp-buffer
  26. (insert-file-contents target-file)
  27. (buffer-string))))
  28. (flet ((exp-p (arg)
  29. (and
  30. (string-match
  31. (format "noweb-%s-start\\([^\000]*\\)noweb-%s-end" arg arg)
  32. tang)
  33. (string-match "expanded" (match-string 1 tang)))))
  34. (should (exp-p "yes"))
  35. (should-not (exp-p "no"))
  36. (should (exp-p "tangle"))))))
  37. (ert-deftest ob-tangle/no-excessive-id-insertion-on-tangle ()
  38. "Don't add IDs to headings without tangling code blocks."
  39. (org-test-at-id "ae7b55ca-9ef2-4d30-bd48-da30e35fd0f3"
  40. (org-babel-next-src-block)
  41. (org-babel-tangle)
  42. (org-babel-previous-src-block)
  43. (should (null (org-id-get)))))
  44. (provide 'test-ob-tangle)
  45. ;;; test-ob-tangle.el ends here