First, here is a patch introducing tests concerning Org comments and
tangling.
>From c769435b9ab11f7a3b5ff5f1ec2df95ae2c6aa32 Mon Sep 17 00:00:00 2001
From: Sebastian Miele <[email protected]>
Date: Wed, 2 Oct 2019 13:02:46 +0000
Subject: [PATCH] ob-tangle: Add tests
* testing/lisp/test-ob-tangle.el (ob-tangle/commented-src-blocks):
(ob-tangle/commented-src-blocks-with-nowebref): Add tests.
---
testing/lisp/test-ob-tangle.el | 85 ++++++++++++++++++++++++++++++++++
1 file changed, 85 insertions(+)
diff --git a/testing/lisp/test-ob-tangle.el b/testing/lisp/test-ob-tangle.el
index 47c31dff5..675f0714b 100644
--- a/testing/lisp/test-ob-tangle.el
+++ b/testing/lisp/test-ob-tangle.el
@@ -296,6 +296,91 @@ another block
(org-split-string (buffer-string))))
(delete-file file))))))
+(ert-deftest ob-tangle/commented-src-blocks ()
+ "Test omission of commented src blocks."
+ (should
+ (equal '("A")
+ (let ((file (make-temp-file "org-tangle-")))
+ (unwind-protect
+ (progn
+ (org-test-with-temp-text-in-file
+ (format "#+property: header-args :tangle %S
+* A
+
+ #+BEGIN_SRC emacs-lisp
+ A
+ #+END_SRC
+
+* COMMENT B
+
+ #+BEGIN_SRC emacs-lisp
+ B
+ #+END_SRC
+
+* C
+
+ # #+BEGIN_SRC emacs-lisp
+ # C
+ # #+END_SRC
+
+* D
+
+ #+BEGIN_COMMENT
+ #+BEGIN_SRC emacs-lisp
+ D
+ #+END_SRC
+ #+END_COMMENT"
+ file)
+ (org-babel-tangle))
+ (with-temp-buffer
+ (insert-file-contents file)
+ (org-split-string (buffer-string))))
+ (delete-file file))))))
+
+(ert-deftest ob-tangle/commented-src-blocks-with-nowebref ()
+ "Test omission of commented src blocks with nowebref."
+ (should
+ (equal '("A")
+ (let ((file (make-temp-file "org-tangle-")))
+ (unwind-protect
+ (progn
+ (org-test-with-temp-text-in-file
+ (format "#+property: header-args :tangle %S
+* A
+
+ #+BEGIN_SRC elisp :noweb yes
+ A
+ <<B>>
+ <<C>>
+ <<D>>
+ #+END_SRC
+
+* COMMENT B
+
+ #+BEGIN_SRC elisp :noweb-ref B
+ B
+ #+END_SRC
+
+* C
+
+ # #+BEGIN_SRC elisp :noweb-ref C
+ # C
+ # #+END_SRC
+
+* D
+
+ #+BEGIN_COMMENT
+ #+BEGIN_SRC elisp :noweb-ref D
+ D
+ #+END_SRC
+ #+END_COMMENT"
+ file)
+ (org-babel-tangle))
+ (with-temp-buffer
+ (insert-file-contents file)
+ (org-split-string (buffer-string))))
+ (delete-file file))))))
+
(provide 'test-ob-tangle)
;;; test-ob-tangle.el ends here
--
2.23.0