test-ob-tangle.el 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. (provide 'test-ob-tangle)
  38. ;;; test-ob-tangle.el ends here