test-ob-tangle.el 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. ;;; test-ob-tangle.el
  2. ;; Copyright (c) 2010-2012 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. ;; TODO
  10. ;; (ert-deftest ob-tangle/noweb-on-tangle ()
  11. ;; "Noweb header arguments tangle correctly.
  12. ;; - yes expand on both export and tangle
  13. ;; - no expand on neither export or tangle
  14. ;; - tangle expand on only tangle not export"
  15. ;; (let ((target-file (make-temp-file "ob-tangle-test-")))
  16. ;; (org-test-at-id "eb1f6498-5bd9-45e0-9c56-50717053e7b7"
  17. ;; (org-narrow-to-subtree)
  18. ;; (org-babel-tangle target-file))
  19. ;; (let ((tang (with-temp-buffer
  20. ;; (insert-file-contents target-file)
  21. ;; (buffer-string))))
  22. ;; (flet ((exp-p (arg)
  23. ;; (and
  24. ;; (string-match
  25. ;; (format "noweb-%s-start\\([^\000]*\\)noweb-%s-end" arg arg)
  26. ;; tang)
  27. ;; (string-match "expanded" (match-string 1 tang)))))
  28. ;; (should (exp-p "yes"))
  29. ;; (should-not (exp-p "no"))
  30. ;; (should (exp-p "tangle"))))))
  31. (ert-deftest ob-tangle/no-excessive-id-insertion-on-tangle ()
  32. "Don't add IDs to headings without tangling code blocks."
  33. (org-test-at-id "ef06fd7f-012b-4fde-87a2-2ae91504ea7e"
  34. (org-babel-next-src-block)
  35. (org-narrow-to-subtree)
  36. (org-babel-tangle)
  37. (should (null (org-id-get)))))
  38. (ert-deftest ob-tangle/continued-code-blocks-w-noweb-ref ()
  39. "Test that the :noweb-ref header argument is used correctly."
  40. (org-test-at-id "54d68d4b-1544-4745-85ab-4f03b3cbd8a0"
  41. (let ((tangled
  42. "df|sed '1d'|awk '{print $5 \" \" $6}'|sort -n |tail -1|awk '{print $2}'"))
  43. (org-narrow-to-subtree)
  44. (org-babel-tangle)
  45. (with-temp-buffer
  46. (insert-file-contents "babel.sh")
  47. (goto-char (point-min))
  48. (should (re-search-forward (regexp-quote tangled) nil t)))
  49. (delete-file "babel.sh"))))
  50. (ert-deftest ob-tangle/expand-headers-as-noweb-references ()
  51. "Test that references to headers are expanded during noweb expansion."
  52. (org-test-at-id "2409e8ba-7b5f-4678-8888-e48aa02d8cb4"
  53. (org-babel-next-src-block 2)
  54. (let ((expanded (org-babel-expand-noweb-references)))
  55. (should (string-match (regexp-quote "simple") expanded))
  56. (should (string-match (regexp-quote "length 14") expanded)))))
  57. (provide 'test-ob-tangle)
  58. ;;; test-ob-tangle.el ends here