From ff62c5d700859c72746da60cf74891e070c7140d Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Wed, 15 Jun 2011 21:27:58 -0700 Subject: [PATCH] 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. --- testing/examples/babel.org | 28 ++++++++++++++++++++++++++++ testing/lisp/test-ob-tangle.el | 17 +++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/testing/examples/babel.org b/testing/examples/babel.org index 506d88bd2..779565265 100644 --- a/testing/examples/babel.org +++ b/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 + <> +#+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 diff --git a/testing/lisp/test-ob-tangle.el b/testing/lisp/test-ob-tangle.el index 4a1794ff5..74735931e 100644 --- a/testing/lisp/test-ob-tangle.el +++ b/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 -- 2.11.4.GIT