ob-exp: Fix export of src blocks with pathological name
[org-mode.git] / testing / lisp / test-ob-exp.el
blob982b26c8358b3085b75f745fa462b9b6bfc3d43b
1 ;;; test-ob-exp.el
3 ;; Copyright (c) 2010-2015 Eric Schulte
4 ;; Authors: Eric Schulte
6 ;; This file is not part of GNU Emacs.
8 ;; This program is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation, either version 3 of the License, or
11 ;; (at your option) any later version.
13 ;; This program is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
21 ;;; Comments:
23 ;; Template test file for Org tests
25 ;;; Code:
27 (defmacro org-test-with-expanded-babel-code (&rest body)
28 "Execute BODY while in a buffer with all Babel code evaluated.
29 Current buffer is a copy of the original buffer."
30 `(let ((string (org-with-wide-buffer (buffer-string)))
31 (narrowing (list (point-min) (point-max)))
32 (org-export-babel-evaluate t))
33 (with-temp-buffer
34 (org-mode)
35 (insert string)
36 (apply #'narrow-to-region narrowing)
37 (org-babel-exp-process-buffer)
38 (goto-char (point-min))
39 (progn ,@body))))
41 (ert-deftest test-ob-exp/org-babel-exp-src-blocks/w-no-headers ()
42 "Testing export without any headlines in the Org mode file."
43 (require 'ox-html)
44 (let ((html-file (concat (file-name-sans-extension org-test-no-heading-file)
45 ".html")))
46 (when (file-exists-p html-file) (delete-file html-file))
47 (org-test-in-example-file org-test-no-heading-file
48 ;; Export the file to HTML.
49 (org-export-to-file 'html html-file))
50 ;; should create a .html file
51 (should (file-exists-p html-file))
52 ;; should not create a file with "::" appended to its name
53 (should-not (file-exists-p (concat org-test-no-heading-file "::")))
54 (when (file-exists-p html-file) (delete-file html-file))))
56 (ert-deftest test-ob-exp/org-babel-exp-src-blocks/w-no-file ()
57 "Testing export from buffers which are not visiting any file."
58 (require 'ox-html)
59 (let ((name (generate-new-buffer-name "*Org HTML Export*")))
60 (org-test-in-example-file nil
61 (org-export-to-buffer 'html name nil nil nil t))
62 ;; Should create a HTML buffer.
63 (should (buffer-live-p (get-buffer name)))
64 ;; Should contain the content of the buffer.
65 (with-current-buffer (get-buffer name)
66 (should (string-match (regexp-quote org-test-file-ob-anchor)
67 (buffer-string))))
68 (when (get-buffer name) (kill-buffer name))))
70 (ert-deftest test-ob-exp/org-babel-exp-src-blocks/w-no-headers2 ()
71 "Testing export without any headlines in the Org file."
72 (let ((html-file (concat (file-name-sans-extension
73 org-test-link-in-heading-file)
74 ".html")))
75 (when (file-exists-p html-file) (delete-file html-file))
76 (org-test-in-example-file org-test-link-in-heading-file
77 ;; export the file to html
78 (org-export-to-file 'html html-file))
79 ;; should create a .html file
80 (should (file-exists-p html-file))
81 ;; should not create a file with "::" appended to its name
82 (should-not (file-exists-p (concat org-test-link-in-heading-file "::")))
83 (when (file-exists-p html-file) (delete-file html-file))))
85 (ert-deftest ob-exp/noweb-on-export ()
86 "Noweb header arguments export correctly.
87 - yes expand on both export and tangle
88 - no expand on neither export or tangle
89 - tangle expand on only tangle not export"
90 (should
91 (equal
92 '("(message \"expanded1\")" "(message \"expanded2\")" ";; noweb-1-yes-start
93 (message \"expanded1\")
94 (message \"expanded1\")" ";; noweb-no-start
95 <<noweb-example1>>" ";; noweb-2-yes-start
96 (message \"expanded2\")
97 (message \"expanded2\")"
98 ";; noweb-tangle-start
99 <<noweb-example1>>
100 <<noweb-example2>>")
101 (org-test-at-id "eb1f6498-5bd9-45e0-9c56-50717053e7b7"
102 (org-narrow-to-subtree)
103 (org-element-map
104 (org-test-with-expanded-babel-code (org-element-parse-buffer))
105 'src-block
106 (lambda (src) (org-trim (org-element-property :value src))))))))
108 (ert-deftest ob-exp/noweb-on-export-with-exports-results ()
109 "Noweb header arguments export correctly using :exports results.
110 - yes expand on both export and tangle
111 - no expand on neither export or tangle
112 - tangle expand on only tangle not export"
113 (should
114 (equal
115 '(";; noweb-no-start
116 <<noweb-example1>>" "<<noweb-example1>>
117 <<noweb-example2>>")
118 (org-test-at-id "8701beb4-13d9-468c-997a-8e63e8b66f8d"
119 (org-narrow-to-subtree)
120 (org-element-map
121 (org-test-with-expanded-babel-code (org-element-parse-buffer))
122 'src-block
123 (lambda (src) (org-trim (org-element-property :value src))))))))
125 (ert-deftest ob-exp/exports-both ()
126 "Test the \":exports both\" header argument.
127 The code block evaluation should create both a code block and
128 a table."
129 (org-test-at-id "92518f2a-a46a-4205-a3ab-bcce1008a4bb"
130 (org-narrow-to-subtree)
131 (let ((tree (org-test-with-expanded-babel-code (org-element-parse-buffer))))
132 (should (and (org-element-map tree 'src-block 'identity)
133 (org-element-map tree 'table 'identity))))))
135 (ert-deftest ob-exp/mixed-blocks-with-exports-both ()
136 (should
137 (equal
138 '(property-drawer plain-list src-block fixed-width src-block plain-list)
139 (org-test-at-id "5daa4d03-e3ea-46b7-b093-62c1b7632df3"
140 (org-narrow-to-subtree)
141 (mapcar 'org-element-type
142 (org-element-map
143 (org-test-with-expanded-babel-code
144 (org-element-parse-buffer 'greater-element))
145 'section 'org-element-contents nil t))))))
147 (ert-deftest ob-exp/export-with-name ()
148 (should
149 (string-match
150 "=qux="
151 (let ((org-babel-exp-code-template
152 "=%name=\n#+BEGIN_SRC %lang%flags\nbody\n#+END_SRC"))
153 (org-test-at-id "b02ddd8a-eeb8-42ab-8664-8a759e6f43d9"
154 (org-narrow-to-subtree)
155 (org-test-with-expanded-babel-code
156 (buffer-string)))))))
158 (ert-deftest ob-exp/export-with-header-argument ()
159 (let ((org-babel-exp-code-template
161 | header | value |
162 |---------+----------|
163 | foo | %foo |
164 | results | %results |
165 #+BEGIN_SRC %lang%flags\nbody\n#+END_SRC"))
166 (org-test-at-id "b02ddd8a-eeb8-42ab-8664-8a759e6f43d9"
167 (org-narrow-to-subtree)
168 (org-test-with-expanded-babel-code
169 (should (string-match "baz" (buffer-string)))
170 (should (string-match "replace" (buffer-string)))))))
172 (ert-deftest ob-exp/noweb-no-export-and-exports-both ()
173 (should
174 (string-match
175 "<<noweb-no-export-and-exports-both-1>>"
176 (org-test-at-id "8a820f6c-7980-43db-8a24-0710d33729c9"
177 (org-narrow-to-subtree)
178 (org-test-with-expanded-babel-code
179 (org-element-map (org-element-parse-buffer) 'src-block
180 (lambda (src-block) (org-element-property :value src-block))
181 nil t))))))
183 (ert-deftest ob-exp/evaluate-all-executables-in-order ()
184 (should
185 (equal '(5 4 3 2 1)
186 (let ((org-export-babel-evaluate t) *evaluation-collector*)
187 (org-test-at-id "96cc7073-97ec-4556-87cf-1f9bffafd317"
188 (org-narrow-to-subtree)
189 (buffer-string)
190 (org-test-with-expanded-babel-code *evaluation-collector*))))))
192 (ert-deftest ob-exp/exports-inline ()
193 (should
194 (string-match
195 (regexp-quote "Here is one in the middle {{{results(=1=)}}} of a line.
196 Here is one at the end of a line. {{{results(=2=)}}}
197 {{{results(=3=)}}} Here is one at the beginning of a line.")
198 (org-test-at-id "54cb8dc3-298c-4883-a933-029b3c9d4b18"
199 (org-narrow-to-subtree)
200 (let ((org-babel-inline-result-wrap "=%s="))
201 (org-test-with-expanded-babel-code (buffer-string)))))))
203 (ert-deftest ob-exp/exports-inline-code ()
204 (let ((org-babel-inline-result-wrap "=%s=")
205 (org-export-babel-evaluate t))
206 (should
207 (string-match "\\`src_emacs-lisp\\(?:\\[]\\)?{(\\+ 1 1)}$"
208 (org-test-with-temp-text
209 "src_emacs-lisp[:exports code]{(+ 1 1)}"
210 (org-babel-exp-process-buffer)
211 (buffer-string))))
212 (should
213 (string-match "\\`src_emacs-lisp\\(?:\\[]\\)?{(\\+ 1 1)}$"
214 (org-test-with-temp-text
215 "src_emacs-lisp[ :exports code ]{(+ 1 1)}"
216 (org-babel-exp-process-buffer)
217 (buffer-string))))
218 (should
219 (string-match "\\`src_emacs-lisp\\(?:\\[]\\)?{(\\+ 1 1)} {{{results(=2=)}}}$"
220 (org-test-with-temp-text
221 "src_emacs-lisp[:exports both]{(+ 1 1)}"
222 (org-babel-exp-process-buffer)
223 (buffer-string))))
224 (should
225 (string-match "\\`{{{results(=2=)}}}$"
226 (org-test-with-temp-text
227 "src_emacs-lisp[:exports results :results scalar]{(+ 1 1)}"
228 (org-babel-exp-process-buffer)
229 (buffer-string))))
230 (should
231 (let ((text "foosrc_emacs-lisp[:exports code]{(+ 1 1)}"))
232 (string-match (regexp-quote text)
233 (org-test-with-temp-text
234 text
235 (org-babel-exp-process-buffer)
236 (buffer-string)))))
237 (should
238 (let ((text "src_emacs lisp{(+ 1 1)}"))
239 (string-match (regexp-quote text)
240 (org-test-with-temp-text
241 text
242 (org-babel-exp-process-buffer)
243 (buffer-string)))))
244 (should
245 (string-match
246 (replace-regexp-in-string
247 "\\\\\\[]{" "\\(?:\\[]\\)?{" ;accept both src_sh[]{...} or src_sh{...}
248 (regexp-quote "Here is one in the middle src_sh[]{echo 1} of a line.
249 Here is one at the end of a line. src_sh[]{echo 2}
250 src_sh[]{echo 3} Here is one at the beginning of a line.
251 Here is one that is also evaluated: src_sh[]{echo 4} {{{results(=4=)}}}")
252 nil t)
253 (org-test-at-id "cd54fc88-1b6b-45b6-8511-4d8fa7fc8076"
254 (org-narrow-to-subtree)
255 (org-test-with-expanded-babel-code (buffer-string)))))))
257 (ert-deftest ob-exp/exports-inline-code-double-eval ()
258 "Based on default header arguments for inline code blocks (:exports
259 results), the resulting code block `src_emacs-lisp{2}' should also be
260 evaluated."
261 (let ((org-babel-inline-result-wrap "=%s=")
262 (org-export-babel-evaluate t))
263 (should
264 (string-match "\\`{{{results(src_emacs-lisp\\[\\]{2})}}}$"
265 (org-test-with-temp-text
266 "src_emacs-lisp[:exports results :results code]{(+ 1 1)}"
267 (org-babel-exp-process-buffer)
268 (buffer-string))))))
270 (ert-deftest ob-exp/exports-inline-code-eval-code-once ()
271 "Ibid above, except that the resulting inline code block should not
272 be evaluated."
273 (let ((org-export-babel-evaluate t))
274 (should
275 (string-match "{{{results(src_emacs-lisp\\(?:\\[[: a-zA-Z]+]\\)?{2})}}}$"
276 (org-test-with-temp-text
277 (concat "src_emacs-lisp[:exports results :results code "
278 ":results_switches \":exports code\"]{(+ 1 1)}")
279 (org-babel-exp-process-buffer)
280 (buffer-string))))))
282 (ert-deftest ob-exp/exports-inline-code-double-eval-exports-both ()
283 (let ((org-export-babel-evaluate t))
284 (should
285 (string-match (concat "\\`src_emacs-lisp\\(?:\\[]\\)?{(\\+ 1 1)} "
286 "{{{results(src_emacs-lisp\\[ :exports code\\]{2})}}}$")
287 (org-test-with-temp-text
288 (concat "src_emacs-lisp[:exports both :results code "
289 ":results_switches \":exports code\"]{(+ 1 1)}")
290 (org-babel-exp-process-buffer)
291 (buffer-string))))))
293 (ert-deftest ob-exp/export-call-line-information ()
294 (org-test-at-id "bec63a04-491e-4caa-97f5-108f3020365c"
295 (org-narrow-to-subtree)
296 (let ((org-babel-exp-call-line-template "\n: call: %line special-token"))
297 (org-test-with-expanded-babel-code
298 (should (string-match "double" (buffer-string)))
299 (should (string-match "16" (buffer-string)))
300 (should (string-match "special-token" (buffer-string)))))))
302 (ert-deftest ob-exp/noweb-strip-export-ensure-strips ()
303 (org-test-at-id "8e7bd234-99b2-4b14-8cd6-53945e409775"
304 (org-narrow-to-subtree)
305 (org-babel-next-src-block 2)
306 (should (= 110 (org-babel-execute-src-block)))
307 (let ((result (org-test-with-expanded-babel-code (buffer-string))))
308 (should-not (string-match (regexp-quote "<<strip-export-1>>") result))
309 (should-not (string-match (regexp-quote "i=\"10\"") result)))))
311 (ert-deftest ob-exp/use-case-of-reading-entry-properties ()
312 (org-test-at-id "cc5fbc20-bca5-437a-a7b8-2b4d7a03f820"
313 (org-narrow-to-subtree)
314 (let* ((case-fold-search nil)
315 (result (org-test-with-expanded-babel-code (buffer-string)))
316 (sect "a:1, b:0, c:3, d:0, e:0")
317 (sub0 "a:1, b:2, c:4, d:0, e:0")
318 (sub1 "a:1, b:2, c:5, d:0, e:6")
319 (func sub0))
320 ;; entry "section"
321 (should (string-match (concat "_shell-sect-call\n: shell " sect "\n")
322 result))
323 (should (string-match (concat "_elisp-sect-call\n: elisp " sect "\n")
324 result))
325 (should (string-match (concat "\n- sect inline shell " sect "\n")
326 result))
327 (should (string-match (concat "\n- sect inline elisp " sect "\n")
328 result))
329 ;; entry "subsection", call without arguments
330 (should (string-match (concat "_shell-sub0-call\n: shell " sub0 "\n")
331 result))
332 (should (string-match (concat "_elisp-sub0-call\n: elisp " sub0 "\n")
333 result))
334 (should (string-match (concat "\n- sub0 inline shell " sub0 "\n")
335 result))
336 (should (string-match (concat "\n- sub0 inline elisp " sub0 "\n")
337 result))
338 ;; entry "subsection", call with arguments
339 (should (string-match (concat "_shell-sub1-call\n: shell " sub1 "\n")
340 result))
341 (should (string-match (concat "_elisp-sub1-call\n: elisp " sub1 "\n")
342 result))
343 (should (string-match (concat "\n- sub1 inline shell " sub1 "\n")
344 result))
345 (should (string-match (concat "\n- sub1 inline elisp " sub1 "\n")
346 result))
347 ;; entry "function definition"
348 (should (string-match (concat "_location_shell\n: shell " func "\n")
349 result))
350 (should (string-match (concat "_location_elisp\n: elisp " func "\n")
351 result)))))
353 (ert-deftest ob-exp/export-from-a-temp-buffer ()
354 (let ((org-export-babel-evaluate t))
355 (org-test-with-temp-text
357 #+Title: exporting from a temporary buffer
359 #+name: foo
360 #+BEGIN_SRC emacs-lisp
361 :foo
362 #+END_SRC
364 #+name: bar
365 #+BEGIN_SRC emacs-lisp
366 :bar
367 #+END_SRC
369 #+BEGIN_SRC emacs-lisp :var foo=foo :noweb yes :exports results
370 (list foo <<bar>>)
371 #+END_SRC
373 (let* ((ascii (org-export-as 'ascii)))
374 (should (string-match
375 (regexp-quote " :foo :bar \n")
376 ascii))))))
378 (ert-deftest ob-export/export-with-results-before-block ()
379 "Test export when results are inserted before source block."
380 (let ((org-export-babel-evaluate t))
381 (should
382 (equal
383 "#+RESULTS: src1
386 #+NAME: src1
387 #+BEGIN_SRC emacs-lisp
388 \(+ 1 1)
389 #+END_SRC"
390 (org-test-with-temp-text
391 "#+RESULTS: src1
393 #+NAME: src1
394 #+BEGIN_SRC emacs-lisp :exports both
395 \(+ 1 1)
396 #+END_SRC"
397 (org-babel-exp-process-buffer)
398 (org-trim (org-no-properties (buffer-string))))))))
400 (ert-deftest ob-export/export-src-block-with-switches ()
401 "Test exporting a source block with switches."
402 (should
403 (string-match
404 "\\`#\\+BEGIN_SRC emacs-lisp -n -r$"
405 (org-test-with-temp-text
406 "#+BEGIN_SRC emacs-lisp -n -r\n\(+ 1 1)\n#+END_SRC"
407 (org-babel-exp-process-buffer)
408 (buffer-string)))))
410 (ert-deftest ob-export/export-src-block-with-flags ()
411 "Test exporting a source block with a flag."
412 (should
413 (string-match
414 "\\`#\\+BEGIN_SRC emacs-lisp -some-flag$"
415 (org-test-with-temp-text
416 "#+BEGIN_SRC emacs-lisp :flags -some-flag\n\(+ 1 1)\n#+END_SRC"
417 (org-babel-exp-process-buffer)
418 (buffer-string)))))
420 (ert-deftest ob-export/export-and-indentation ()
421 "Test indentation of evaluated source blocks during export."
422 ;; No indentation.
423 (should
424 (string-match
425 "^t"
426 (org-test-with-temp-text "#+BEGIN_SRC emacs-lisp\n t\n#+END_SRC"
427 (let ((indent-tabs-mode t)
428 (tab-width 1)
429 (org-src-preserve-indentation nil))
430 (org-babel-exp-process-buffer)
431 (buffer-string)))))
432 ;; Preserve indentation with "-i" flag.
433 (should
434 (string-match
435 "^ t"
436 (org-test-with-temp-text "#+BEGIN_SRC emacs-lisp -i\n t\n#+END_SRC"
437 (let ((indent-tabs-mode t)
438 (tab-width 1))
439 (org-babel-exp-process-buffer)
440 (buffer-string)))))
441 ;; Preserve indentation with a non-nil
442 ;; `org-src-preserve-indentation'.
443 (should
444 (string-match
445 "^ t"
446 (org-test-with-temp-text "#+BEGIN_SRC emacs-lisp\n t\n#+END_SRC"
447 (let ((indent-tabs-mode t)
448 (tab-width 1)
449 (org-src-preserve-indentation t))
450 (org-babel-exp-process-buffer)
451 (buffer-string))))))
453 (ert-deftest ob-export/export-under-commented-headline ()
454 "Test evaluation of code blocks under COMMENT headings."
455 (let ((org-export-babel-evaluate t)
456 (org-babel-inline-result-wrap "=%s="))
457 ;; Do not eval block in a commented headline.
458 (should
459 (string-match
460 ": 2"
461 (org-test-with-temp-text "* Headline
462 #+BEGIN_SRC emacs-lisp :exports results
463 \(+ 1 1)
464 #+END_SRC"
465 (org-babel-exp-process-buffer)
466 (buffer-string))))
467 (should-not
468 (string-match
469 ": 2"
470 (org-test-with-temp-text "* COMMENT Headline
471 #+BEGIN_SRC emacs-lisp :exports results
472 \(+ 1 1)
473 #+END_SRC"
474 (org-babel-exp-process-buffer)
475 (buffer-string))))
476 ;; Do not eval inline blocks either.
477 (should
478 (string-match
479 "=2="
480 (org-test-with-temp-text "* Headline
481 src_emacs-lisp{(+ 1 1)}"
482 (org-babel-exp-process-buffer)
483 (buffer-string))))
484 (should-not
485 (string-match
486 "=2="
487 (org-test-with-temp-text "* COMMENT Headline
488 src_emacs-lisp{(+ 1 1)}"
489 (org-babel-exp-process-buffer)
490 (buffer-string))))
491 ;; Also check parent headlines.
492 (should-not
493 (string-match
494 ": 2"
495 (org-test-with-temp-text "
496 * COMMENT Headline
497 ** Children
498 #+BEGIN_SRC emacs-lisp :exports results
499 \(+ 1 1)
500 #+END_SRC"
501 (org-babel-exp-process-buffer)
502 (buffer-string))))))
504 (ert-deftest ob-export/reference-in-post-header ()
505 "Test references in :post header during export."
506 (should
507 (org-test-with-temp-text "
508 #+NAME: foo
509 #+BEGIN_SRC emacs-lisp :exports none :var bar=\"baz\"
510 (concat \"bar\" bar)
511 #+END_SRC
513 #+NAME: nofun
514 #+BEGIN_SRC emacs-lisp :exports results :post foo(\"nofun\")
515 #+END_SRC"
516 (org-babel-exp-process-buffer) t)))
518 (ert-deftest ob-export/babel-evaluate ()
519 "Test `org-export-babel-evaluate' effect."
520 ;; When nil, no Babel code is executed.
521 (should-not
522 (string-match-p
524 (org-test-with-temp-text
525 "#+BEGIN_SRC emacs-lisp :exports results\n(+ 1 1)\n#+END_SRC"
526 (let ((org-export-babel-evaluate nil)) (org-babel-exp-process-buffer))
527 (buffer-string))))
528 (should-not
529 (string-match-p
531 (org-test-with-temp-text
532 "src_emacs-lisp{(+ 1 1)}"
533 (let ((org-export-babel-evaluate nil)) (org-babel-exp-process-buffer))
534 (buffer-string))))
535 ;; When non-nil, all Babel code types are executed.
536 (should
537 (string-match-p
539 (org-test-with-temp-text
540 "#+BEGIN_SRC emacs-lisp :exports results\n(+ 1 1)\n#+END_SRC"
541 (let ((org-export-babel-evaluate t)) (org-babel-exp-process-buffer))
542 (buffer-string))))
543 (should
544 (string-match-p
546 (org-test-with-temp-text
547 "src_emacs-lisp{(+ 1 1)}"
548 (let ((org-export-babel-evaluate t)) (org-babel-exp-process-buffer))
549 (buffer-string))))
550 ;; When set to `inline-only' limit evaluation to inline code.
551 (should-not
552 (string-match-p
554 (org-test-with-temp-text
555 "#+BEGIN_SRC emacs-lisp :exports results\n(+ 1 1)\n#+END_SRC"
556 (let ((org-export-babel-evaluate 'inline-only))
557 (org-babel-exp-process-buffer))
558 (buffer-string))))
559 (should
560 (string-match-p
562 (org-test-with-temp-text
563 "src_emacs-lisp{(+ 1 1)}"
564 (let ((org-export-babel-evaluate 'inline-only))
565 (org-babel-exp-process-buffer))
566 (buffer-string)))))
568 (ert-deftest ob-export/body-with-coderef ()
569 "Test exporting a code block with coderefs."
570 (should
571 (equal "#+BEGIN_SRC emacs-lisp\n0 (ref:foo)\n#+END_SRC"
572 (org-test-with-temp-text
573 "#+BEGIN_SRC emacs-lisp :exports code\n0 (ref:foo)\n#+END_SRC"
574 (let ((org-export-babel-evaluate t)
575 (org-coderef-label-format "(ref:foo)"))
576 (org-babel-exp-process-buffer))
577 (buffer-string))))
578 (should
579 (equal
580 "#+BEGIN_SRC emacs-lisp -l \"r:%s\"\n1 r:foo\n#+END_SRC"
581 (org-test-with-temp-text
582 "#+BEGIN_SRC emacs-lisp -l \"r:%s\" -lisp :exports code\n1 r:foo\n#+END_SRC"
583 (let ((org-export-babel-evaluate t))
584 (org-babel-exp-process-buffer))
585 (buffer-string)))))
587 (ert-deftest ob-exp/src-block-with-affiliated-keyword ()
588 "Test exporting a code block with affiliated keywords."
589 ;; Pathological case: affiliated keyword matches inline src block
590 ;; syntax.
591 (should
592 (equal "#+name: call_foo\n#+BEGIN_SRC emacs-lisp\n42\n#+END_SRC"
593 (org-test-with-temp-text
594 "#+name: call_foo\n#+BEGIN_SRC emacs-lisp\n42\n#+END_SRC"
595 (let ((org-export-use-babel t))
596 (org-babel-exp-process-buffer))
597 (buffer-string)))))
600 (provide 'test-ob-exp)
602 ;;; test-ob-exp.el ends here