org.el (org-display-inline-images): Honor the ̀beg' parameter.
[org-mode/org-mode-NeilSmithlineMods.git] / testing / lisp / test-ob-tangle.el
blob5f0385ef74c9b05e054e223934524df0d9000377
1 ;;; test-ob-tangle.el
3 ;; Copyright (c) 2010 Eric Schulte
4 ;; Authors: Eric Schulte
6 ;; Released under the GNU General Public License version 3
7 ;; see: http://www.gnu.org/licenses/gpl-3.0.html
9 ;;;; Comments:
11 ;; Template test file for Org-mode tests
14 ;;; Code:
15 (let ((load-path (cons (expand-file-name
16 ".." (file-name-directory
17 (or load-file-name buffer-file-name)))
18 load-path)))
19 (require 'org-test)
20 (require 'org-test-ob-consts))
23 ;;; Tests
25 ;; TODO
26 ;; (ert-deftest ob-tangle/noweb-on-tangle ()
27 ;; "Noweb header arguments tangle correctly.
28 ;; - yes expand on both export and tangle
29 ;; - no expand on neither export or tangle
30 ;; - tangle expand on only tangle not export"
31 ;; (let ((target-file (make-temp-file "ob-tangle-test-")))
32 ;; (org-test-at-id "eb1f6498-5bd9-45e0-9c56-50717053e7b7"
33 ;; (org-narrow-to-subtree)
34 ;; (org-babel-tangle target-file))
35 ;; (let ((tang (with-temp-buffer
36 ;; (insert-file-contents target-file)
37 ;; (buffer-string))))
38 ;; (flet ((exp-p (arg)
39 ;; (and
40 ;; (string-match
41 ;; (format "noweb-%s-start\\([^\000]*\\)noweb-%s-end" arg arg)
42 ;; tang)
43 ;; (string-match "expanded" (match-string 1 tang)))))
44 ;; (should (exp-p "yes"))
45 ;; (should-not (exp-p "no"))
46 ;; (should (exp-p "tangle"))))))
48 (ert-deftest ob-tangle/no-excessive-id-insertion-on-tangle ()
49 "Don't add IDs to headings without tangling code blocks."
50 (org-test-at-id "ef06fd7f-012b-4fde-87a2-2ae91504ea7e"
51 (org-babel-next-src-block)
52 (org-narrow-to-subtree)
53 (org-babel-tangle)
54 (should (null (org-id-get)))))
56 (ert-deftest ob-tangle/continued-code-blocks-w-noweb-ref ()
57 "Test that the :noweb-ref header argument is used correctly."
58 (org-test-at-id "54d68d4b-1544-4745-85ab-4f03b3cbd8a0"
59 (let ((tangled
60 "df|sed '1d'|awk '{print $5 \" \" $6}'|sort -n |tail -1|awk '{print $2}'"))
61 (org-narrow-to-subtree)
62 (org-babel-tangle)
63 (with-temp-buffer
64 (insert-file-contents "babel.sh")
65 (goto-char (point-min))
66 (should (re-search-forward (regexp-quote tangled) nil t)))
67 (delete-file "babel.sh"))))
69 (ert-deftest ob-tangle/expand-headers-as-noweb-references ()
70 "Test that references to headers are expanded during noweb expansion."
71 (org-test-at-id "2409e8ba-7b5f-4678-8888-e48aa02d8cb4"
72 (org-babel-next-src-block 2)
73 (let ((expanded (org-babel-expand-noweb-references)))
74 (should (string-match (regexp-quote "simple") expanded))
75 (should (string-match (regexp-quote "length 14") expanded)))))
77 (provide 'test-ob-tangle)
79 ;;; test-ob-tangle.el ends here