emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [patch][test] Fix and suplement pending tests in test-ob-exp.el
@ 2012-01-05 15:54 Martyn Jago
  2012-01-05 17:18 ` Bastien
  0 siblings, 1 reply; 2+ messages in thread
From: Martyn Jago @ 2012-01-05 15:54 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 111 bytes --]


Fix pending tests in test-ob-exp.el related to exporting blocks with
various header arguments.

Best, Martyn


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: tests-in-test-ob-exp.el --]
[-- Type: text/x-patch, Size: 9627 bytes --]

From e71a64c531969876e9bba0659db2308a97806e5d Mon Sep 17 00:00:00 2001
From: Martyn Jago <martyn.jago@btinternet.com>
Date: Thu, 5 Jan 2012 15:49:16 +0000
Subject: [PATCH] Fixed and suplemented pending tests in `test-ob-exp.el'.
 * testing/examples/babel.org: examples altered and added to
 * testing/lisp/test-ob-exp.el: tests fixed and added to

---
 testing/examples/babel.org  |   76 +++++++++++++++----
 testing/lisp/test-ob-exp.el |  180 ++++++++++++++++++++++++++++++++++---------
 2 files changed, 204 insertions(+), 52 deletions(-)

diff --git a/testing/examples/babel.org b/testing/examples/babel.org
index bcb7e57..6c0825f 100644
--- a/testing/examples/babel.org
+++ b/testing/examples/babel.org
@@ -7,26 +7,69 @@
   :END:
 
 #+name: noweb-example
-#+begin_src emacs-lisp
-  (message "expanded")
+#+begin_src emacs-lisp :results silent :exports code
+  (message "expanded1")
 #+end_src
 
-#+begin_src emacs-lisp :noweb yes
-  ;; noweb-yes-start
-  <<noweb-example>>
-  ;; noweb-yes-end
+#+name: noweb-example2
+#+begin_src emacs-lisp :results silent
+  (message "expanded2")
 #+end_src
 
-#+begin_src emacs-lisp :noweb no
-  ;; noweb-no-start
+#+begin_src emacs-lisp :noweb yes :results silent
+;; noweb-1-yes-start
   <<noweb-example>>
-  ;; noweb-no-end
 #+end_src
 
-#+begin_src emacs-lisp :noweb tangle
+#+begin_src emacs-lisp :noweb no  :results silent
+;; noweb-no-start
+  <<noweb-example1>>
+#+end_src
+
+#+begin_src emacs-lisp :noweb yes :results silent
+;; noweb-2-yes-start
+  <<noweb-example2>>
+#+end_src
+
+#+begin_src emacs-lisp :noweb tangle :results silent
   ;; noweb-tangle-start
+  <<noweb-example1>>
+  <<noweb-example2>>
+#+end_src
+
+* =:noweb= header argument expansion using :exports results
+  :PROPERTIES:
+  :ID:       8701beb4-13d9-468c-997a-8e63e8b66f8d
+  :END:
+
+#+name: noweb-example
+#+begin_src emacs-lisp :exports results
+  (message "expanded1")
+#+end_src
+
+#+name: noweb-example2
+#+begin_src emacs-lisp :exports results
+  (message "expanded2")
+#+end_src
+
+#+begin_src emacs-lisp :noweb yes :exports results
+;; noweb-1-yes-start
   <<noweb-example>>
-  ;; noweb-tangle-end
+#+end_src
+
+#+begin_src emacs-lisp :noweb no :exports code
+;; noweb-no-start
+  <<noweb-example1>>
+#+end_src
+
+#+begin_src emacs-lisp :noweb yes :exports results
+;; noweb-2-yes-start
+  <<noweb-example2>>
+#+end_src
+
+#+begin_src emacs-lisp :noweb tangle :exports code
+  <<noweb-example1>> 
+  <<noweb-example2>> 
 #+end_src
 
 * excessive id links on tangling
@@ -62,7 +105,7 @@
 #+name: i-have-a-name
 : 42
 
-* Pascal's Triangle -- export test
+* Pascal's Triangle -- exports both test
   :PROPERTIES:
   :ID:       92518f2a-a46a-4205-a3ab-bcce1008a4bb
   :END:
@@ -153,21 +196,24 @@ Here is one in the middle src_sh{echo 1} of a line.
 Here is one at the end of a line. src_sh{echo 2}
 src_sh{echo 3} Here is one at the beginning of a line.
 
-* conflicting blocks on export
+* mixed blocks with exports both
   :PROPERTIES:
   :ID:       5daa4d03-e3ea-46b7-b093-62c1b7632df3
   :END:
+
 #+name: a-list
 - a
 - b
 - c
 
-#+begin_src emacs-lisp :results wrap :exports both
+#+begin_src emacs-lisp :exports both
     "code block results"
 #+end_src
-#+begin_src emacs-lisp :var lst=a-list :results list
+
+#+begin_src emacs-lisp :var lst=a-list :results list :exports both
   (reverse lst)
 #+end_src
+
 * using the =:noweb-ref= header argument
   :PROPERTIES:
   :ID:       54d68d4b-1544-4745-85ab-4f03b3cbd8a0
diff --git a/testing/lisp/test-ob-exp.el b/testing/lisp/test-ob-exp.el
index b9bec99..c303c5d 100644
--- a/testing/lisp/test-ob-exp.el
+++ b/testing/lisp/test-ob-exp.el
@@ -65,44 +65,150 @@
     (should-not (file-exists-p (concat org-test-link-in-heading-file "::")))
     (when (file-exists-p html-file) (delete-file html-file))))
 
-;; TODO
-;; (ert-deftest ob-exp/noweb-on-export ()
-;;   "Noweb header arguments export correctly.
-;; - yes      expand on both export and tangle
-;; - no       expand on neither export or tangle
-;; - tangle   expand on only tangle not export"
-;;   (let (html)
-;;     (org-test-at-id "eb1f6498-5bd9-45e0-9c56-50717053e7b7"
-;;       (org-narrow-to-subtree)
-;;       (let ((arg nil)
-;; 	    )
-;; 	(mapcar (lambda (x)
-;; 		  (should (equal ""
-;; 				 (org-export-as-html nil
-;; 						     nil
-;; 						     nil
-;; 						     'string))))
-;; 		'("yes" "no" "tangle"))))))
-
-
-;; TODO Test broken (args-out-of-range 1927 3462)
-;; (ert-deftest ob-exp/exports-both ()
-;;     "Test the :exports both header argument.
-;; The code block should create both <pre></pre> and <table></table>
-;; elements in the final html."
-;;   (let (html)
-;;     (org-test-at-id "92518f2a-a46a-4205-a3ab-bcce1008a4bb"
-;;       (org-narrow-to-subtree)
-;;       (setq html (org-export-as-html nil nil nil 'string))
-;;       (should (string-match "<pre.*>[^\000]*</pre>" html))
-;;       (should (string-match "<table.*>[^\000]*</table>" html)))))
-
-;; TODO Test Broken - causes ert to go off into the weeds
-;; (ert-deftest ob-exp/export-subtree ()
-;;   (org-test-at-id "5daa4d03-e3ea-46b7-b093-62c1b7632df3"
-;;     (org-mark-subtree)
-;;     (org-export-as-latex nil)))
+(ert-deftest ob-exp/noweb-on-export ()
+  "Noweb header arguments export correctly.
+- yes      expand on both export and tangle
+- no       expand on neither export or tangle
+- tangle   expand on only tangle not export"
+  (org-test-at-id "eb1f6498-5bd9-45e0-9c56-50717053e7b7"
+    (org-narrow-to-subtree)
+    (let ((exported-html
+	   (org-export-as-html nil nil nil 'string))
+	  (test-point 0))
 
+      (org-test-with-temp-text-in-file
+	  exported-html
+
+	;; check following ouput exists and in order
+	(mapcar (lambda (x)
+		  (should (< test-point
+			     (re-search-forward
+			      x
+			      nil t)))
+		  (setq test-point (point)))
+		'("<head>" "</head>" "<body>"
+		  "<code>:noweb</code> header argument expansion"
+		  "<code>:noweb</code> header argument expansion"
+		  "message" "expanded1"
+		  "message" "expanded2"
+		  "noweb-1-yes-start"
+		  "message" "expanded1"
+		  "noweb-no-start"
+		  "&lt;&lt;noweb-example1&gt;&gt;"
+		  "noweb-2-yes-start"
+		  "message" "expanded2"
+		  "noweb-tangle-start"
+		  "&lt;&lt;noweb-example1&gt;&gt;"
+		  "&lt;&lt;noweb-example2&gt;&gt;"
+		  "</body>"))))))
+
+(ert-deftest ob-exp/noweb-on-export-with-exports-results ()
+  "Noweb header arguments export correctly using :exports results.
+- yes      expand on both export and tangle
+- no       expand on neither export or tangle
+- tangle   expand on only tangle not export"
+  (org-test-at-id "8701beb4-13d9-468c-997a-8e63e8b66f8d"
+    (org-narrow-to-subtree)
+    (let ((exported-html
+	   (org-export-as-html nil nil nil 'string))
+	  (test-point 0))
+
+      (org-test-with-temp-text-in-file
+	  exported-html
+
+	;; check following ouput exists and in order
+	(mapcar (lambda (x)
+		  (should (< test-point
+			     (re-search-forward
+			      x
+			      nil t)))
+		  (setq test-point (point)))
+		'("<head>" "</head>" "<body>"
+		  "<code>:noweb</code> header argument expansion using :exports results"
+		  "<code>:noweb</code> header argument expansion using :exports results"
+		  "expanded1"
+		  "expanded2"
+		  "expanded1"
+		  "noweb-no-start"
+		  "&lt;&lt;noweb-example1&gt;&gt;"
+		  "expanded2"
+		  "&lt;&lt;noweb-example1&gt;&gt;"
+		  "&lt;&lt;noweb-example2&gt;&gt;"
+		  "</body>"))))))
+
+(ert-deftest ob-exp/exports-both ()
+  "Test the :exports both header argument.
+The code block should create both <pre></pre> and <table></table>
+elements in the final html."
+  (org-test-at-id "92518f2a-a46a-4205-a3ab-bcce1008a4bb"
+    (org-narrow-to-subtree)
+    (let ((exported-html
+	   (org-export-as-html nil nil nil 'string))
+	  (test-point 0))
+
+      (org-test-with-temp-text-in-file
+	  exported-html
+
+	;; check following ouput exists and in order
+	(mapcar (lambda (x)
+		  (should (< test-point
+			     (re-search-forward
+			      x
+			      nil t)))
+		  (setq test-point (point)))
+		'("<head>" "</head>" "<body>"
+		   "Pascal's Triangle &ndash; exports both test"
+		   "Pascal's Triangle &ndash; exports both test"
+		   "<pre"
+		   "defun" "pascals-triangle"
+		   "if""list""list""let*""prev-triangle"
+		   "pascals-triangle""prev-row""car""reverse""prev-triangle"
+		   "append""prev-triangle""list""map""list"
+		   "append""prev-row""append""prev-row""pascals-triangle"
+		   "</pre>"
+		   "<table""<tbody>"
+		   "<tr>"">1<""</tr>"
+		   "<tr>"">1<"">1<""</tr>"
+		   "<tr>"">1<"">2<"">1<""</tr>"
+		   "<tr>"">1<"">3<"">3<"">1<""</tr>"
+		   "<tr>"">1<"">4<"">6<"">4<"">1<""</tr>"
+		   "<tr>"">1<"">5<"">10<"">10<"">5<"">1<""</tr>"
+		   "</tbody>""</table>"
+		  "</body>"))))))
+
+(ert-deftest ob-exp/mixed-blocks-with-exports-both ()
+    (org-test-at-id "5daa4d03-e3ea-46b7-b093-62c1b7632df3"
+    (org-narrow-to-subtree)
+    (let ((exported-html
+	   (org-export-as-html nil nil nil 'string))
+	  (test-point 0))
+      (org-test-with-temp-text-in-file
+	  exported-html
+
+	;; check following ouput exists and in order
+	(mapcar (lambda (x)
+		  (should (< test-point
+			     (re-search-forward
+			      x
+			      nil t)))
+		  (setq test-point (point)))
+		'("<head>" "</head>" "<body>"
+		  "mixed blocks with exports both"
+		  "mixed blocks with exports both"
+		  "<ul>"
+		  "<li>""a""</li>"
+		  "<li>""b""</li>"
+		  "<li>""c""</li>"
+		  "</ul>"
+		  "<pre"
+		  "\"code block results\""
+		  "</pre>"
+		  "<pre class=\"example\">"
+		  "code block results"
+		  "</pre>"
+		  "</body>"))))))
+      
 (provide 'test-ob-exp)
 
 ;;; test-ob-exp.el ends here
+
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [patch][test] Fix and suplement pending tests in test-ob-exp.el
  2012-01-05 15:54 [patch][test] Fix and suplement pending tests in test-ob-exp.el Martyn Jago
@ 2012-01-05 17:18 ` Bastien
  0 siblings, 0 replies; 2+ messages in thread
From: Bastien @ 2012-01-05 17:18 UTC (permalink / raw)
  To: Martyn Jago; +Cc: emacs-orgmode

Hi Martyn,

Martyn Jago <martyn.jago@btinternet.com> writes:

> Fix pending tests in test-ob-exp.el related to exporting blocks with
> various header arguments.

Applied, thanks.

Ps: I removed some trailing whitespaces afterward... I use this:

(add-hook 
  'emacs-lisp-mode-hook
  (lambda() (setq show-trailing-whitespace t)))

-- 
 Bastien

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-01-05 17:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-05 15:54 [patch][test] Fix and suplement pending tests in test-ob-exp.el Martyn Jago
2012-01-05 17:18 ` Bastien

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).