all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: Mehmet Tekman <mtekman89@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [ANN] lisp/ob-tangle-sync.el
Date: Sat, 22 Jul 2023 08:02:24 +0000	[thread overview]
Message-ID: <87o7k48jcf.fsf@localhost> (raw)
In-Reply-To: <CAHHeYzLZ7nVT8t=uzCjfWOUcXDNApWOtyc4cF9JSWdQFRhNz6w@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1689 bytes --]

Mehmet Tekman <mtekman89@gmail.com> 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?

Another meetup is on July 26. https://emacs-berlin.org/
Or we can arrange a jitsi call.

>> 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.

To name them, you can use separate ert-deftest statements.
Also, see the attached modified version of your diff - I made it so that
`should' failures immediately provide some clue about expected result
value, that can help to identify which of the should clauses fails.

> 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

The tests are indeed not passing on vanilla Org. I assume that you
tested them with your other patch applied.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-testing-lisp-test-ob.el-test-ob-merge-params-new-test-v3-Ihor.patch --]
[-- Type: text/x-patch, Size: 5575 bytes --]

diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el
index c8dbd44f4..de92cb90b 100644
--- a/testing/lisp/test-ob.el
+++ b/testing/lisp/test-ob.el
@@ -314,6 +314,147 @@ (ert-deftest test-ob/parse-header-args2 ()
     (org-babel-next-src-block)
     (should (= 14 (org-babel-execute-src-block)))))
 
+(defun test-ob/get-src-block-property (properties)
+  "Get plist of PROPERTIES and values for the first src block in buffer.
+PROPERTIES is a list of property keywords or a single keyword."
+  (org-with-wide-buffer
+   (goto-char (point-min))
+   (org-babel-next-src-block)
+   (org-set-regexps-and-options)
+   (let ((all-props (nth 2 (org-babel-get-src-block-info))))
+     (if (listp properties)
+         (apply #'nconc (mapcar (lambda (p) (list p (cdr (assoc p all-props)))) properties))
+       (list properties (cdr (assoc properties all-props)))))))
+
+(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."
+  (should ;; 1. inherit-document-header-args
+   (equal '(:tangle "/tmp/default_tangle.txt")
+          (org-test-with-temp-text
+              "\
+#+PROPERTY: header-args :tangle /tmp/default_tangle.txt
+* One
+#+begin_src conf
+#+end_src"
+            (test-ob/get-src-block-property :tangle))))
+  (should  ;; 2. inherit-document-header-with-local-sync-action
+   (equal '(:tangle "/tmp/default_tangle.txt skip")
+          (org-test-with-temp-text
+              "\
+#+PROPERTY: header-args :tangle /tmp/default_tangle.txt
+* One
+#+begin_src conf :tangle skip
+#+end_src"
+            (test-ob/get-src-block-property :tangle))))
+  (should ;; 3. override-document-header-with-local-tfile
+   (equal '(:tangle "randomfile sync")
+          (org-test-with-temp-text
+              "\
+#+PROPERTY: header-args :tangle /tmp/default_tangle.txt
+* One
+#+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-and-action
+   (equal '(:tangle "randomfile sync")
+          (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
+#+end_src"
+            (test-ob/get-src-block-property :tangle))))
+  (should ;; 5. test-tangle-and-default-results-param-together
+   (equal '(:tangle "randomfile" :results "replace")
+          (org-test-with-temp-text
+              "\
+* One
+#+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
+* One
+#+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
+   (equal '(:tangle "fname2 export")
+          (org-test-with-temp-text
+              "\
+#+PROPERTY: header-args :tangle /tmp/default_tangle.txt
+* One
+#+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
+              "\
+* One
+#+begin_src sh :results file wrap
+#+end_src"
+            (test-ob/get-src-block-property '(:results :exports)))))
+  (should-not  ;; 9. do-not-tangle-this-block --
+   (equal '(:tangle "no")
+          ;; 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
+#+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
+* One
+: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 "foo.txt")
+          (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
+#+end_src"
+            (test-ob/get-src-block-property :tangle))))
+  (should-not  ;; 12. tangle-file-with-spaces
+   ;; THIS SHOULD NOT FAIL WITH NEW MERGE FUNCTION.
+   (equal '(:tangle "file with spaces.txt")
+          (org-test-with-temp-text
+              "\
+* One
+:PROPERTIES:
+:header-args: :tangle \"foo.txt\"
+:END:
+** Two
+#+begin_src conf :tangle \"file with spaces.txt\"
+#+end_src"
+            (test-ob/get-src-block-property :tangle)))))
+
 (ert-deftest test-ob/inline-src-blocks ()
   (should
    (= 1

[-- Attachment #3: Type: text/plain, Size: 224 bytes --]


-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

  reply	other threads:[~2023-07-22  8:03 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-26 14:48 [ANN] lisp/ob-tangle-sync.el Mehmet Tekman
2023-04-26 16:43 ` John Wiegley
2023-04-26 18:43   ` Mehmet Tekman
2023-04-27  2:55 ` Ruijie Yu via General discussions about Org-mode.
2023-04-27  6:27   ` Mehmet Tekman
2023-04-28 10:57     ` Ruijie Yu via General discussions about Org-mode.
2023-04-28 11:28       ` Mehmet Tekman
2023-05-02 20:43         ` Mehmet Tekman
2023-05-03  2:31           ` Ruijie Yu via General discussions about Org-mode.
2023-05-03  7:53             ` Mehmet Tekman
2023-05-03  8:34               ` Mehmet Tekman
2023-05-03  8:44                 ` Ihor Radchenko
2023-05-03 11:43           ` Ihor Radchenko
2023-05-03 13:54             ` Mehmet Tekman
2023-05-03 18:06               ` Ihor Radchenko
2023-05-03 15:05             ` Mehmet Tekman
2023-05-03 15:21               ` Ihor Radchenko
     [not found]                 ` <87lei577g4.fsf@gmail.com>
     [not found]                   ` <87lei5v1fg.fsf@localhost>
     [not found]                     ` <87fs8duyae.fsf@localhost>
2023-05-09 14:03                       ` Mehmet Tekman
2023-05-10  9:46                         ` Ihor Radchenko
2023-05-10 11:06                           ` mtekman89
2023-05-10 11:32                             ` Ihor Radchenko
2023-05-10 16:20                               ` Mehmet Tekman
2023-05-12 12:33                                 ` Ihor Radchenko
2023-05-16 12:49                                   ` Mehmet Tekman
2023-05-16 18:57                                     ` Ihor Radchenko
2023-05-17 13:45                                       ` Mehmet Tekman
2023-05-18 10:30                                         ` Ihor Radchenko
2023-05-19  7:10                                           ` Mehmet Tekman
2023-07-15 12:38                                             ` Ihor Radchenko
2023-07-16  9:42                                               ` Mehmet Tekman
2023-07-17 11:29                                                 ` Mehmet Tekman
2023-07-18  8:47                                                   ` Ihor Radchenko
2023-07-21  8:48                                                     ` Mehmet Tekman
2023-07-22  8:02                                                       ` Ihor Radchenko [this message]
2023-07-25 11:19                                                         ` Mehmet Tekman
2023-07-25 16:19                                                           ` Ihor Radchenko
2023-07-31 13:41                                                             ` Mehmet Tekman
2023-07-31 16:38                                                               ` Ihor Radchenko
2023-07-31 20:11                                                                 ` Mehmet Tekman
2023-08-01  7:54                                                                   ` Ihor Radchenko
2023-08-01  8:49                                                                     ` Mehmet Tekman
2023-08-01  9:30                                                                       ` Ihor Radchenko
2023-08-01 18:19                                                                         ` Bastien Guerry
2023-08-02  7:29                                                                           ` Ihor Radchenko
2023-08-02 14:46                                                                   ` Mehmet Tekman
2023-08-03  6:32                                                                     ` Mehmet Tekman
2023-08-03  7:35                                                                     ` Ihor Radchenko
2023-08-03  8:08                                                                       ` Mehmet Tekman
2023-08-03  8:16                                                                         ` Ihor Radchenko
     [not found]                                                                           ` <CAHHeYzL6Z5_gGbTUrNzKDh5swgCSQiYsSj3Cs0gFy_d=eXbSBA@mail.gmail.com>
     [not found]                                                                             ` <87o7jo1q2s.fsf@localhost>
2023-08-03  8:46                                                                               ` Mehmet Tekman
2023-08-04  7:41                                                                                 ` Mehmet Tekman
2023-08-04  8:09                                                                                   ` Ihor Radchenko
2023-08-04 13:14                                                                                     ` Mehmet Tekman
2023-08-04 16:34                                                                                       ` Mehmet Tekman
2023-08-06  9:07                                                                                         ` Ihor Radchenko
2023-08-08 19:41                                                                                           ` Mehmet Tekman
2023-08-08 19:51                                                                                             ` Ihor Radchenko
2023-08-08 20:04                                                                                               ` Mehmet Tekman
2023-08-09  8:04                                                                                                 ` Ihor Radchenko
2023-08-05  8:48                                                                                       ` Ihor Radchenko
2023-08-05 22:54                                                                                         ` Mehmet Tekman
2023-11-10  9:41                                                                                           ` Ihor Radchenko
2023-11-10  9:53                                                                                             ` Mehmet Tekman
2023-12-11 13:40                                                                                               ` Ihor Radchenko
2023-12-11 14:28                                                                                                 ` Mehmet Tekman
2024-04-29  5:16                                                                                                   ` João Pedro
2024-04-29  7:43                                                                                                     ` Mehmet Tekman
2024-04-29 16:21                                                                                                       ` João Pedro
2024-05-05 16:47                                                                                                         ` Mehmet Tekman
2024-05-06  1:56                                                                                                           ` João Pedro
2024-05-06 12:53                                                                                                             ` Ihor Radchenko
2024-05-06 16:28                                                                                                             ` Mehmet Tekman
2024-05-06 12:45                                                                                                           ` Ihor Radchenko
2024-06-23 10:48                                                                                                     ` Ihor Radchenko
2024-07-23  8:47                                                                                                     ` Ihor Radchenko
2023-04-27 12:02 ` Ihor Radchenko
2023-04-27 13:01   ` Mehmet Tekman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87o7k48jcf.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=emacs-orgmode@gnu.org \
    --cc=mtekman89@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.