From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id kAMUMFkV1V41LwAA0tVLHw (envelope-from ) for ; Mon, 01 Jun 2020 14:48:57 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id IF8ELFkV1V4wdAAAB5/wlQ (envelope-from ) for ; Mon, 01 Jun 2020 14:48:57 +0000 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 9634A9400EF for ; Mon, 1 Jun 2020 14:48:56 +0000 (UTC) Received: from localhost ([::1]:51394 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jflkD-000303-Un for larch@yhetil.org; Mon, 01 Jun 2020 10:48:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40570) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jfljh-0002zV-5m for emacs-orgmode@gnu.org; Mon, 01 Jun 2020 10:48:21 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]:36759) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jfljf-00076C-Aj; Mon, 01 Jun 2020 10:48:20 -0400 Received: by mail-wr1-x42b.google.com with SMTP id q11so134715wrp.3; Mon, 01 Jun 2020 07:48:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=USX0ftpomUxyk11osoKZM8PajWEiG+eCpcu5WNYs5sE=; b=VAWh2VkLWehTbDPRsfliI4At67mPExSz9pFThSGr4C1NXohjDH1RUAPENl1GNqti8Z 3q/zMjvwTj7IWxYHkH8Iqp8oQ6wBxRd5vLY9ANlTpX+R1Q9ssS/8lY0GP7PeiwlKWAWI RZgRMlqsjgNnTX/uVT3Mgr+1IpvUocDUvWIvVKWZ4hR5mnADDW2tJhbRXXFzJTaY9RRx WqUqh4fu+G1AVfDGyAjEso7bcNZ517csjSuBk96Hog8xAxVilk5o9s/VAm3WQ+YmEO3p rs8KvcKw5ufKStV9fbWm7YE12W4l4ykfF50gd85dy+8AiSyeqxo9BA+ZbIzKL3m+nABX JI1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=USX0ftpomUxyk11osoKZM8PajWEiG+eCpcu5WNYs5sE=; b=U7LAvhaWbI06XSRn1HZxQxdzsDjyk9+XrEPWirCGFg7vGXNEVQFzQSUdOIR/TsUXCe HJTZrhbAOoLkaPyqVTxXSY/CQLDcWMZBtw6bmzc6rgAaRYtrl9iGvwUreN4iwX0dC/mF zR4YR6jZeOxQArFbcwOZGQu9QeVvGepSMp6Uby/XHb0b6eHBxUCK2Kl0/786xpXo+wso D/g22UO+/WHcS/VO2QmDTGFp1qTy2guucpnBwgFsv0PM/Yvvp+fTg1FDCWs2yuEbNlsX mCrkNSsIFx3gcbc+yq41gtI7S+RjxchTf1qiFcMuVfj1qZFo+zmzSlaIvo4eAUK25dEI r4+w== X-Gm-Message-State: AOAM533DCElEFyHLfVoRHB7OFhC/dcGigmGxDv11U0w6l09BjnTl1kEr eh1gKkL2bUPJHKVczVWWjMWXhejDKCA= X-Google-Smtp-Source: ABdhPJxWzwCX2fIYGBjgF3IZYoPS1Wby5v5fiS5Wyqdr8xpG1hJL0BwuMwzvdHhEyhUX6hrH3oyDVQ== X-Received: by 2002:a5d:5006:: with SMTP id e6mr23616462wrt.170.1591022896720; Mon, 01 Jun 2020 07:48:16 -0700 (PDT) Received: from klegouguec-HP-ProBook-450-G1 (200.143.13.109.rev.sfr.net. [109.13.143.200]) by smtp.gmail.com with ESMTPSA id a126sm9468783wme.28.2020.06.01.07.48.15 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Jun 2020 07:48:15 -0700 (PDT) From: =?utf-8?Q?K=C3=A9vin_Le_Gouguec?= To: Kyle Meyer Subject: Re: Failing tests References: <87wo4vv4mt.fsf@kyleam.com> <87imgevrou.fsf@gmail.com> <878sh8vgx3.fsf@kyleam.com> Date: Mon, 01 Jun 2020 16:48:15 +0200 In-Reply-To: <878sh8vgx3.fsf@kyleam.com> (Kyle Meyer's message of "Sun, 31 May 2020 04:59:04 +0000") Message-ID: <87r1uyhmfk.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=kevin.legouguec@gmail.com; helo=mail-wr1-x42b.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bastien , emacs-orgmode@gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=VAWh2VkL; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: -1.71 X-TUID: gzpPWsTTWIpy --=-=-= Content-Type: text/plain Kyle Meyer writes: >> I think I've narrowed this down to org-open-file running "less >> examples/att1/fileA" instead of visiting this file. > [...] >> Let-binding org-file-apps to '(("." . emacs)) makes the tests pass, but >> I don't know if that's the way we want to solve this. > > Thanks for looking into the failures. Let-binding org-file-apps sounds > like a good approach to me. Rather than the catch-all regular > expression, I believe the value could be ((t . emacs)). Absolutely. I've attached a patch to that effect. I wonder though, shouldn't org-open-file always visit text/plain files? Why would we ever want to send those to an external viewer? I think this would need special-casing inside org-open-file, since I don't see a way to catch all text/plain files with org-file-apps. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Make-tests-robust-with-respect-to-mailcap-entries.patch >From 05a71740c662fcde3fcfad7c07975052781ec589 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Le=20Gouguec?= Date: Mon, 1 Jun 2020 16:07:44 +0200 Subject: [PATCH] Make tests robust with respect to mailcap entries When /etc/mailcap specifies a program for text/plain files (e.g. less(1)), org-open-file will run this program instead of visiting the file. This throws off some tests which expect extension-less temporary files to be visited. * testing/lisp/test-ob-tangle.el (ob-tangle/jump-to-org): * testing/lisp/test-org-attach.el (test-org-attach/dir): Rig org-file-apps so that temporary files are visited inside Emacs. --- testing/lisp/test-ob-tangle.el | 121 +++++++++++++------------- testing/lisp/test-org-attach.el | 147 ++++++++++++++++---------------- 2 files changed, 135 insertions(+), 133 deletions(-) diff --git a/testing/lisp/test-ob-tangle.el b/testing/lisp/test-ob-tangle.el index 2283037fc..35490f538 100644 --- a/testing/lisp/test-ob-tangle.el +++ b/testing/lisp/test-ob-tangle.el @@ -125,23 +125,24 @@ echo 1 (ert-deftest ob-tangle/jump-to-org () "Test `org-babel-tangle-jump-to-org' specifications." ;; Standard test. - (should - (equal - "* H\n#+begin_src emacs-lisp\n1\n#+end_src" - (org-test-with-temp-text-in-file - "* H\n#+begin_src emacs-lisp\n1\n#+end_src" - (let ((file (buffer-file-name))) - (org-test-with-temp-text - (format ";; [[file:%s][H:1]]\n1\n;; H:1 ends here\n" - (file-name-nondirectory file)) - (org-babel-tangle-jump-to-org) - (buffer-string)))))) - ;; Multiple blocks in the same section. - (should - (equal - "2" - (org-test-with-temp-text-in-file - "* H + (let ((org-file-apps '((t . emacs)))) + (should + (equal + "* H\n#+begin_src emacs-lisp\n1\n#+end_src" + (org-test-with-temp-text-in-file + "* H\n#+begin_src emacs-lisp\n1\n#+end_src" + (let ((file (buffer-file-name))) + (org-test-with-temp-text + (format ";; [[file:%s][H:1]]\n1\n;; H:1 ends here\n" + (file-name-nondirectory file)) + (org-babel-tangle-jump-to-org) + (buffer-string)))))) + ;; Multiple blocks in the same section. + (should + (equal + "2" + (org-test-with-temp-text-in-file + "* H first block @@ -155,49 +156,49 @@ another block 2 #+end_src " - (let ((file (buffer-file-name))) - (org-test-with-temp-text - (format ";; [[file:%s][H:2]]\n2\n;; H:2 ends here\n" - (file-name-nondirectory file)) - (org-babel-tangle-jump-to-org) - (buffer-substring (line-beginning-position) - (line-end-position))))))) - ;; Preserve position within the source code. - (should - (equal - "1)" - (org-test-with-temp-text-in-file - "* H\n#+begin_src emacs-lisp\n(+ 1 1)\n#+end_src" - (let ((file (buffer-file-name))) - (org-test-with-temp-text - (format ";; [[file:%s][H:1]]\n(+ 1 1)\n;; H:1 ends here\n" - (file-name-nondirectory file)) - (org-babel-tangle-jump-to-org) - (buffer-substring-no-properties (point) (line-end-position))))))) - ;; Blocks before first heading. - (should - (equal - "Buffer start\n#+begin_src emacs-lisp\n1\n#+end_src\n* H" - (org-test-with-temp-text-in-file - "Buffer start\n#+begin_src emacs-lisp\n1\n#+end_src\n* H" - (let ((file (buffer-file-name))) - (org-test-with-temp-text - (format ";; [[file:%s][H:1]]\n1\n;; H:1 ends here\n" - (file-name-nondirectory file)) - (org-babel-tangle-jump-to-org) - (buffer-string)))))) - ;; Special case: buffer starts with a source block. - (should - (equal - "#+begin_src emacs-lisp\n1\n#+end_src\n* H" - (org-test-with-temp-text-in-file - "#+begin_src emacs-lisp\n1\n#+end_src\n* H" - (let ((file (buffer-file-name))) - (org-test-with-temp-text - (format ";; [[file:%s][H:1]]\n1\n;; H:1 ends here\n" - (file-name-nondirectory file)) - (org-babel-tangle-jump-to-org) - (buffer-string))))))) + (let ((file (buffer-file-name))) + (org-test-with-temp-text + (format ";; [[file:%s][H:2]]\n2\n;; H:2 ends here\n" + (file-name-nondirectory file)) + (org-babel-tangle-jump-to-org) + (buffer-substring (line-beginning-position) + (line-end-position))))))) + ;; Preserve position within the source code. + (should + (equal + "1)" + (org-test-with-temp-text-in-file + "* H\n#+begin_src emacs-lisp\n(+ 1 1)\n#+end_src" + (let ((file (buffer-file-name))) + (org-test-with-temp-text + (format ";; [[file:%s][H:1]]\n(+ 1 1)\n;; H:1 ends here\n" + (file-name-nondirectory file)) + (org-babel-tangle-jump-to-org) + (buffer-substring-no-properties (point) (line-end-position))))))) + ;; Blocks before first heading. + (should + (equal + "Buffer start\n#+begin_src emacs-lisp\n1\n#+end_src\n* H" + (org-test-with-temp-text-in-file + "Buffer start\n#+begin_src emacs-lisp\n1\n#+end_src\n* H" + (let ((file (buffer-file-name))) + (org-test-with-temp-text + (format ";; [[file:%s][H:1]]\n1\n;; H:1 ends here\n" + (file-name-nondirectory file)) + (org-babel-tangle-jump-to-org) + (buffer-string)))))) + ;; Special case: buffer starts with a source block. + (should + (equal + "#+begin_src emacs-lisp\n1\n#+end_src\n* H" + (org-test-with-temp-text-in-file + "#+begin_src emacs-lisp\n1\n#+end_src\n* H" + (let ((file (buffer-file-name))) + (org-test-with-temp-text + (format ";; [[file:%s][H:1]]\n1\n;; H:1 ends here\n" + (file-name-nondirectory file)) + (org-babel-tangle-jump-to-org) + (buffer-string)))))))) (ert-deftest ob-tangle/nested-block () "Test tangling of org file with nested block." diff --git a/testing/lisp/test-org-attach.el b/testing/lisp/test-org-attach.el index f910526c2..168e5d56f 100644 --- a/testing/lisp/test-org-attach.el +++ b/testing/lisp/test-org-attach.el @@ -30,80 +30,81 @@ (ert-deftest test-org-attach/dir () "Test `org-attach-get' specifications." - (should (equal "Text in fileA\n" - (org-test-in-example-file org-test-attachments-file - (goto-char 157) ;; First attachment link - (org-open-at-point) - (buffer-string)))) - (should-not (equal "Text in fileB\n" - (org-test-in-example-file org-test-attachments-file - (goto-char 219) ;; Second attachment link - (let ((org-attach-use-inheritance nil)) - (org-open-at-point) - (buffer-string))))) - (should (equal "Text in fileB\n" - (org-test-in-example-file org-test-attachments-file - (goto-char 219) ;; Second attachment link - (let ((org-attach-use-inheritance t)) + (let ((org-file-apps '((t . emacs)))) + (should (equal "Text in fileA\n" + (org-test-in-example-file org-test-attachments-file + (goto-char 157) ;; First attachment link (org-open-at-point) - (buffer-string))))) - (should-not (equal "att1" - (org-test-in-example-file org-test-attachments-file - (goto-char 179) ;; H1.1 - (let ((org-attach-use-inheritance nil)) - (org-attach-dir))))) - (should (equal "att1" - (org-test-in-example-file org-test-attachments-file - (goto-char 179) ;; H1.1 - (let ((org-attach-use-inheritance t)) - (org-attach-dir))))) - (should (equal '("fileC" "fileD") - (org-test-in-example-file org-test-attachments-file - (goto-char 239) ;; H1.2 - (org-attach-file-list (org-attach-dir))))) - (should (equal '("fileC" "fileD") - (org-test-in-example-file org-test-attachments-file - (goto-char 239) ;; H1.2 - (org-attach-file-list (org-attach-dir))))) - (should (equal '("fileE") - (org-test-in-example-file org-test-attachments-file - (goto-char 289) ;; H2 - (let ((org-attach-id-dir "data/")) - (org-attach-file-list (org-attach-dir)))))) - (should (equal "peek-a-boo\n" - (org-test-in-example-file org-test-attachments-file - (goto-char 289) ;; H2 - (let ((org-attach-id-dir "data/")) - (org-attach-open-in-emacs) - (buffer-string))))) - (should (equal '("fileA" "fileB") - (org-test-in-example-file org-test-attachments-file - (goto-char 336) ;; H3 - (org-attach-file-list (org-attach-dir))))) - ;; Test for folder not initialized in the filesystem - (should-not (org-test-in-example-file org-test-attachments-file - (goto-char 401) ;; H3.1 - (let ((org-attach-use-inheritance nil) - (org-attach-id-dir "data/")) - (org-attach-dir)))) - ;; Not yet initialized folder should be found if no-fs-check is - ;; non-nil - (should (equal "data/ab/cd12345" - (org-test-in-example-file org-test-attachments-file - (goto-char 401) ;; H3.1 - (let ((org-attach-use-inheritance nil) - (org-attach-id-dir "data/")) - (file-relative-name (org-attach-dir nil t)))))) - (should (equal '("fileA" "fileB") - (org-test-in-example-file org-test-attachments-file - (goto-char 401) ;; H3.1 - (let ((org-attach-use-inheritance t)) - ;; This is where it gets a bit sketchy...! DIR always has - ;; priority over ID, even if ID is declared "higher up" in the - ;; tree. This can potentially be revised. But it is also - ;; pretty clean. DIR is always higher in priority than ID right - ;; now, no matter the depth in the tree. - (org-attach-file-list (org-attach-dir))))))) + (buffer-string)))) + (should-not (equal "Text in fileB\n" + (org-test-in-example-file org-test-attachments-file + (goto-char 219) ;; Second attachment link + (let ((org-attach-use-inheritance nil)) + (org-open-at-point) + (buffer-string))))) + (should (equal "Text in fileB\n" + (org-test-in-example-file org-test-attachments-file + (goto-char 219) ;; Second attachment link + (let ((org-attach-use-inheritance t)) + (org-open-at-point) + (buffer-string))))) + (should-not (equal "att1" + (org-test-in-example-file org-test-attachments-file + (goto-char 179) ;; H1.1 + (let ((org-attach-use-inheritance nil)) + (org-attach-dir))))) + (should (equal "att1" + (org-test-in-example-file org-test-attachments-file + (goto-char 179) ;; H1.1 + (let ((org-attach-use-inheritance t)) + (org-attach-dir))))) + (should (equal '("fileC" "fileD") + (org-test-in-example-file org-test-attachments-file + (goto-char 239) ;; H1.2 + (org-attach-file-list (org-attach-dir))))) + (should (equal '("fileC" "fileD") + (org-test-in-example-file org-test-attachments-file + (goto-char 239) ;; H1.2 + (org-attach-file-list (org-attach-dir))))) + (should (equal '("fileE") + (org-test-in-example-file org-test-attachments-file + (goto-char 289) ;; H2 + (let ((org-attach-id-dir "data/")) + (org-attach-file-list (org-attach-dir)))))) + (should (equal "peek-a-boo\n" + (org-test-in-example-file org-test-attachments-file + (goto-char 289) ;; H2 + (let ((org-attach-id-dir "data/")) + (org-attach-open-in-emacs) + (buffer-string))))) + (should (equal '("fileA" "fileB") + (org-test-in-example-file org-test-attachments-file + (goto-char 336) ;; H3 + (org-attach-file-list (org-attach-dir))))) + ;; Test for folder not initialized in the filesystem + (should-not (org-test-in-example-file org-test-attachments-file + (goto-char 401) ;; H3.1 + (let ((org-attach-use-inheritance nil) + (org-attach-id-dir "data/")) + (org-attach-dir)))) + ;; Not yet initialized folder should be found if no-fs-check is + ;; non-nil + (should (equal "data/ab/cd12345" + (org-test-in-example-file org-test-attachments-file + (goto-char 401) ;; H3.1 + (let ((org-attach-use-inheritance nil) + (org-attach-id-dir "data/")) + (file-relative-name (org-attach-dir nil t)))))) + (should (equal '("fileA" "fileB") + (org-test-in-example-file org-test-attachments-file + (goto-char 401) ;; H3.1 + (let ((org-attach-use-inheritance t)) + ;; This is where it gets a bit sketchy...! DIR always has + ;; priority over ID, even if ID is declared "higher up" in the + ;; tree. This can potentially be revised. But it is also + ;; pretty clean. DIR is always higher in priority than ID right + ;; now, no matter the depth in the tree. + (org-attach-file-list (org-attach-dir)))))))) (ert-deftest test-org-attach/dired-attach-to-next-best-subtree/1 () "Attach file at point in dired to subtree." -- 2.17.1 --=-=-= Content-Type: text/plain The diff looks big, but most of it is just re-indentation. Here is the signal beneath the whitespace noise: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=clean.diff diff --git a/testing/lisp/test-ob-tangle.el b/testing/lisp/test-ob-tangle.el index 2283037fc..35490f538 100644 --- a/testing/lisp/test-ob-tangle.el +++ b/testing/lisp/test-ob-tangle.el @@ -125,6 +125,7 @@ (ert-deftest ob-tangle/jump-to-org () "Test `org-babel-tangle-jump-to-org' specifications." ;; Standard test. + (let ((org-file-apps '((t . emacs)))) (should (equal "* H\n#+begin_src emacs-lisp\n1\n#+end_src" @@ -197,7 +197,7 @@ (format ";; [[file:%s][H:1]]\n1\n;; H:1 ends here\n" (file-name-nondirectory file)) (org-babel-tangle-jump-to-org) - (buffer-string))))))) + (buffer-string)))))))) (ert-deftest ob-tangle/nested-block () "Test tangling of org file with nested block." diff --git a/testing/lisp/test-org-attach.el b/testing/lisp/test-org-attach.el index f910526c2..168e5d56f 100644 --- a/testing/lisp/test-org-attach.el +++ b/testing/lisp/test-org-attach.el @@ -30,6 +30,7 @@ (ert-deftest test-org-attach/dir () "Test `org-attach-get' specifications." + (let ((org-file-apps '((t . emacs)))) (should (equal "Text in fileA\n" (org-test-in-example-file org-test-attachments-file (goto-char 157) ;; First attachment link @@ -103,7 +104,7 @@ ;; tree. This can potentially be revised. But it is also ;; pretty clean. DIR is always higher in priority than ID right ;; now, no matter the depth in the tree. - (org-attach-file-list (org-attach-dir))))))) + (org-attach-file-list (org-attach-dir)))))))) (ert-deftest test-org-attach/dired-attach-to-next-best-subtree/1 () "Attach file at point in dired to subtree." --=-=-=--