Hello > Ihor Radchenko <yanta...@posteo.net> writes: > > P.S. There going to be Emacs meetup this Saturday, July 22 > (https://emacs-apac.gitlab.io/announcements/july-2023/). I plan to be > there and, if you need it, we can try to resolve difficulties in more > interactive way.
I am currently travelling this weekend, otherwise I happily would attend so that this patch could speed forward. Next month maybe? > This is failing because of subtlety in > `org-test-with-temp-text' that inserts text after activating > org-mode. PROPERTY lines are only computed when org-mode is > activated, unless you explicitly call > `org-set-regexps-and-options' to refresh them. Okay, it's working as intended now. > This fails because you did not provide LANG for source block. > override-document-and-heading-tfile-with-yes test is also > missing LANG. Thanks, I thought I fixed this last time you mentioned it but apparently only in my mind... > Side note: You are re-implementing the already available ERT > features for failed test reporting. Instead of controlling > which tests failed manually, you should better follow the > example of all other tests and simply use a sequence of > `should'/`should-not' forms. Okay, I've re-written this to conform to the `should' macros. I *really* wish these macros could be named so that I could debug failing statements better, but for now numbering them in the comments and using the `l' binding works well enough for debugging. I have two tests that I've set to "should-not" pass for now, but once the correct merging behaviour has been implemented, I believe that I will change them to "should" pass statements: - 9. do-not-tangle-this-block - 12. tangle-file-with-spaces Attached is the new diff (travelling makes it hard to write meaningful commit messages so I did not use git-format-patch), which should be used against the upstream/main. Looking forward to further feedback! Best, Mehmet
diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el index c8dbd44f4..2b9326865 100644 --- a/testing/lisp/test-ob.el +++ b/testing/lisp/test-ob.el @@ -314,6 +314,151 @@ this is simple" (org-babel-next-src-block) (should (= 14 (org-babel-execute-src-block))))) + +(ert-deftest test-ob/merge-params () + "Test the output of merging multiple header parameters. The +expected output is given in the contents of the source code block +in each test. The desired test header parameters are given +either as a symbol or a list in the `idtest-alist' variable. +Multiple header parameters must be separated by a newline and +exactly two spaces in the block contents." + (let ((test-the-result + (lambda (test-prop) + (org-babel-next-src-block) + (org-set-regexps-and-options) + (string= + (if (string= "symbol" (type-of test-prop)) + (format "%s" (assoc test-prop (nth 2 (org-babel-get-src-block-info)))) + (mapconcat + (lambda (x) (format "%s" (assoc x (nth 2 (org-babel-get-src-block-info))))) + test-prop "\n ")) ;; newline with exactly two spaces. + (string-trim (org-element-property :value (org-element-at-point))))))) + (should ;; 1. inherit-document-header-args + (org-test-with-temp-text + "\ +#+PROPERTY: header-args :tangle /tmp/default_tangle.txt +* One +#+begin_src conf + (:tangle . /tmp/default_tangle.txt) +#+end_src" + (funcall test-the-result :tangle))) + (should ;; 2. inherit-document-header-with-local-sync-action + (org-test-with-temp-text + "\ +#+PROPERTY: header-args :tangle /tmp/default_tangle.txt +* One +#+begin_src conf :tangle skip + (:tangle . /tmp/default_tangle.txt skip) +#+end_src" + (funcall test-the-result :tangle))) + (should ;; 3. override-document-header-with-local-tfile + (org-test-with-temp-text + "\ +#+PROPERTY: header-args :tangle /tmp/default_tangle.txt +* One +#+begin_src conf :tangle randomfile sync + (:tangle . randomfile sync) +#+end_src" + (funcall test-the-result :tangle))) + (should ;; 4. override-document-and-parent-header-with-local-tfile-and-action + (org-test-with-temp-text + "\ +#+PROPERTY: header-args :tangle /tmp/default_tangle.txt +* One +:PROPERTIES: +:header-args: :tangle \"newfile.txt\" import +:END: +** Two +#+begin_src conf :tangle randomfile sync + (:tangle . randomfile sync) +#+end_src" + (funcall test-the-result :tangle))) + (should ;; 5. test-tangle-and-default-results-param-together + (org-test-with-temp-text + "\ +* One +#+begin_src conf :tangle randomfile + (:tangle . randomfile) + (:results . replace) +#+end_src" + (funcall test-the-result '(:tangle :results)))) + (should ;; 6. inherit-document-tfile-take-only-last-local-sync-action + (org-test-with-temp-text + "\ +#+PROPERTY: header-args :tangle /tmp/default_tangle.txt +* One +#+begin_src conf :tangle import export + (:tangle . /tmp/default_tangle.txt export) +#+end_src" + (funcall test-the-result :tangle))) + (should ;; 7. ignore-document-header-take-last-tfile-and-sync-action + (org-test-with-temp-text + "\ +#+PROPERTY: header-args :tangle /tmp/default_tangle.txt +* One +#+begin_src conf :tangle fname1 fname2 sync export + (:tangle . fname2 export) +#+end_src" + (funcall test-the-result :tangle))) + (should ;; 8. test-results-and-exports + (org-test-with-temp-text + "\ +* One +#+begin_src sh :results file wrap + (:results . wrap file replace) + (:exports . code) +#+end_src" + (funcall test-the-result '(:results :exports)))) + (should-not ;; 9. do-not-tangle-this-block -- + ;; THIS SHOULD NOT FAIL WITH NEW MERGE FUNCTION. + (org-test-with-temp-text + "\ +#+PROPERTY: header-args :tangle /tmp/default_tangle.txt +* One +#+begin_src conf :tangle no + (:tangle . no) +#+end_src" + (funcall test-the-result :tangle))) + (should ;; 10. test-tangle-exports-and-comments + (org-test-with-temp-text + "\ +#+PROPERTY: header-args :tangle /tmp/default_tangle.txt +* One +:PROPERTIES: +:header-args: :tangle no :exports verbatim +:END: +#+begin_src conf :tangle \"foo.txt\" :comments link + (:tangle . foo.txt) + (:exports . verbatim code) + (:comments . link) +#+end_src" + (funcall test-the-result '(:tangle :exports :comments)))) + (should ;; 11. override-document-and-heading-tfile-with-yes + (org-test-with-temp-text + "\ +#+PROPERTY: header-args :tangle /tmp/default_tangle.txt +* One +:PROPERTIES: +:header-args: :tangle \"foo.txt\" +:END: +#+begin_src conf :tangle yes + (:tangle . foo.txt) +#+end_src" + (funcall test-the-result :tangle))) + (should-not ;; 12. tangle-file-with-spaces + ;; THIS SHOULD NOT FAIL WITH NEW MERGE FUNCTION. + (org-test-with-temp-text + "\ +* One +:PROPERTIES: +:header-args: :tangle \"foo.txt\" +:END: +** Two +#+begin_src conf :tangle \"file with spaces.txt\" + (:tangle . \"file with spaces.txt\") +#+end_src" + (funcall test-the-result :tangle))))) + (ert-deftest test-ob/inline-src-blocks () (should (= 1