test-ob-tangle.el 2.6 KB

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