summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Ecay <aaronecay@gmail.com>2015-01-22 00:59:04 -0500
committerAaron Ecay <aaronecay@gmail.com>2015-01-22 01:52:49 -0500
commitfda70440f49292197d76ce4c2727dbf426bc65f3 (patch)
tree32799e62c33ed53c445586715a9b090b35e289cd
parentcaad78ca8a15d5dce4c2f58f11c8b51966a2f42d (diff)
downloadorg-mode-fda70440f49292197d76ce4c2727dbf426bc65f3.tar.gz
test: Fixes for running tests interactively.
* testing/examples/babel.org: Change spaces to dashes in #+name lines. * testing/lisp/test-ob-exp.el (org-test-with-expanded-babel-code): (ob-exp/evaluate-all-executables-in-order): (ob-exp/exports-inline-code): (ob-exp/exports-inline): (ob-exp/exports-inline-code-double-eval): (ob-exp/exports-inline-code-eval-code-once): (ob-exp/exports-inline-code-double-eval-exports-both): (ob-exp/use-case-of-reading-entry-properties): (ob-exp/export-from-a-temp-buffer): (ob-export/export-with-results-before-block): (ob-export/export-under-commented-headline): * testing/lisp/test-ob-lob.el (test-ob-lob/export-lob-lines): * testing/lisp/test-ob.el (test-org-babel/inline-src_blk-default-results-replace-line-1): (test-org-babel/inline-src_blk-default-results-replace-line-2): (test-org-babel/inline-src_blk-manual-results-replace): (test-org-babel/inline-src_blk-results-scalar): (test-org-babel/inline-src_blk-results-verbatim): (test-org-babel/inline-src_blk-preceded-punct-preceded-by-point): * testing/lisp/test-ox.el (test-org-export/export-scope): Bind ‘org-babel-inline-result-wrap’ and/or ‘org-export-babel-evaluate’ so tests work when users have customized these variables. * testing/lisp/test-ob-exp.el (ob-export/export-with-results-before-block): Add ‘org-trim’ where an extra newline was creeping in. * testing/lisp/test-ob-lob.el (test-ob-lob/call-with-header-arguments): Neutralize org-babel-insert-result, which was stomping on the buffer contents and disrupting the test * testing/lisp/test-org-element.el (test-org-element/block-switches): Replace (should (and ...)) with multiple (should ...). This gives more precise indications of what is wrong when a test fails. (test-org-element/link-parser): Require org-docview. * testing/lisp/test-org-timer.el (test-org-timer/other-timer-error): Add the error type for ‘should-error’. * testing/lisp/test-ox.el (test-org-export/set-title): (test-org-export/handle-options): (test-org-export/with-timestamps): (test-org-export/comment-tree): (test-org-export/handle-inlinetasks): Let ‘org-export-filter-body-functions’ and ‘org-export-filter-final-output-functions’ to nil where an empty string is the expected result. ‘org-export-filter-apply-functions’ treats an empty string as special, and changes it to nil. This creates test failures when the user has customized these variables. * testing/org-test.el (org-test-with-temp-text): Let ‘org-mode-hook’ to nil. (org-test-table-target-expect): Require ert since this function calls some of its should* functions.
-rw-r--r--testing/examples/babel.org12
-rw-r--r--testing/lisp/test-ob-exp.el256
-rw-r--r--testing/lisp/test-ob-lob.el106
-rw-r--r--testing/lisp/test-ob.el26
-rw-r--r--testing/lisp/test-org-element.el91
-rw-r--r--testing/lisp/test-org-timer.el6
-rw-r--r--testing/lisp/test-ox.el137
-rw-r--r--testing/org-test.el4
8 files changed, 347 insertions, 291 deletions
diff --git a/testing/examples/babel.org b/testing/examples/babel.org
index 8bae65b..1f9ce3d 100644
--- a/testing/examples/babel.org
+++ b/testing/examples/babel.org
@@ -400,10 +400,10 @@ the optional argument of the caller.
Note: Just export of a property can be done with a macro: {{{property(a)}}}.
-#+NAME: src_block_location_shell sect call
+#+NAME: src_block_location_shell-sect-call
#+CALL: src_block_location_shell()
-#+NAME: src_block_location_elisp sect call
+#+NAME: src_block_location_elisp-sect-call
#+CALL: src_block_location_elisp()
- sect inline call_src_block_location_shell()
@@ -415,19 +415,19 @@ Note: Just export of a property can be done with a macro: {{{property(a)}}}.
:c: 4
:END:
-#+NAME: src_block_location_shell sub0 call
+#+NAME: src_block_location_shell-sub0-call
#+CALL: src_block_location_shell()
-#+NAME: src_block_location_elisp sub0 call
+#+NAME: src_block_location_elisp-sub0-call
#+CALL: src_block_location_elisp()
- sub0 inline call_src_block_location_shell()
- sub0 inline call_src_block_location_elisp()
-#+NAME: src_block_location_shell sub1 call
+#+NAME: src_block_location_shell-sub1-call
#+CALL: src_block_location_shell(c=5, e=6)
-#+NAME: src_block_location_elisp sub1 call
+#+NAME: src_block_location_elisp-sub1-call
#+CALL: src_block_location_elisp(c=5, e=6)
- sub1 inline call_src_block_location_shell(c=5, e=6)
diff --git a/testing/lisp/test-ob-exp.el b/testing/lisp/test-ob-exp.el
index 4669c55..9a586f2 100644
--- a/testing/lisp/test-ob-exp.el
+++ b/testing/lisp/test-ob-exp.el
@@ -28,7 +28,8 @@
"Execute BODY while in a buffer with all Babel code evaluated.
Current buffer is a copy of the original buffer."
`(let ((string (buffer-string))
- (buf (current-buffer)))
+ (buf (current-buffer))
+ (org-export-babel-evaluate t))
(with-temp-buffer
(org-mode)
(insert string)
@@ -180,11 +181,10 @@ a table."
(ert-deftest ob-exp/evaluate-all-executables-in-order ()
(should
(equal '(5 4 3 2 1)
- (let (*evaluation-collector*)
+ (let ((org-export-babel-evaluate t) *evaluation-collector*)
(org-test-at-id "96cc7073-97ec-4556-87cf-1f9bffafd317"
(org-narrow-to-subtree)
(buffer-string)
- (fboundp 'org-export-execute-babel-code)
(org-test-with-expanded-babel-code *evaluation-collector*))))))
(ert-deftest ob-exp/exports-inline ()
@@ -195,91 +195,98 @@ Here is one at the end of a line. =2=
=3= Here is one at the beginning of a line.")
(org-test-at-id "54cb8dc3-298c-4883-a933-029b3c9d4b18"
(org-narrow-to-subtree)
- (org-test-with-expanded-babel-code (buffer-string))))))
+ (let ((org-babel-inline-result-wrap "=%s="))
+ (org-test-with-expanded-babel-code (buffer-string)))))))
(ert-deftest ob-exp/exports-inline-code ()
- (should
- (string-match "\\`src_emacs-lisp\\(?:\\[]\\)?{(\\+ 1 1)}$"
- (org-test-with-temp-text
- "src_emacs-lisp[:exports code]{(+ 1 1)}"
- (org-export-execute-babel-code)
- (buffer-string))))
- (should
- (string-match "\\`src_emacs-lisp\\(?:\\[]\\)?{(\\+ 1 1)}$"
- (org-test-with-temp-text
- "src_emacs-lisp[ :exports code ]{(+ 1 1)}"
- (org-export-execute-babel-code)
- (buffer-string))))
- (should
- (string-match "\\`src_emacs-lisp\\(?:\\[]\\)?{(\\+ 1 1)} =2=$"
- (org-test-with-temp-text
- "src_emacs-lisp[:exports both]{(+ 1 1)}"
- (org-export-execute-babel-code)
- (buffer-string))))
- (should
- (string-match "\\`=2=$"
- (org-test-with-temp-text
- "src_emacs-lisp[:exports results :results scalar]{(+ 1 1)}"
- (org-export-execute-babel-code)
- (buffer-string))))
- (should
- (let ((text "foosrc_emacs-lisp[:exports code]{(+ 1 1)}"))
- (string-match (regexp-quote text)
+ (let ((org-babel-inline-result-wrap "=%s=")
+ (org-export-babel-evaluate t))
+ (should
+ (string-match "\\`src_emacs-lisp\\(?:\\[]\\)?{(\\+ 1 1)}$"
(org-test-with-temp-text
- text
- (org-export-execute-babel-code)
- (buffer-string)))))
- (should
- (let ((text "src_emacs lisp{(+ 1 1)}"))
- (string-match (regexp-quote text)
+ "src_emacs-lisp[:exports code]{(+ 1 1)}"
+ (org-export-execute-babel-code)
+ (buffer-string))))
+ (should
+ (string-match "\\`src_emacs-lisp\\(?:\\[]\\)?{(\\+ 1 1)}$"
(org-test-with-temp-text
- text
- (org-export-execute-babel-code)
- (buffer-string)))))
- (should
- (string-match
- (replace-regexp-in-string
- "\\\\\\[]{" "\\(?:\\[]\\)?{" ;accept both src_sh[]{...} or src_sh{...}
- (regexp-quote "Here is one in the middle src_sh[]{echo 1} of a line.
+ "src_emacs-lisp[ :exports code ]{(+ 1 1)}"
+ (org-export-execute-babel-code)
+ (buffer-string))))
+ (should
+ (string-match "\\`src_emacs-lisp\\(?:\\[]\\)?{(\\+ 1 1)} =2=$"
+ (org-test-with-temp-text
+ "src_emacs-lisp[:exports both]{(+ 1 1)}"
+ (org-export-execute-babel-code)
+ (buffer-string))))
+ (should
+ (string-match "\\`=2=$"
+ (org-test-with-temp-text
+ "src_emacs-lisp[:exports results :results scalar]{(+ 1 1)}"
+ (org-export-execute-babel-code)
+ (buffer-string))))
+ (should
+ (let ((text "foosrc_emacs-lisp[:exports code]{(+ 1 1)}"))
+ (string-match (regexp-quote text)
+ (org-test-with-temp-text
+ text
+ (org-export-execute-babel-code)
+ (buffer-string)))))
+ (should
+ (let ((text "src_emacs lisp{(+ 1 1)}"))
+ (string-match (regexp-quote text)
+ (org-test-with-temp-text
+ text
+ (org-export-execute-babel-code)
+ (buffer-string)))))
+ (should
+ (string-match
+ (replace-regexp-in-string
+ "\\\\\\[]{" "\\(?:\\[]\\)?{" ;accept both src_sh[]{...} or src_sh{...}
+ (regexp-quote "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.
Here is one that is also evaluated: src_sh[]{echo 4} =4=")
- nil t)
- (org-test-at-id "cd54fc88-1b6b-45b6-8511-4d8fa7fc8076"
- (org-narrow-to-subtree)
- (org-test-with-expanded-babel-code (buffer-string))))))
+ nil t)
+ (org-test-at-id "cd54fc88-1b6b-45b6-8511-4d8fa7fc8076"
+ (org-narrow-to-subtree)
+ (org-test-with-expanded-babel-code (buffer-string)))))))
(ert-deftest ob-exp/exports-inline-code-double-eval ()
"Based on default header arguments for inline code blocks (:exports
results), the resulting code block `src_emacs-lisp{2}' should also be
evaluated."
- (should
- (string-match "\\`=2=$"
- (org-test-with-temp-text
- "src_emacs-lisp[:exports results :results code]{(+ 1 1)}"
- (org-export-execute-babel-code)
- (buffer-string)))))
+ (let ((org-babel-inline-result-wrap "=%s=")
+ (org-export-babel-evaluate t))
+ (should
+ (string-match "\\`=2=$"
+ (org-test-with-temp-text
+ "src_emacs-lisp[:exports results :results code]{(+ 1 1)}"
+ (org-export-execute-babel-code)
+ (buffer-string))))))
(ert-deftest ob-exp/exports-inline-code-eval-code-once ()
"Ibid above, except that the resulting inline code block should not
be evaluated."
- (should
- (string-match "\\`src_emacs-lisp\\(?:\\[]\\)?{2}$"
- (org-test-with-temp-text
- (concat "src_emacs-lisp[:exports results :results code "
- ":results_switches \":exports code\"]{(+ 1 1)}")
- (org-export-execute-babel-code)
- (buffer-string)))))
+ (let ((org-export-babel-evaluate t))
+ (should
+ (string-match "\\`src_emacs-lisp\\(?:\\[]\\)?{2}$"
+ (org-test-with-temp-text
+ (concat "src_emacs-lisp[:exports results :results code "
+ ":results_switches \":exports code\"]{(+ 1 1)}")
+ (org-export-execute-babel-code)
+ (buffer-string))))))
(ert-deftest ob-exp/exports-inline-code-double-eval-exports-both ()
- (should
- (string-match (concat "\\`src_emacs-lisp\\(?:\\[]\\)?{(\\+ 1 1)} "
- "src_emacs-lisp\\(?:\\[]\\)?{2}$")
- (org-test-with-temp-text
- (concat "src_emacs-lisp[:exports both :results code "
- ":results_switches \":exports code\"]{(+ 1 1)}")
- (org-export-execute-babel-code)
- (buffer-string)))))
+ (let ((org-export-babel-evaluate t))
+ (should
+ (string-match (concat "\\`src_emacs-lisp\\(?:\\[]\\)?{(\\+ 1 1)} "
+ "src_emacs-lisp\\(?:\\[]\\)?{2}$")
+ (org-test-with-temp-text
+ (concat "src_emacs-lisp[:exports both :results code "
+ ":results_switches \":exports code\"]{(+ 1 1)}")
+ (org-export-execute-babel-code)
+ (buffer-string))))))
(ert-deftest ob-exp/export-call-line-information ()
(org-test-at-id "bec63a04-491e-4caa-97f5-108f3020365c"
@@ -303,33 +310,34 @@ be evaluated."
(org-test-at-id "cc5fbc20-bca5-437a-a7b8-2b4d7a03f820"
(org-narrow-to-subtree)
(let* ((case-fold-search nil)
+ (org-babel-inline-result-wrap "=%s=")
(result (org-test-with-expanded-babel-code (buffer-string)))
(sect "a:1, b:0, c:3, d:0, e:0")
(sub0 "a:1, b:2, c:4, d:0, e:0")
(sub1 "a:1, b:2, c:5, d:0, e:6")
(func sub0))
;; entry "section"
- (should (string-match (concat "_shell sect call\n: shell " sect "\n")
+ (should (string-match (concat "_shell-sect-call\n: shell " sect "\n")
result))
- (should (string-match (concat "_elisp sect call\n: elisp " sect "\n")
+ (should (string-match (concat "_elisp-sect-call\n: elisp " sect "\n")
result))
(should (string-match (concat "\n- sect inline =shell " sect "=\n")
result))
(should (string-match (concat "\n- sect inline =elisp " sect "=\n")
result))
;; entry "subsection", call without arguments
- (should (string-match (concat "_shell sub0 call\n: shell " sub0 "\n")
+ (should (string-match (concat "_shell-sub0-call\n: shell " sub0 "\n")
result))
- (should (string-match (concat "_elisp sub0 call\n: elisp " sub0 "\n")
+ (should (string-match (concat "_elisp-sub0-call\n: elisp " sub0 "\n")
result))
(should (string-match (concat "\n- sub0 inline =shell " sub0 "=\n")
result))
(should (string-match (concat "\n- sub0 inline =elisp " sub0 "=\n")
result))
;; entry "subsection", call with arguments
- (should (string-match (concat "_shell sub1 call\n: shell " sub1 "\n")
+ (should (string-match (concat "_shell-sub1-call\n: shell " sub1 "\n")
result))
- (should (string-match (concat "_elisp sub1 call\n: elisp " sub1 "\n")
+ (should (string-match (concat "_elisp-sub1-call\n: elisp " sub1 "\n")
result))
(should (string-match (concat "\n- sub1 inline =shell " sub1 "=\n")
result))
@@ -342,8 +350,9 @@ be evaluated."
result)))))
(ert-deftest ob-exp/export-from-a-temp-buffer ()
- (org-test-with-temp-text
- "
+ (let ((org-export-babel-evaluate t))
+ (org-test-with-temp-text
+ "
#+Title: exporting from a temporary buffer
#+name: foo
@@ -360,31 +369,32 @@ be evaluated."
(list foo <<bar>>)
#+END_SRC
"
- (let* ((ascii (org-export-as 'ascii)))
- (should (string-match
- (regexp-quote " :foo :bar \n")
- ascii)))))
+ (let* ((ascii (org-export-as 'ascii)))
+ (should (string-match
+ (regexp-quote " :foo :bar \n")
+ ascii))))))
(ert-deftest ob-export/export-with-results-before-block ()
"Test export when results are inserted before source block."
- (should
- (equal
- "#+RESULTS: src1
+ (let ((org-export-babel-evaluate t))
+ (should
+ (equal
+ "#+RESULTS: src1
: 2
#+NAME: src1
#+BEGIN_SRC emacs-lisp
\(+ 1 1)
#+END_SRC"
- (org-test-with-temp-text
- "#+RESULTS: src1
+ (org-test-with-temp-text
+ "#+RESULTS: src1
#+NAME: src1
#+BEGIN_SRC emacs-lisp :exports both
\(+ 1 1)
#+END_SRC"
- (org-export-execute-babel-code)
- (buffer-string)))))
+ (org-export-execute-babel-code)
+ (org-trim (org-no-properties (buffer-string))))))))
(ert-deftest ob-export/export-src-block-with-switches ()
"Test exporting a source block with switches."
@@ -441,52 +451,54 @@ be evaluated."
(ert-deftest ob-export/export-under-commented-headline ()
"Test evaluation of code blocks under COMMENT headings."
- ;; Do not eval block in a commented headline.
- (should
- (string-match
- ": 2"
- (org-test-with-temp-text "* Headline
+ (let ((org-export-babel-evaluate t)
+ (org-babel-inline-result-wrap "=%s="))
+ ;; Do not eval block in a commented headline.
+ (should
+ (string-match
+ ": 2"
+ (org-test-with-temp-text "* Headline
#+BEGIN_SRC emacs-lisp :exports results
\(+ 1 1)
#+END_SRC"
- (org-export-execute-babel-code)
- (buffer-string))))
- (should-not
- (string-match
- ": 2"
- (org-test-with-temp-text "* COMMENT Headline
+ (org-export-execute-babel-code)
+ (buffer-string))))
+ (should-not
+ (string-match
+ ": 2"
+ (org-test-with-temp-text "* COMMENT Headline
#+BEGIN_SRC emacs-lisp :exports results
\(+ 1 1)
#+END_SRC"
- (org-export-execute-babel-code)
- (buffer-string))))
- ;; Do not eval inline blocks either.
- (should
- (string-match
- "=2="
- (org-test-with-temp-text "* Headline
+ (org-export-execute-babel-code)
+ (buffer-string))))
+ ;; Do not eval inline blocks either.
+ (should
+ (string-match
+ "=2="
+ (org-test-with-temp-text "* Headline
src_emacs-lisp{(+ 1 1)}"
- (org-export-execute-babel-code)
- (buffer-string))))
- (should-not
- (string-match
- "=2="
- (org-test-with-temp-text "* COMMENT Headline
+ (org-export-execute-babel-code)
+ (buffer-string))))
+ (should-not
+ (string-match
+ "=2="
+ (org-test-with-temp-text "* COMMENT Headline
src_emacs-lisp{(+ 1 1)}"
- (org-export-execute-babel-code)
- (buffer-string))))
- ;; Also check parent headlines.
- (should-not
- (string-match
- ": 2"
- (org-test-with-temp-text "
+ (org-export-execute-babel-code)
+ (buffer-string))))
+ ;; Also check parent headlines.
+ (should-not
+ (string-match
+ ": 2"
+ (org-test-with-temp-text "
* COMMENT Headline
** Children
#+BEGIN_SRC emacs-lisp :exports results
\(+ 1 1)
#+END_SRC"
- (org-export-execute-babel-code)
- (buffer-string)))))
+ (org-export-execute-babel-code)
+ (buffer-string))))))
(ert-deftest ob-export/reference-in-post-header ()
"Test references in :post header during export."
diff --git a/testing/lisp/test-ob-lob.el b/testing/lisp/test-ob-lob.el
index b85022b..89650aa 100644
--- a/testing/lisp/test-ob-lob.el
+++ b/testing/lisp/test-ob-lob.el
@@ -39,60 +39,64 @@
(ert-deftest test-ob-lob/call-with-header-arguments ()
"Test the evaluation of a library of babel #+call: line."
- (org-test-at-id "fab7e291-fde6-45fc-bf6e-a485b8bca2f0"
- (move-beginning-of-line 1)
- (forward-line 6)
- (message (buffer-substring (point-at-bol) (point-at-eol)))
- (should (string= "testing" (org-babel-lob-execute
- (org-babel-lob-get-info))))
- (forward-line 1)
- (should (string= "testing" (caar (org-babel-lob-execute
- (org-babel-lob-get-info)))))
- (forward-line 1)
- (should (string= "testing" (org-babel-lob-execute
- (org-babel-lob-get-info))))
- (forward-line 1)
- (should (string= "testing" (caar (org-babel-lob-execute
- (org-babel-lob-get-info)))))
- (forward-line 1)
- (should (string= "testing" (org-babel-lob-execute
- (org-babel-lob-get-info))))
- (forward-line 1)
- (should (string= "testing" (caar (org-babel-lob-execute
- (org-babel-lob-get-info)))))
- (forward-line 1) (beginning-of-line) (forward-char 27)
- (should (string= "testing" (org-babel-lob-execute
- (org-babel-lob-get-info))))
- (forward-line 1) (beginning-of-line) (forward-char 27)
- (should (string= "testing" (caar (org-babel-lob-execute
- (org-babel-lob-get-info)))))
- (forward-line 1) (beginning-of-line)
- (should (= 4 (org-babel-lob-execute (org-babel-lob-get-info))))
- (forward-line 1)
- (should (string= "testing" (org-babel-lob-execute
- (org-babel-lob-get-info))))
- (forward-line 1)
- (should (string= "123" (org-babel-lob-execute (org-babel-lob-get-info))))))
+ (cl-letf (((symbol-function 'org-babel-insert-result)
+ (symbol-function 'ignore)))
+ (org-test-at-id "fab7e291-fde6-45fc-bf6e-a485b8bca2f0"
+ (move-beginning-of-line 1)
+ (forward-line 6)
+ (message (buffer-substring (point-at-bol) (point-at-eol)))
+ (should (string= "testing" (org-babel-lob-execute
+ (org-babel-lob-get-info))))
+ (forward-line 1)
+ (should (string= "testing" (caar (org-babel-lob-execute
+ (org-babel-lob-get-info)))))
+ (forward-line 1)
+ (should (string= "testing" (org-babel-lob-execute
+ (org-babel-lob-get-info))))
+ (forward-line 1)
+ (should (string= "testing" (caar (org-babel-lob-execute
+ (org-babel-lob-get-info)))))
+ (forward-line 1)
+ (should (string= "testing" (org-babel-lob-execute
+ (org-babel-lob-get-info))))
+ (forward-line 1)
+ (should (string= "testing" (caar (org-babel-lob-execute
+ (org-babel-lob-get-info)))))
+ (forward-line 1) (beginning-of-line) (forward-char 27)
+ (should (string= "testing" (org-babel-lob-execute
+ (org-babel-lob-get-info))))
+ (forward-line 1) (beginning-of-line) (forward-char 27)
+ (should (string= "testing" (caar (org-babel-lob-execute
+ (org-babel-lob-get-info)))))
+ (forward-line 1) (beginning-of-line)
+ (should (= 4 (org-babel-lob-execute (org-babel-lob-get-info))))
+ (forward-line 1)
+ (should (string= "testing" (org-babel-lob-execute
+ (org-babel-lob-get-info))))
+ (forward-line 1)
+ (should (string= "123" (org-babel-lob-execute (org-babel-lob-get-info)))))))
(ert-deftest test-ob-lob/export-lob-lines ()
"Test the export of a variety of library babel call lines."
- (org-test-at-id "72ddeed3-2d17-4c7f-8192-a575d535d3fc"
- (org-narrow-to-subtree)
- (let ((buf (current-buffer))
- (string (buffer-string)))
- (with-temp-buffer
- (org-mode)
- (insert string)
- (org-babel-exp-process-buffer buf)
- (message (buffer-string))
- (goto-char (point-min))
- (should (re-search-forward "^: 0" nil t))
- (should (re-search-forward "call =2= stuck" nil t))
- (should (re-search-forward
- "exported =call_double(it=2)= because" nil t))
- (should (re-search-forward "^=6= because" nil t))
- (should (re-search-forward "results 8 should" nil t))
- (should (re-search-forward "following 2\\*5==10= should" nil t))))))
+ (let ((org-babel-inline-result-wrap "=%s=")
+ (org-export-babel-evaluate t))
+ (org-test-at-id "72ddeed3-2d17-4c7f-8192-a575d535d3fc"
+ (org-narrow-to-subtree)
+ (let ((buf (current-buffer))
+ (string (buffer-string)))
+ (with-temp-buffer
+ (org-mode)
+ (insert string)
+ (org-babel-exp-process-buffer buf)
+ (message (buffer-string))
+ (goto-char (point-min))
+ (should (re-search-forward "^: 0" nil t))
+ (should (re-search-forward "call =2= stuck" nil t))
+ (should (re-search-forward
+ "exported =call_double(it=2)= because" nil t))
+ (should (re-search-forward "^=6= because" nil t))
+ (should (re-search-forward "results 8 should" nil t))
+ (should (re-search-forward "following 2\\*5==10= should" nil t)))))))
(ert-deftest test-ob-lob/do-not-eval-lob-lines-in-example-blocks-on-export ()
(require 'ox)
diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el
index ce28435..989c201 100644
--- a/testing/lisp/test-ob.el
+++ b/testing/lisp/test-ob.el
@@ -269,7 +269,7 @@ this is simple"
(ert-deftest test-org-babel/org-babel-get-inline-src-block-matches ()
(flet ((test-at-id (id)
- (org-test-at-id
+ (org-test-at-id
id
(let ((test-point (point)))
(should (fboundp 'org-babel-get-inline-src-block-matches))
@@ -294,7 +294,8 @@ this is simple"
(test-at-id "d55dada7-de0e-4340-8061-787cccbedee5")))
(ert-deftest test-org-babel/inline-src_blk-default-results-replace-line-1 ()
- (let ((test-line "src_sh{echo 1}"))
+ (let ((test-line "src_sh{echo 1}")
+ (org-babel-inline-result-wrap "=%s="))
;; src_ at bol line 1...
(org-test-with-temp-text
test-line
@@ -331,7 +332,8 @@ this is simple"
(ert-deftest test-org-babel/inline-src_blk-default-results-replace-line-2 ()
;; src_ at bol line 2...
- (let ((test-line " src_emacs-lisp{ \"x\" }"))
+ (let ((test-line " src_emacs-lisp{ \"x\" }")
+ (org-babel-inline-result-wrap "=%s="))
(org-test-with-temp-text
(concat "\n" test-line)
(should-error (org-ctrl-c-ctrl-c))
@@ -345,7 +347,8 @@ this is simple"
(buffer-substring-no-properties
(point-at-bol) (point-at-eol))))))
- (let ((test-line "Some text prior to block src_emacs-lisp{ \"y\" }"))
+ (let ((test-line "Some text prior to block src_emacs-lisp{ \"y\" }")
+ (org-babel-inline-result-wrap "=%s="))
(org-test-with-temp-text
test-line
(goto-char (point-max))
@@ -362,7 +365,8 @@ this is simple"
(should-error (org-ctrl-c-ctrl-c)))))
(ert-deftest test-org-babel/inline-src_blk-manual-results-replace ()
- (let ((test-line " src_emacs-lisp[:results replace]{ \"x\" }"))
+ (let ((test-line " src_emacs-lisp[:results replace]{ \"x\" }")
+ (org-babel-inline-result-wrap "=%s="))
(org-test-with-temp-text
(concat "\n" test-line)
(should-error (org-ctrl-c-ctrl-c))
@@ -377,7 +381,8 @@ this is simple"
(point-at-bol) (point-at-eol))))))
(let ((test-line (concat " Some text prior to block "
- "src_emacs-lisp[:results replace]{ \"y\" }")))
+ "src_emacs-lisp[:results replace]{ \"y\" }"))
+ (org-babel-inline-result-wrap "=%s="))
(org-test-with-temp-text test-line
(goto-char (point-max))
(insert (concat "\n" test-line " end"))
@@ -448,7 +453,8 @@ this is simple"
(point-min) (point-max)))))))
(ert-deftest test-org-babel/inline-src_blk-results-scalar ()
- (let ((test-line "src_emacs-lisp[ :results scalar ]{ \"x\" }"))
+ (let ((test-line "src_emacs-lisp[ :results scalar ]{ \"x\" }")
+ (org-babel-inline-result-wrap "=%s="))
(org-test-with-temp-text
test-line
(org-ctrl-c-ctrl-c)
@@ -457,7 +463,8 @@ this is simple"
(point-min) (point-max)))))))
(ert-deftest test-org-babel/inline-src_blk-results-verbatim ()
- (let ((test-line "src_emacs-lisp[ :results verbatim ]{ \"x\" }"))
+ (let ((test-line "src_emacs-lisp[ :results verbatim ]{ \"x\" }")
+ (org-babel-inline-result-wrap "=%s="))
(org-test-with-temp-text
test-line
(org-ctrl-c-ctrl-c)
@@ -845,7 +852,8 @@ trying to find the :END: marker."
* next heading"))
(ert-deftest test-org-babel/inline-src_blk-preceded-punct-preceded-by-point ()
- (let ((test-line ".src_emacs-lisp[ :results verbatim ]{ \"x\" }"))
+ (let ((test-line ".src_emacs-lisp[ :results verbatim ]{ \"x\" }")
+ (org-babel-inline-result-wrap "=%s="))
(org-test-with-temp-text
test-line
(forward-char 1)
diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el
index b9aafa1..97e88e6 100644
--- a/testing/lisp/test-org-element.el
+++ b/testing/lisp/test-org-element.el
@@ -677,33 +677,29 @@ Some other text
(org-element-property :preserve-indent (org-element-at-point))))
;; 2. "-n -r -k" combination should number lines, retain labels but
;; not use them in coderefs.
- (should
- (org-test-with-temp-text "#+BEGIN_EXAMPLE -n -r -k\nText.\n#+END_EXAMPLE"
- (let ((element (org-element-at-point)))
- (and (org-element-property :number-lines element)
- (org-element-property :retain-labels element)
- (not (org-element-property :use-labels element))))))
- (should
- (org-test-with-temp-text
- "#+BEGIN_SRC emacs-lisp -n -r -k\n(+ 1 1)\n#+END_SRC"
- (let ((element (org-element-at-point)))
- (and (org-element-property :number-lines element)
- (org-element-property :retain-labels element)
- (not (org-element-property :use-labels element))))))
+ (org-test-with-temp-text "#+BEGIN_EXAMPLE -n -r -k\nText.\n#+END_EXAMPLE"
+ (let ((element (org-element-at-point)))
+ (should (org-element-property :number-lines element))
+ (should (org-element-property :retain-labels element))
+ (should-not (org-element-property :use-labels element))))
+ (org-test-with-temp-text
+ "#+BEGIN_SRC emacs-lisp -n -r -k\n(+ 1 1)\n#+END_SRC"
+ (let ((element (org-element-at-point)))
+ (should (org-element-property :number-lines element))
+ (should (org-element-property :retain-labels element))
+ (should-not (org-element-property :use-labels element))))
;; 3. "-n -r" combination should number-lines remove labels and not
;; use them in coderefs.
- (should
- (org-test-with-temp-text "#+BEGIN_EXAMPLE -n -r\nText.\n#+END_EXAMPLE"
- (let ((element (org-element-at-point)))
- (and (org-element-property :number-lines element)
- (not (org-element-property :retain-labels element))
- (not (org-element-property :use-labels element))))))
- (should
- (org-test-with-temp-text "#+BEGIN_SRC emacs-lisp -n -r\n(+ 1 1)\n#+END_SRC"
- (let ((element (org-element-at-point)))
- (and (org-element-property :number-lines element)
- (not (org-element-property :retain-labels element))
- (not (org-element-property :use-labels element))))))
+ (org-test-with-temp-text "#+BEGIN_EXAMPLE -n -r\nText.\n#+END_EXAMPLE"
+ (let ((element (org-element-at-point)))
+ (should (org-element-property :number-lines element))
+ (should-not (org-element-property :retain-labels element))
+ (should-not (org-element-property :use-labels element))))
+ (org-test-with-temp-text "#+BEGIN_SRC emacs-lisp -n -r\n(+ 1 1)\n#+END_SRC"
+ (let ((element (org-element-at-point)))
+ (should (org-element-property :number-lines element))
+ (should-not (org-element-property :retain-labels element))
+ (should-not (org-element-property :use-labels element))))
;; 4. "-n" or "+n" should number lines, retain labels and use them
;; in coderefs.
(should
@@ -732,32 +728,28 @@ Some other text
(org-element-property :use-labels element)))))
;; 5. No switch should not number lines, but retain labels and use
;; them in coderefs.
- (should
- (org-test-with-temp-text "#+BEGIN_EXAMPLE\nText.\n#+END_EXAMPLE"
- (let ((element (org-element-at-point)))
- (and (not (org-element-property :number-lines element))
- (org-element-property :retain-labels element)
- (org-element-property :use-labels element)))))
- (should
- (org-test-with-temp-text "#+BEGIN_SRC emacs-lisp\n(+ 1 1)\n#+END_SRC"
- (let ((element (org-element-at-point)))
- (and (not (org-element-property :number-lines element))
- (org-element-property :retain-labels element)
- (org-element-property :use-labels element)))))
+ (org-test-with-temp-text "#+BEGIN_EXAMPLE\nText.\n#+END_EXAMPLE"
+ (let ((element (org-element-at-point)))
+ (should (not (org-element-property :number-lines element)))
+ (should (org-element-property :retain-labels element))
+ (should (org-element-property :use-labels element))))
+ (org-test-with-temp-text "#+BEGIN_SRC emacs-lisp\n(+ 1 1)\n#+END_SRC"
+ (let ((element (org-element-at-point)))
+ (should (not (org-element-property :number-lines element)))
+ (should (org-element-property :retain-labels element))
+ (should (org-element-property :use-labels element))))
;; 6. "-r" switch only: do not number lines, remove labels, and
;; don't use labels in coderefs.
- (should
- (org-test-with-temp-text "#+BEGIN_EXAMPLE -r\nText.\n#+END_EXAMPLE"
- (let ((element (org-element-at-point)))
- (and (not (org-element-property :number-lines element))
- (not (org-element-property :retain-labels element))
- (not (org-element-property :use-labels element))))))
- (should
- (org-test-with-temp-text "#+BEGIN_SRC emacs-lisp -r\n(+ 1 1)\n#+END_SRC"
- (let ((element (org-element-at-point)))
- (and (not (org-element-property :number-lines element))
- (not (org-element-property :retain-labels element))
- (not (org-element-property :use-labels element))))))
+ (org-test-with-temp-text "#+BEGIN_EXAMPLE -r\nText.\n#+END_EXAMPLE"
+ (let ((element (org-element-at-point)))
+ (should (not (org-element-property :number-lines element)))
+ (should (not (org-element-property :retain-labels element)))
+ (should (not (org-element-property :use-labels element)))))
+ (org-test-with-temp-text "#+BEGIN_SRC emacs-lisp -r\n(+ 1 1)\n#+END_SRC"
+ (let ((element (org-element-at-point)))
+ (should (not (org-element-property :number-lines element)))
+ (should (not (org-element-property :retain-labels element)))
+ (should (not (org-element-property :use-labels element)))))
;; 7. Recognize coderefs with user-defined syntax.
(should
(equal
@@ -1500,6 +1492,7 @@ e^{i\\pi}+1=0
(org-element-property :path l)
(org-element-property :search-option l)))))))
;; ... file-type link with application...
+ (require 'org-docview)
(should
(equal
'("file" "projects.org" "docview")
diff --git a/testing/lisp/test-org-timer.el b/testing/lisp/test-org-timer.el
index db0b258..cfa9071 100644
--- a/testing/lisp/test-org-timer.el
+++ b/testing/lisp/test-org-timer.el
@@ -262,12 +262,14 @@ Also, mute output from `message'."
(should-error
(test-org-timer/with-temp-text ""
(org-timer-start)
- (org-timer-set-timer 10)))
+ (org-timer-set-timer 10))
+ :type 'user-error)
;; Countdown timer is running.
(should-error
(test-org-timer/with-temp-text ""
(org-timer-set-timer 10)
- (org-timer-start))))
+ (org-timer-start))
+ :type 'user-error))
(provide 'test-org-timer)
;;; test-org-timer.el end here
diff --git a/testing/lisp/test-ox.el b/testing/lisp/test-ox.el
index 2098ebc..7b05d6e 100644
--- a/testing/lisp/test-ox.el
+++ b/testing/lisp/test-ox.el
@@ -274,24 +274,28 @@ Paragraph"
(should
(equal
""
- (org-test-with-temp-text "Test"
- (org-export-as
- (org-export-create-backend
- :transcoders
- '((template . (lambda (text info)
- (org-element-interpret-data
- (plist-get info :title))))))))))
+ (let (org-export-filter-body-functions
+ org-export-filter-final-output-functions)
+ (org-test-with-temp-text "Test"
+ (org-export-as
+ (org-export-create-backend
+ :transcoders
+ '((template . (lambda (text info)
+ (org-element-interpret-data
+ (plist-get info :title)))))))))))
;; With a blank TITLE keyword.
(should
(equal
""
- (org-test-with-temp-text "#+TITLE:\nTest"
- (org-export-as
- (org-export-create-backend
- :transcoders
- '((template . (lambda (text info)
- (org-element-interpret-data
- (plist-get info :title))))))))))
+ (let (org-export-filter-body-functions
+ org-export-filter-final-output-functions)
+ (org-test-with-temp-text "#+TITLE:\nTest"
+ (org-export-as
+ (org-export-create-backend
+ :transcoders
+ '((template . (lambda (text info)
+ (org-element-interpret-data
+ (plist-get info :title)))))))))))
;; With a non-empty TITLE keyword.
(should
(equal
@@ -336,9 +340,11 @@ Paragraph"
;; Test exclude tags for headlines and inlinetasks.
(should
(equal ""
- (org-test-with-temp-text "* Head1 :noexp:"
- (org-export-as (org-test-default-backend)
- nil nil nil '(:exclude-tags ("noexp"))))))
+ (let (org-export-filter-body-functions
+ org-export-filter-final-output-functions)
+ (org-test-with-temp-text "* Head1 :noexp:"
+ (org-export-as (org-test-default-backend)
+ nil nil nil '(:exclude-tags ("noexp")))))))
;; Test include tags for headlines and inlinetasks.
(should
(equal "* H2\n** Sub :exp:\n*** Sub Sub\n"
@@ -375,7 +381,9 @@ Paragraph"
;; Ignore tasks.
(should
(equal ""
- (let ((org-todo-keywords '((sequence "TODO" "DONE"))))
+ (let ((org-todo-keywords '((sequence "TODO" "DONE")))
+ org-export-filter-body-functions
+ org-export-filter-final-output-functions)
(org-test-with-temp-text "* TODO Head1"
(org-export-as (org-test-default-backend)
nil nil nil '(:with-tasks nil))))))
@@ -388,10 +396,12 @@ Paragraph"
;; Archived tree.
(should
(equal ""
- (org-test-with-temp-text "* Head1 :archive:"
- (let ((org-archive-tag "archive"))
- (org-export-as (org-test-default-backend)
- nil nil nil '(:with-archived-trees nil))))))
+ (let (org-export-filter-body-functions
+ org-export-filter-final-output-functions)
+ (org-test-with-temp-text "* Head1 :archive:"
+ (let ((org-archive-tag "archive"))
+ (org-export-as (org-test-default-backend)
+ nil nil nil '(:with-archived-trees nil)))))))
(should
(string-match
"\\* Head1[ \t]+:archive:"
@@ -414,15 +424,19 @@ Paragraph"
nil nil nil '(:with-clocks t)))))
(should
(equal ""
- (org-test-with-temp-text "CLOCK: [2012-04-29 sun. 10:45]"
- (org-export-as (org-test-default-backend)
- nil nil nil '(:with-clocks nil)))))
+ (let (org-export-filter-body-functions
+ org-export-filter-final-output-functions)
+ (org-test-with-temp-text "CLOCK: [2012-04-29 sun. 10:45]"
+ (org-export-as (org-test-default-backend)
+ nil nil nil '(:with-clocks nil))))))
;; Drawers.
(should
(equal ""
- (org-test-with-temp-text ":TEST:\ncontents\n:END:"
- (org-export-as (org-test-default-backend)
- nil nil nil '(:with-drawers nil)))))
+ (let (org-export-filter-body-functions
+ org-export-filter-final-output-functions)
+ (org-test-with-temp-text ":TEST:\ncontents\n:END:"
+ (org-export-as (org-test-default-backend)
+ nil nil nil '(:with-drawers nil))))))
(should
(equal ":TEST:\ncontents\n:END:\n"
(org-test-with-temp-text ":TEST:\ncontents\n:END:"
@@ -446,9 +460,11 @@ Paragraph"
'(:with-fixed-width t)))))
(should
(equal ""
- (org-test-with-temp-text ": A"
- (org-export-as (org-test-default-backend) nil nil nil
- '(:with-fixed-width nil)))))
+ (let (org-export-filter-body-functions
+ org-export-filter-final-output-functions)
+ (org-test-with-temp-text ": A"
+ (org-export-as (org-test-default-backend) nil nil nil
+ '(:with-fixed-width nil))))))
;; Footnotes.
(should
(equal "Footnote?"
@@ -467,14 +483,18 @@ Paragraph"
(should
(equal
""
- (let ((org-inlinetask-min-level 15))
+ (let ((org-inlinetask-min-level 15)
+ org-export-filter-body-functions
+ org-export-filter-final-output-functions)
(org-test-with-temp-text "*************** Task"
(org-export-as (org-test-default-backend)
nil nil nil '(:with-inlinetasks nil))))))
(should
(equal
""
- (let ((org-inlinetask-min-level 15))
+ (let ((org-inlinetask-min-level 15)
+ org-export-filter-body-functions
+ org-export-filter-final-output-functions)
(org-test-with-temp-text
"*************** Task\nContents\n*************** END"
(org-export-as (org-test-default-backend)
@@ -515,9 +535,12 @@ Paragraph"
;; Statistics cookies.
(should
(equal ""
- (org-test-with-temp-text "[0/0]"
- (org-export-as (org-test-default-backend)
- nil nil nil '(:with-statistics-cookies nil)))))
+ (let (org-export-filter-body-functions
+ org-export-filter-final-output-functions)
+ (org-trim
+ (org-test-with-temp-text "[0/0]"
+ (org-export-as (org-test-default-backend)
+ nil nil nil '(:with-statistics-cookies nil)))))))
;; Tables.
(should
(equal "| A |\n"
@@ -526,9 +549,11 @@ Paragraph"
'(:with-tables t)))))
(should
(equal ""
- (org-test-with-temp-text "| A |"
- (org-export-as (org-test-default-backend) nil nil nil
- '(:with-tables nil))))))
+ (let (org-export-filter-body-functions
+ org-export-filter-final-output-functions)
+ (org-test-with-temp-text "| A |"
+ (org-export-as (org-test-default-backend) nil nil nil
+ '(:with-tables nil)))))))
(ert-deftest test-org-export/with-timestamps ()
"Test `org-export-with-timestamps' specifications."
@@ -543,9 +568,12 @@ Paragraph"
(should
(equal
""
- (org-test-with-temp-text "[2012-04-29 sun. 10:45]<2012-04-29 sun. 10:45>"
- (org-export-as (org-test-default-backend)
- nil nil nil '(:with-timestamps nil)))))
+ (let (org-export-filter-body-functions
+ org-export-filter-final-output-functions)
+ (org-trim
+ (org-test-with-temp-text "[2012-04-29 sun. 10:45]<2012-04-29 sun. 10:45>"
+ (org-export-as (org-test-default-backend)
+ nil nil nil '(:with-timestamps nil)))))))
;; `active' value.
(should
(string-match
@@ -571,8 +599,10 @@ Paragraph <2012-03-29 Thu>[2012-03-29 Thu]"
"Test if export process ignores commented trees."
(should
(equal ""
- (org-test-with-temp-text "* COMMENT Head1"
- (org-export-as (org-test-default-backend))))))
+ (let (org-export-filter-body-functions
+ org-export-filter-final-output-functions)
+ (org-test-with-temp-text "* COMMENT Head1"
+ (org-export-as (org-test-default-backend)))))))
(ert-deftest test-org-export/uninterpreted ()
"Test handling of uninterpreted elements."
@@ -735,9 +765,10 @@ text
(goto-char (point-at-eol))
(should (equal (org-export-as (org-test-default-backend)) "text\n")))
;; Subtree with a code block calling another block outside.
- (should
- (equal ": 3\n"
- (org-test-with-temp-text "
+ (let ((org-export-babel-evaluate t))
+ (should
+ (equal ": 3\n"
+ (org-test-with-temp-text "
* Head1
#+BEGIN_SRC emacs-lisp :noweb yes :exports results
<<test>>
@@ -747,8 +778,8 @@ text
#+BEGIN_SRC emacs-lisp
\(+ 1 2)
#+END_SRC"
- (forward-line 1)
- (org-export-as (org-test-default-backend) 'subtree))))
+ (forward-line 1)
+ (org-export-as (org-test-default-backend) 'subtree)))))
;; Body only.
(let ((backend (org-test-default-backend)))
(setf (org-export-backend-transcoders backend)
@@ -1940,7 +1971,9 @@ Paragraph[fn:1]"
(should
(equal
""
- (let ((org-inlinetask-min-level 3))
+ (let ((org-inlinetask-min-level 3)
+ org-export-filter-body-functions
+ org-export-filter-final-output-functions)
(org-test-with-temp-text "*** Inlinetask :noexp:\nContents\n*** end"
(org-export-as (org-test-default-backend)
nil nil nil '(:exclude-tags ("noexp")))))))
@@ -1957,7 +1990,9 @@ Paragraph[fn:1]"
(should
(equal ""
(let ((org-todo-keywords '((sequence "TODO" "DONE")))
- (org-inlinetask-min-level 3))
+ (org-inlinetask-min-level 3)
+ org-export-filter-body-functions
+ org-export-filter-final-output-functions)
(org-test-with-temp-text "*** TODO Inline"
(org-export-as (org-test-default-backend)
nil nil nil '(:with-tasks nil))))))))
diff --git a/testing/org-test.el b/testing/org-test.el
index bcd0002..992f17f 100644
--- a/testing/org-test.el
+++ b/testing/org-test.el
@@ -205,7 +205,8 @@ mode holding TEXT. If the string \"<point>\" appears in TEXT
then remove it and place the point there before running BODY,
otherwise place the point at the beginning of the inserted text."
(declare (indent 1))
- `(let ((inside-text (if (stringp ,text) ,text (eval ,text))))
+ `(let ((inside-text (if (stringp ,text) ,text (eval ,text)))
+ (org-mode-hook nil))
(with-temp-buffer
(org-mode)
(let ((point (string-match "<point>" inside-text)))
@@ -254,6 +255,7 @@ or temporarily substitute the `org-test-with-temp-text' of this
function with `org-test-with-temp-text-in-file'. Also consider
setting `pp-escape-newlines' to nil manually."
(require 'pp)
+ (require 'ert)
(let ((back pp-escape-newlines) (current-tblfm))
(unless tblfm
(should-not laps)