From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id sPdwI9raZGRoHAAASxT56A (envelope-from ) for ; Wed, 17 May 2023 15:47:06 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id MCBLI9raZGROdAAA9RJhRA (envelope-from ) for ; Wed, 17 May 2023 15:47:06 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 070BA4519 for ; Wed, 17 May 2023 15:47:06 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzHTj-00033J-PO; Wed, 17 May 2023 09:46:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pzHTM-0002vW-Da for emacs-orgmode@gnu.org; Wed, 17 May 2023 09:45:46 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pzHTH-0006TE-Mm for emacs-orgmode@gnu.org; Wed, 17 May 2023 09:45:42 -0400 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-307a8386946so549693f8f.2 for ; Wed, 17 May 2023 06:45:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684331136; x=1686923136; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=rkxkogUSRTRvUxtKtBsZYD94or7+oX5tobv6l1/ZxBA=; b=FX/uKecaZNOJCc1+6hEnYR4JteoqxFrpPz3/zCd++mdFvcL32LPOBAI7Gk8LA3TRC2 qKOTDnXn9+QTClq/pOgNOnete9aPLINm55/pqOwVjlg8QHX30bKlnL0ImwZbXuIkVBFD K64MO4Hi5Z4Vanwqopc7YtvB1YWyxyB7Wvwfd2ZXJmkFL5zd22TEm7roNPRd4ltxAjiD pFqhBdx42sW74JzUhE5Pob34s3Rp8jYkAlK0qSQEaoJmzEWQ+foUB5TPQ7eY+nLXkY1x fI4C3CamB/FZ0kocvKyiJgKrVkyrxrWOJ6gE0Xnn9k1umj77/BfH2jnN9QiuCYBKOp6u x3Ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684331136; x=1686923136; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=rkxkogUSRTRvUxtKtBsZYD94or7+oX5tobv6l1/ZxBA=; b=GRQhj512osERcPi21y+v6hYxQJTENOp1bTdAZfkWLcx5Eszlfvqsvt4Bo+Eo2G/d/5 OK3bh9mrHkgrAPq+PCFMScaBpwqDdrpzYPDmMePIAVUBHYDPIEFiSmJiCoAURmK8NPjM PxJbjKKYixr/eSFARMA6ivTTLBc6NWtEiy3dZsfppGyLNzo+B2uh7bvQ5rDyA69cFF5B yUj9NRohr4V1mE3jX4DgCaWEeyoKtQiy1j/78mWyQtvDhQXxwQ/l8m+aV413g8xUuGnx 5Q2crMrJwnAKmVmIPo3XfxYr2JNZ5Pc9veHUVHHDJ9UQh3vRaMs0nCOO6lk0fq8iwIeH OM1g== X-Gm-Message-State: AC+VfDxdsEV+FkXEb2tUVdvwg74N3qnFyWH1WtGDRpGy01QOBiHuBLZc dPSfQZTMUkxQZG/wQV2Dhz3fu6VVSvw= X-Google-Smtp-Source: ACHHUZ68TkWWWcoW7WLwjdKkThOpGGgiUdDpbooYnIOnEiKTaR/yTpwL4ZR3S3MIBIVk7yCAgS1vlA== X-Received: by 2002:adf:f8c2:0:b0:309:31ac:6663 with SMTP id f2-20020adff8c2000000b0030931ac6663mr914433wrq.16.1684331135873; Wed, 17 May 2023 06:45:35 -0700 (PDT) Received: from hayvan (pharma2-70.w2k.pharmakol.uni-freiburg.de. [132.230.165.170]) by smtp.gmail.com with ESMTPSA id f12-20020adff8cc000000b003093a412310sm2790366wrq.92.2023.05.17.06.45.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 May 2023 06:45:35 -0700 (PDT) From: Mehmet Tekman To: Ihor Radchenko Cc: emacs-orgmode@gnu.org Subject: Re: [ANN] lisp/ob-tangle-sync.el In-Reply-To: <87leho3y0n.fsf@localhost> (Ihor Radchenko's message of "Tue, 16 May 2023 18:57:12 +0000") References: <87r0rxabd4.fsf@localhost> <87sfcd78vw.fsf@gmail.com> <87r0rxv3t5.fsf@localhost> <87lei577g4.fsf@gmail.com> <87lei5v1fg.fsf@localhost> <87fs8duyae.fsf@localhost> <8735451u20.fsf@gmail.com> <874jokbjsk.fsf@localhost> <87zg6ch2dm.fsf@gmail.com> <87sfc4a0ce.fsf@localhost> <87r0ro9mzc.fsf@gmail.com> <87zg69zq49.fsf@localhost> <87r0rg1lwe.fsf@gmail.com> <87leho3y0n.fsf@localhost> Date: Wed, 17 May 2023 15:45:33 +0200 Message-ID: <87a5y3vzpe.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=mtekman89@gmail.com; helo=mail-wr1-x42c.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Seal: i=1; s=key1; d=yhetil.org; t=1684331226; a=rsa-sha256; cv=none; b=HfMJ3WsuVoFsrIL+bd6MJQvpeKtdEQM5M1Ea3++tuUJULrSAGDzaJ16T1bCXEhG1Su2dYc YmjOe5/rushmwvgZVmxCc2HYOO4wndoUmGvYdmXf+pmqNEHLE0RWfGJDVrrlqqSQiV8iOo dshum8rXWZJUDt+9llCZhkipyGKghYmprMqN5+0kECCJ6R1b8SmcNnY5qxz/QvKUxmxf1R TqAD0gygyEDW6MiIim/PXZULW+bTX3NxW8mW1wVjdXVT00qYoD2LpRh5x3kOEAy3ZNNdX7 9APHv4RNu9i09difNKKFglk29Lg5/SwYL0dG+AN1ZOTnW7zthS44pQHE+Gws7Q== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20221208 header.b="FX/uKeca"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1684331226; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=rkxkogUSRTRvUxtKtBsZYD94or7+oX5tobv6l1/ZxBA=; b=Y1ZUvug5a9BSnY5c9bk319LD5b15QLGDFAWJiy1uRfNcXX47lEaYC4GtCS1Tg0QoXHOA9C LQAhADv0RAGa3X0p51E/0igxI7Pv8UjYm60TF3jJbvzP9Cm/1Rx/AEJfjkGBdeKoylRfxI 8Hdd6HEdFlwBiXLPHDF3SDJfx+0lpe9PRmOtv/O5NBRF185sf095l/Ug/JVBkeQEhWGVbL 3EvsASi/MyUVYI1ayNHsJq4KNne+NmG6Bo0QONlv/Tt8jbhtCR5eyFJSBxd79MkschPpO/ ZXtP/NY9nZSyyGQOkfTGsZNnlcyKD/JKIIJt/2scfXd3mkxmuntvT34/irJ9/A== X-Migadu-Spam-Score: -6.67 X-Spam-Score: -6.67 X-Migadu-Queue-Id: 070BA4519 X-Migadu-Scanner: scn0.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20221208 header.b="FX/uKeca"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-TUID: 7lOloVY53ohz --=-=-= Content-Type: text/plain Hello again, Ihor Radchenko writes: >>> I recommend trying various edge cases with your patch. >>> In particular: >>> >>> 1. Testing exclusive group inheritance when we inherit a header arg >>> value that matches :any: >>> >>> #+PROPERTIES: header-args :tangle "foo.txt" >>> #+begin_src ... :tangle no >>> >>> #+PROPERTIES: header-args :tangle no >>> #+begin_src ... :tangle "foo.txt" >>> >>> #+PROPERTIES: header-args :tangle no >>> * Heading >>> >>> :PROPERTIES: >>> :header-args: :tangle "foo.txt" >>> :END: >>> #+begin_src ... :tangle yes >> ... >>> I feel that the following code is not reliable when we inherit exact and >>> :any exclusive group members in alternations. >> >> Ah, hmm - can you give me an example here? I thought the idea was that >> an :any string would only be invokable once for a given header >> parameter. > > See the above 3 examples: (1) "foo.txt" shadowed by "no"; (2) "no" > shadowed by "foo.txt"; (3) "no" shadowed by "foo.txt" then shadowed by > "yes". > > You can also consider "foo.txt" shadowed by "bar.txt" and other > variations. I've created a small patch that contains a single ert test function that checks an example org file I made (based on the above as well as my own toy file) to try to validate the `org-babel-merge-params' rewrite. I've attached it below in case you want to test it... ...but there were a few cases where I wasn't entirely sure what the result of the merge was supposed to be: For example, a document with: > #+TITLE: Header tests > #+PROPERTY: header-args :tangle /tmp/default_tangle.txt > > * Inherit tangle header from document > > #+begin_src conf > (:tangle . /tmp/default_tangle.txt) > #+end_src I would expect the output of: (assoc :tangle (nth 2 (org-babel-get-src-block-info))) within that block to evaluate to the contents written in that block. Instead it evaluates to `(:tangle . no)' when run in a vanilla Emacs. Is this expected? Another example: > * Header args overwritten by local header > :PROPERTIES: > :header-args: :tangle "foo.txt" > :END: > #+begin_src :tangle yes > (:tangle . foo.txt) > #+end_src > > ** Inherited header > > #+begin_src :tangle "file with spaces.txt" > (:tangle . "file with spaces.txt") > #+end_src The first block correctly gives "foo.txt" under vanilla Emacs, but the second block also gives "foo.txt". Is this expected behaviour? Best, Mehmet --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0004-testing-examples-header_test.org-New-example-test-fi.patch Content-Description: test org file and associated ert test function >From 2f040db1197f835262d32e7ced857f2a47dd8ca8 Mon Sep 17 00:00:00 2001 From: MT Date: Wed, 17 May 2023 13:16:08 +0200 Subject: [PATCH 4/4] * testing/examples/header_test.org: New example test file Contains several source blocks with document, heading, block header arguments * testing/lisp/test-ob.el (test-ob/merge-params): New test function for `org-babel-merge-params' validation. This function takes a list of all the ID properties for each of the blocks in `header_test.org', along with a symbol or list of header properties to test against. The expected value is written within the block contents. --- testing/examples/header_test.org | 127 +++++++++++++++++++++++++++++++ testing/lisp/test-ob.el | 44 +++++++++++ 2 files changed, 171 insertions(+) create mode 100644 testing/examples/header_test.org diff --git a/testing/examples/header_test.org b/testing/examples/header_test.org new file mode 100644 index 000000000..9a33661be --- /dev/null +++ b/testing/examples/header_test.org @@ -0,0 +1,127 @@ +#+TITLE: Header tests +#+PROPERTY: header-args :tangle /tmp/default_tangle.txt + +The text contents in each block are tested against the output of +=(assoc (nth 2 (org-babel-get-src-block-info)))= + +Multiple header properties can be tested by separating each property +output with a **newline followed by exactly two spaces**. + +* Inherit tangle header from document +:PROPERTIES: +:ID: a41c3238-f457-4769-b10b-8d50e9d386a1 +:END: + +#+begin_src conf + (:tangle . /tmp/default_tangle.txt) +#+end_src + +* Inherit tangle header but use local sync action +:PROPERTIES: +:ID: debf7bf8-e5eb-412d-9127-57950a27c390 +:END: + +#+begin_src conf :tangle skip + (:tangle . /tmp/default_tangle.txt skip) +#+end_src + +* Use local tangle file and sync action +:PROPERTIES: +:ID: 1ca658c1-0dfd-42a5-bbe3-305582deeb00 +:END: ++ Ignore document header completely. +#+begin_src conf :tangle randomfile sync + (:tangle . randomfile sync) +#+end_src + +* Use local tangle file and sync action 2 +:PROPERTIES: +:header-args: :tangle "newfile.txt" import +:END: +** Subheading +:PROPERTIES: +:ID: 602503b8-6657-49c6-9cac-7edac396f725 +:END: ++ Ignore document header and parent header completely. +#+begin_src conf :tangle randomfile sync + (:tangle . randomfile sync) +#+end_src + + +* Test tangle and results param together +:PROPERTIES: +:ID: 4fb9938c-aec0-479f-bbc6-6b7a4228d9c2 +:END: +#+begin_src conf :tangle randomfile + (:tangle . randomfile) + (:results . replace) +#+end_src + +* Inherit the tangle file name, take the last sync action +:PROPERTIES: +:ID: 7a98b56d-e59f-426d-bd58-f93bb22cf57b +:END: ++ Ignores import +#+begin_src conf :tangle import export + (:tangle . /tmp/default_tangle.txt export) +#+end_src + +* Take the last local tangle file name and the last sync action +:PROPERTIES: +:ID: cd85e03a-1a4c-45d5-ac33-90d96999b665 +:END: ++ Ignores fname1 and sync +#+begin_src conf :tangle fname1 fname2 sync export + (:tangle . fname2 export) +#+end_src + +* Merge document results param and local results param +:PROPERTIES: +:ID: f4e4e422-029b-4ef7-b594-cd70cff2d943 +:END: + +#+begin_src sh :results file wrap + (:results . wrap file replace) + (:exports . code) +#+end_src + +* All tangle headers should be ignored (ITS FAILING HERE) +:PROPERTIES: +:ID: 9715d355-009c-4188-8b97-bcbebaeee86f +:END: + +#+begin_src conf :tangle no + (:tangle . no) +#+end_src + +* Tangle filename ignores document and heading args, inherits heading exports +:PROPERTIES: +:ID: 1a3b5565-27b5-450e-a2c5-7f95a8142f3b +: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 + +* Heading tangle parameter is not overwritten by local "yes" +:PROPERTIES: +:ID: fe54b2be-d9f1-40b4-83df-49501e69d083 +:header-args: :tangle "foo.txt" +:END: +#+begin_src :tangle yes + (:tangle . foo.txt) +#+end_src + +** Local tangle filename with spaces overwrites parent foo.txt +:PROPERTIES: +:ID: ab8af294-c586-4ec8-9f45-3c3baaeb184d +:END: ++ The expected hierarchy is =/tmp/default_tangle.txt= is supplanted by + =foo.txt= which is supplanted by =file with spaces.txt= + +#+begin_src :tangle "file with spaces.txt" + (:tangle . "file with spaces.txt") +#+end_src diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el index c8dbd44f4..e05dd083a 100644 --- a/testing/lisp/test-ob.el +++ b/testing/lisp/test-ob.el @@ -314,6 +314,50 @@ 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 +at each header. 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 '(("a41c3238-f457-4769-b10b-8d50e9d386a1" . :tangle) + ("debf7bf8-e5eb-412d-9127-57950a27c390" . :tangle) + ("1ca658c1-0dfd-42a5-bbe3-305582deeb00" . :tangle) + ("602503b8-6657-49c6-9cac-7edac396f725" . :tangle) + ("4fb9938c-aec0-479f-bbc6-6b7a4228d9c2" . (:tangle :results)) + ("7a98b56d-e59f-426d-bd58-f93bb22cf57b" . :tangle) + ("cd85e03a-1a4c-45d5-ac33-90d96999b665" . :tangle) + ("f4e4e422-029b-4ef7-b594-cd70cff2d943" . (:results :exports)) + ("9715d355-009c-4188-8b97-bcbebaeee86f" . :tangle) + ("1a3b5565-27b5-450e-a2c5-7f95a8142f3b" . (:tangle :exports :comments)) + ("fe54b2be-d9f1-40b4-83df-49501e69d083" . :tangle) + ("ab8af294-c586-4ec8-9f45-3c3baaeb184d" . :tangle))) + buffer + failed-ids) + (unwind-protect + (org-test-in-example-file (expand-file-name "header_test.org" org-test-example-dir) + (setq buffer (current-buffer)) + (dolist (testpair idtest-alist) + (let ((id (car testpair)) + (prop (cdr testpair))) + (org-test-at-id id) + (org-babel-next-src-block) + (unless (string= + (if (string= "symbol" (type-of prop)) + (format "%s" (assoc prop + (nth 2 (org-babel-get-src-block-info)))) + (mapconcat (lambda (x) (format "%s" + (assoc x + (nth 2 (org-babel-get-src-block-info))))) + prop "\n ")) ;; newline with exactly two spaces. + (string-trim (org-element-property :value (org-element-at-point)))) + (push id failed-ids)))) + (kill-buffer buffer) + (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 -- 2.40.1 --=-=-=--