Browse Source

ob-core: Test that org-confirm-babel-evaluate does not see coderefs

* testing/lisp/test-ob.el (test-ob/check-eval-noweb-expanded): Add
test.

With df5a83637 (ob-core: Call org-confirm-babel-evaluate with expanded
noweb refs, 2020-08-02), org-confirm-babel-evaluate gets called with
an expanded body and coderefs.  As of the last commit, the coderefs
are stripped.

Cf: https://orgmode.org/list/CA+G3_PPYS2KAaXiBDeujTTpswCTzTuJRQsXwaji1MuRoc8N7vw@mail.gmail.com
Kyle Meyer 4 years ago
parent
commit
f24c3d11cc
1 changed files with 20 additions and 0 deletions
  1. 20 0
      testing/lisp/test-ob.el

+ 20 - 0
testing/lisp/test-ob.el

@@ -1863,6 +1863,26 @@ default-directory
 	    (let ((org-confirm-babel-evaluate
 		   (lambda (_ body)
 		     (not (string-match-p ":bar" body)))))
+	      (org-babel-check-confirm-evaluate
+	       (org-babel-get-src-block-info))))))
+  ;; The code block passed to `org-confirm-babel-evaluate' does not
+  ;; include coderefs.
+  (should
+   (equal t
+	  (org-test-with-temp-text "
+#+name: foo
+#+begin_src emacs-lisp
+  :bar
+#+end_src
+
+<point>#+begin_src emacs-lisp :noweb yes
+  #(ref:foo)
+  <<foo>>
+#+end_src"
+	    (let ((org-coderef-label-format "#(ref:%s)")
+		  (org-confirm-babel-evaluate
+		   (lambda (_ body)
+		     (string-match-p "ref:foo" body))))
 	      (org-babel-check-confirm-evaluate
 	       (org-babel-get-src-block-info)))))))