浏览代码

added a test for the new noweb-ref header argument, passing all tests

* testing/examples/babel.org: Example data for new test.
* testing/lisp/test-ob-tangle.el
  (ob-tangle/no-excessive-id-insertion-on-tangle): Safer to narrow,
  and less work.
  (ob-tangle/continued-code-blocks-w-noweb-ref): Testing new
  :noweb-ref header argument.
Eric Schulte 14 年之前
父节点
当前提交
ff62c5d700
共有 2 个文件被更改,包括 45 次插入0 次删除
  1. 28 0
      testing/examples/babel.org
  2. 17 0
      testing/lisp/test-ob-tangle.el

+ 28 - 0
testing/examples/babel.org

@@ -174,3 +174,31 @@
 #+begin_src emacs-lisp :var lst=a-list :results list
   (reverse lst)
 #+end_src
+* using the =:noweb-ref= header argument
+  :PROPERTIES:
+  :ID:       54d68d4b-1544-4745-85ab-4f03b3cbd8a0
+  :END:
+
+#+begin_src sh :tangle yes :noweb yes :shebang #!/bin/sh
+  <<fullest-disk>>
+#+end_src
+
+** query all mounted disks
+#+begin_src sh :noweb-ref fullest-disk
+  df \
+#+end_src
+
+** strip the header row
+#+begin_src sh :noweb-ref fullest-disk
+  |sed '1d' \
+#+end_src
+
+** sort by the percent full
+#+begin_src sh :noweb-ref fullest-disk
+  |awk '{print $5 " " $6}'|sort -n |tail -1 \
+#+end_src
+
+** extract the mount point
+#+begin_src sh :noweb-ref fullest-disk
+  |awk '{print $2}'
+#+end_src

+ 17 - 0
testing/lisp/test-ob-tangle.el

@@ -49,9 +49,26 @@
   "Don't add IDs to headings without tangling code blocks."
   (org-test-at-id "ef06fd7f-012b-4fde-87a2-2ae91504ea7e"
     (org-babel-next-src-block)
+    (org-narrow-to-subtree)
     (org-babel-tangle)
     (should (null (org-id-get)))))
 
+(ert-deftest ob-tangle/continued-code-blocks-w-noweb-ref ()
+  "Test that the :noweb-ref header argument is used correctly."
+  (org-test-at-id "54d68d4b-1544-4745-85ab-4f03b3cbd8a0"
+    (let ((tangled "df \\
+|sed '1d' \\
+|awk '{print $5 \" \" $6}'|sort -n |tail -1 \\
+|awk '{print $2}'
+"))
+      (org-narrow-to-subtree)
+      (org-babel-tangle)
+      (with-temp-buffer
+	(insert-file-contents "babel.sh")
+	(goto-char (point-min))
+	(should (re-search-forward (regexp-quote tangled) nil t)))
+      (delete-file "babel.sh"))))
+
 (provide 'test-ob-tangle)
 
 ;;; test-ob-tangle.el ends here