Hello again!

> Ihor Radchenko <yanta...@posteo.net> writes:
>
> Two months have passed since the last message in this thread.
> Mehmet, have you had a chance to work on this? May you need any help?

General recap of where we are so far with this patch:

 The tangle-sync mode I wished to implement had some ambiguities
 when resolving `:tangle' headers. This turned out to be a
 general problem for any header that had multiple parameters, so
 the merge-params function was re-written. This introduced some
 ambiguities in itself, so we decided to write a better testing
 framework for it.

> Mehmet Tekman <mtekma...@gmail.com> writes:
>
> ... I will rewrite to to conform to the
> `org-test-with-temp-text' examples.

So I've just rewritten the `merge-params' testing function I
wrote before, this time using the `org-test-with-temp-text'
method/macro.

I seem to be getting 5 failing tests for reasons that I'm not
quite sure why. I've tested it against upstream/main, but still
getting the same errors. Maybe you can try it and see where I'm
going wrong?

The patch does not rely on any previous patches

Best,
Mehmet

On Sun, 16 Jul 2023 at 11:42, Mehmet Tekman <mtekma...@gmail.com> wrote:
>
> Apologies, this patch has been burning in the back of mind for a
> while now, but I keep getting distracted with other random side
> projects.
>
> I appreciate the wake up call, and I will refocus my efforts next
> week in my free time.
>
> Best,
> Mehmet
diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el
index c8dbd44f4..9ba2d09d3 100644
--- a/testing/lisp/test-ob.el
+++ b/testing/lisp/test-ob.el
@@ -314,6 +314,135 @@ 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 ((idtest-alist '((inherit-document-header-args
+                         :tangle "\
+#+PROPERTY: header-args :tangle /tmp/default_tangle.txt
+* One
+#+begin_src conf
+  (:tangle . /tmp/default_tangle.txt)
+#+end_src")
+                        (inherit-document-header-with-local-sync-action
+                         :tangle "\
+#+PROPERTY: header-args :tangle /tmp/default_tangle.txt
+* One
+#+begin_src conf :tangle skip
+  (:tangle . /tmp/default_tangle.txt skip)
+#+end_src")
+                        (override-document-header-with-local-tfile
+                         :tangle "\
+#+PROPERTY: header-args :tangle /tmp/default_tangle.txt
+* One
+#+begin_src conf :tangle randomfile sync
+  (:tangle . randomfile sync)
+#+end_src")
+                        (override-document-and-parent-header-with-local-tfile-and-action
+                         :tangle "\
+#+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")
+                        (test-tangle-and-default-results-param-together
+                         (:tangle :results) "\
+* One
+#+begin_src conf  :tangle randomfile
+  (:tangle . randomfile)
+  (:results . replace)
+#+end_src")
+                        (inherit-document-tfile-take-only-last-local-sync-action
+                         :tangle "\
+#+PROPERTY: header-args :tangle /tmp/default_tangle.txt
+* One
+#+begin_src conf  :tangle import export
+  (:tangle . /tmp/default_tangle.txt export)
+#+end_src")
+                        (ignore-document-header-take-last-tfile-and-sync-action
+                         :tangle "\
+#+PROPERTY: header-args :tangle /tmp/default_tangle.txt
+* One
+#+begin_src conf  :tangle fname1 fname2 sync export
+  (:tangle . fname2 export)
+#+end_src")
+                        (test-results-and-exports
+                         (:results :exports) "\
+* One
+#+begin_src sh :results file wrap
+  (:results . wrap file replace)
+  (:exports . code)
+#+end_src")
+                        (do-not-tangle-this-block
+                         :tangle "\
+#+PROPERTY: header-args :tangle /tmp/default_tangle.txt
+* One
+#+begin_src conf :tangle no
+  (:tangle . no)
+#+end_src")
+                        (test-tangle-exports-and-comments
+                         (:tangle :exports :comments) "\
+#+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")
+                        (override-document-and-heading-tfile-with-yes
+                         :tangle "\
+#+PROPERTY: header-args :tangle /tmp/default_tangle.txt
+* One
+:PROPERTIES:
+:header-args: :tangle \"foo.txt\"
+:END:
+#+begin_src :tangle yes
+   (:tangle . yes)
+#+end_src")
+                        (tangle-file-with-spaces
+                         :tangle "\
+* One
+:PROPERTIES:
+:header-args: :tangle \"foo.txt\"
+:END:
+** Two
+#+begin_src :tangle \"file with spaces.txt\"
+   (:tangle . \"file with spaces.txt\")
+#+end_src")))
+        failed-ids)
+    (dolist (testpair idtest-alist)
+      (let ((test-name (nth 0 testpair))
+            (test-prop (nth 1 testpair))
+            (test-cont (nth 2 testpair)))
+        (org-test-with-temp-text
+         test-cont
+         (org-babel-next-src-block)
+         (unless
+             (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))))
+           (push test-name failed-ids)))))
+    (if failed-ids
+        (user-error "%d Failed Blocks: %s" (length failed-ids) failed-ids))
+    (should (= 0 (length failed-ids)))))
+
+
 (ert-deftest test-ob/inline-src-blocks ()
   (should
    (= 1

Reply via email to