From 033c5ef74f54c1a83a9f3de2590700d852b9a344 Mon Sep 17 00:00:00 2001 From: Mehmet Tekman Date: Fri, 4 Aug 2023 18:17:34 +0200 Subject: [PATCH 3/3] * lisp/ob-core.el: (org-babel-common-header-args-w-values): Added mutually exclusive tangle groups relating to desired tangle sync actions * testing/lisp/test-ob.el: (test-ob/merge-params-tangle): Updated test function to take into account the new headers --- lisp/ob-core.el | 3 +- testing/lisp/test-ob.el | 133 +++++++++++++++++++++++++++++++++++++--- 2 files changed, 127 insertions(+), 9 deletions(-) diff --git a/lisp/ob-core.el b/lisp/ob-core.el index cd6c6708c..f09540f18 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -441,7 +441,8 @@ then run `org-babel-switch-to-session'." (sep . :any) (session . :any) (shebang . :any) - (tangle . ((tangle yes no :any))) + (tangle . ((tangle yes no :any) + (import export skip sync))) (tangle-mode . ((#o755 #o555 #o444 :any))) (var . :any) (wrap . :any)) diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el index 48cb60e10..60f385663 100644 --- a/testing/lisp/test-ob.el +++ b/testing/lisp/test-ob.el @@ -382,7 +382,7 @@ PROPERTIES is a list of property keywords or a single keyword." (ert-deftest test-ob/merge-params-tangle() "Test the output of merging multiple header parameters." - (should + (should ;; 1. inherit-document-header-args (equal '(:tangle "/tmp/default_tangle.txt") (org-test-with-temp-text "\ @@ -391,8 +391,8 @@ PROPERTIES is a list of property keywords or a single keyword." #+begin_src conf #+end_src" (test-ob/get-src-block-property :tangle)))) - (should ;; 2. inherit-document-header-with-local-sync-action - (equal '(:tangle "skip") + (should ;; 2. inherit-document-header + (equal '(:tangle "/tmp/default_tangle.txt skip") (org-test-with-temp-text "\ #+PROPERTY: header-args :tangle /tmp/default_tangle.txt @@ -400,7 +400,7 @@ PROPERTIES is a list of property keywords or a single keyword." #+begin_src conf :tangle skip #+end_src" (test-ob/get-src-block-property :tangle)))) - (should + (should ;; 3. override-document-header-with-local-tfile (equal '(:tangle "randomfile") (org-test-with-temp-text "\ @@ -409,7 +409,16 @@ PROPERTIES is a list of property keywords or a single keyword." #+begin_src conf :tangle randomfile #+end_src" (test-ob/get-src-block-property :tangle)))) - (should + (should ;; 3b. override-document-header-with-local-tfile-sync + (equal '(:tangle "randomfile sync") + (org-test-with-temp-text + "\ +#+PROPERTY: header-args :tangle /tmp/default_tangle.txt +* ThreeA +#+begin_src conf :tangle randomfile sync +#+end_src" + (test-ob/get-src-block-property :tangle)))) + (should ;; 4. override-document-and-parent-header-with-local-tfile (equal '(:tangle "newfile.txt") (org-test-with-temp-text "\ @@ -422,7 +431,20 @@ PROPERTIES is a list of property keywords or a single keyword." #+begin_src conf #+end_src" (test-ob/get-src-block-property :tangle)))) - (should + (should ;; 4a. override-document-and-parent-header-with-local-tfile-action + (equal '(:tangle "randomfile sync") + (org-test-with-temp-text + "\ +#+PROPERTY: header-args :tangle /tmp/default_tangle.txt +* Four +:PROPERTIES: +:header-args: :tangle \"newfile.txt\" import +:END: +** A +#+begin_src conf :tangle randomfile sync +#+end_src" + (test-ob/get-src-block-property :tangle)))) + (should ;; 5. tangle-file-name-duplicate (equal '(:tangle "./headfile.txt") (org-test-with-temp-text "\ @@ -435,7 +457,63 @@ PROPERTIES is a list of property keywords or a single keyword." #+begin_src conf #+end_src" (test-ob/get-src-block-property :tangle)))) - (should + (should ;; 5a. test-tangle-and-default-results-param-together + (equal '(:tangle "randomfile" :results "replace") + (org-test-with-temp-text + "\ +* FiveA +#+begin_src conf :tangle randomfile +#+end_src" + (test-ob/get-src-block-property '(:tangle :results))))) + (should ;; 6. inherit-document-tfile-take-only-last-local-sync-action + (equal '(:tangle "/tmp/default_tangle.txt export") + (org-test-with-temp-text + "\ +#+PROPERTY: header-args :tangle /tmp/default_tangle.txt +* Six +#+begin_src conf :tangle import export +#+end_src" + (test-ob/get-src-block-property :tangle)))) + (should ;; 7. ignore-document-header-take-last-tfile-and-sync-action + ;; This should pass with newer merge function with multiple tangle parameters + (equal '(:tangle "fname2 export") + (org-test-with-temp-text + "\ +#+PROPERTY: header-args :tangle /tmp/default_tangle.txt +* Seven +#+begin_src conf :tangle fname1 fname2 sync export +#+end_src" + (test-ob/get-src-block-property :tangle)))) + (should ;; 8. test-results-and-exports + (equal '(:results "wrap file replace" :exports "code") + (org-test-with-temp-text + "\ +* Eight +#+begin_src sh :results file wrap +#+end_src" + (test-ob/get-src-block-property '(:results :exports))))) + (should ;; 9. do-not-tangle-this-block -- + (equal '(:tangle "no") + (org-test-with-temp-text + "\ +#+PROPERTY: header-args :tangle /tmp/default_tangle.txt +* Nine +#+begin_src conf :tangle no +#+end_src" + (test-ob/get-src-block-property :tangle)))) + (should ;; 10. test-tangle-exports-and-comments + (equal '(:tangle "foo.txt" :exports "verbatim code" :comments "link") + (org-test-with-temp-text + "\ +#+PROPERTY: header-args :tangle /tmp/default_tangle.txt +* Ten +:PROPERTIES: +:header-args: :tangle no :exports verbatim +:END: +#+begin_src conf :tangle \"foo.txt\" :comments link +#+end_src" + (test-ob/get-src-block-property '(:tangle :exports :comments))))) + (should ;; 11. override-document-and-heading-tfile-with-yes (equal '(:tangle "yes") (org-test-with-temp-text "\ @@ -447,7 +525,7 @@ PROPERTIES is a list of property keywords or a single keyword." #+begin_src conf :tangle yes #+end_src" (test-ob/get-src-block-property :tangle)))) - (should + (should ;; 12. simple-file-with-space (equal '(:tangle "file with spaces.txt") (org-test-with-temp-text "\ @@ -457,9 +535,48 @@ PROPERTIES is a list of property keywords or a single keyword." :END: ** A #+begin_src conf :tangle \"file with spaces.txt\" +#+end_src" + (test-ob/get-src-block-property :tangle)))) + (should ;; 12a. simple-file-with-spaces-action + (equal '(:tangle "file with spaces.txt import") + (org-test-with-temp-text "\ +#+PROPERTY: header-args :tangle \"file with spaces.txt\" sync +* TwelveA +#+begin_src conf :tangle import +#+end_src" + (test-ob/get-src-block-property :tangle)))) + (should ;; 13. hierarchical-tangle-file-with-spaces + (equal '(:tangle "file with spaces.txt") + (org-test-with-temp-text + "\ +* Thirteen +:PROPERTIES: +:header-args: :tangle \"foo.txt\" +:END: +** A +#+begin_src conf :tangle \"file with spaces.txt\" +#+end_src" + (test-ob/get-src-block-property :tangle)))) + (should ;; 14. do-not-tangle + (equal '(:tangle "no") + (org-test-with-temp-text + "\ +#+PROPERTY: header-args :tangle /tmp/default_tangle.txt +* Fourteen +#+begin_src emacs-lisp :tangle no +#+end_src" + (test-ob/get-src-block-property :tangle)))) + (should ;; 15. headers-dont-cancel-out + (equal '(:tangle "relative.el") + (org-test-with-temp-text + "\ +#+PROPERTY: header-args :tangle relative.el +* Fifteen +#+begin_src emacs-lisp :tangle relative.el #+end_src" (test-ob/get-src-block-property :tangle))))) + (ert-deftest test-ob/inline-src-blocks () (should (= 1 -- 2.41.0