* contrib/lisp/org-e-texinfo.el: Added support for optional menu titles, also do...
[org-mode.git] / testing / lisp / test-ob-tangle.el
blob17bb433114ac4b1cd278adb1e2015c9725099bcb
1 ;;; test-ob-tangle.el
3 ;; Copyright (c) 2010-2012 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:
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"))))))
39 (ert-deftest ob-tangle/no-excessive-id-insertion-on-tangle ()
40 "Don't add IDs to headings without tangling code blocks."
41 (org-test-at-id "ef06fd7f-012b-4fde-87a2-2ae91504ea7e"
42 (org-babel-next-src-block)
43 (org-narrow-to-subtree)
44 (org-babel-tangle)
45 (should (null (org-id-get)))))
47 (ert-deftest ob-tangle/continued-code-blocks-w-noweb-ref ()
48 "Test that the :noweb-ref header argument is used correctly."
49 (org-test-at-id "54d68d4b-1544-4745-85ab-4f03b3cbd8a0"
50 (let ((tangled
51 "df|sed '1d'|awk '{print $5 \" \" $6}'|sort -n |tail -1|awk '{print $2}'"))
52 (org-narrow-to-subtree)
53 (org-babel-tangle)
54 (with-temp-buffer
55 (insert-file-contents "babel.sh")
56 (goto-char (point-min))
57 (should (re-search-forward (regexp-quote tangled) nil t)))
58 (delete-file "babel.sh"))))
60 (ert-deftest ob-tangle/expand-headers-as-noweb-references ()
61 "Test that references to headers are expanded during noweb expansion."
62 (org-test-at-id "2409e8ba-7b5f-4678-8888-e48aa02d8cb4"
63 (org-babel-next-src-block 2)
64 (let ((expanded (org-babel-expand-noweb-references)))
65 (should (string-match (regexp-quote "simple") expanded))
66 (should (string-match (regexp-quote "length 14") expanded)))))
68 (provide 'test-ob-tangle)
70 ;;; test-ob-tangle.el ends here