Re: Failing tests
Kévin Le Gouguec writes: > 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. Thanks. Applied (c8f7e89d7). > 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. Good question. I'm not sure, though offhand I can't think of cases where I'd want to send text/plain files to an external viewer. I'd guess this doesn't matter much in practice given the default position of (auto-mode . emacs) in org-file-apps, which will catch a good number of text/plain files.
Re: Failing tests
Kévin Le Gouguec writes: > Absolutely. I've attached a patch to that effect. I just realized that these let-bindings probably deserved explanatory comments. Here is an updated patch: >From f996ec3a10a845abae2fa463ab0ea7a761af1707 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 | 124 +- testing/lisp/test-org-attach.el | 148 2 files changed, 138 insertions(+), 134 deletions(-) diff --git a/testing/lisp/test-ob-tangle.el b/testing/lisp/test-ob-tangle.el index 2283037fc..7b1f617ed 100644 --- a/testing/lisp/test-ob-tangle.el +++ b/testing/lisp/test-ob-tangle.el @@ -124,24 +124,26 @@ 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 + ;; Make sure temporary files will be visited inside Emacs. + (let ((org-file-apps '((t . emacs +;; 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 first block @@ -155,49 +157,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#+begi
Re: Failing tests
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. >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) -
Re: Failing tests
Kévin Le Gouguec writes: > Thanks for the pointer, and for applying the patches! > FAILED ob-tangle/jump-to-org FAILED test-org-attach/dir I have had both tests failing for a while without understanding why, if this gets fixed as a side-effect of the incomplete fix I made for ob-C.el, I'd be very happy! -- Bastien
Re: Failing tests (was: Possible fix for :includes header argument in org-babel C source blocks)
Kévin Le Gouguec writes: > Kyle Meyer writes: > >> The source for that page is in the worg repo: >> https://code.orgmode.org/bzg/worg/src/master/org-contrib/babel/languages/ob-doc-C.org > > Thanks for the pointer, and for applying the patches! > FAILED ob-tangle/jump-to-org FAILED test-org-attach/dir >> >> :( >> >> After your first patch, all tests now pass on my end. Would you mind >> posting the details of those failures in a new thread? > > Mmm, on further inspection, those tests fail on one of my setups but > pass on another. > > 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)).
Re: Failing tests
Kyle Meyer writes: > Marco Wahl writes: > >> When building with "make test" I get >> >> #v+ >> 2 unexpected results: >>FAILED ob-tangle/jump-to-org >>FAILED test-org-attach/dir >> #v- >> >> does this ring a bell for anybody? > > FWIW I don't see either failure on my end (Emacs 26.3). Do they fail > for you consistently? Good to know that the tests pass on your side. I'll check again and report in the case I find something interesting. Thanks! -- Marco
Re: Failing tests
Marco Wahl writes: > When building with "make test" I get > > #v+ > 2 unexpected results: >FAILED ob-tangle/jump-to-org >FAILED test-org-attach/dir > #v- > > does this ring a bell for anybody? FWIW I don't see either failure on my end (Emacs 26.3). Do they fail for you consistently?