From: "Christopher M. Miles" <numbchild@gmail.com>
To: Ihor Radchenko <yantar92@gmail.com>
Cc: "Christopher M. Miles" <numbchild@gmail.com>, emacs-orgmode@gnu.org
Subject: Re: [PATCH 2-v4] New: auto display inline images under subtree when `org-cycle'.
Date: Sat, 22 Oct 2022 09:29:24 +0800 [thread overview]
Message-ID: <m21qr0skzl.fsf@numbchild@gmail.com> (raw)
In-Reply-To: <m2v8os5aqy.fsf@numbchild>
[-- Attachment #1: Type: text/plain, Size: 15614 bytes --]
Whether can this patch be merged at first, put the test in future to
finish? In recent days, I still have not figured out this image overlays
test.
"Christopher M. Miles" <numbchild@gmail.com> writes:
> [[PGP Signed Part:Undecided]]
>
> Ihor Radchenko <yantar92@gmail.com> writes:
>
>> "Christopher M. Miles" <numbchild@gmail.com> writes:
>>
>>>> I think that the best we can do in this situation is mocking
>>>> `create-image' in batch mode to return non-nil using `cl-letf'.
>>>
>>> I checked the `create-image' in image.el source code, don't know how to
>>> mocking this. I have no experience and idea about this. I also searched
>>> org testing. Have not found similar situations.
>>>
>>> If you have idea how to write this test, I suggest pass this word to
>>> you. What do you think?
>>
>> I imagine something like
>>
>> ;; Mock `create-image' to work noninteractively.
>> (cl-letf (((symbol-function 'create-image)
>> (lambda (&rest _)
>> `(image :type "dummy" :data "dummy"))))
>> <your test code here>)
>
> After wrapped your cl-letf redefining function binding. Still failed on test.
>
> Here is the new test code:
>
> #+begin_src emacs-lisp
> (ert-deftest test-org-fold/org-fold-display-inline-images ()
> "Test inline images displaying when cycling."
> ;; Mock `create-image' to work noninteractively.
> (cl-letf (((symbol-function 'create-image)
> (lambda (&rest _) `(image :type "dummy" :data "dummy"))))
> (let* ((org-cycle-inline-images-display t)
> (images-dir (expand-file-name "examples/images/" org-test-dir))
> (org-logo-image (expand-file-name "Org mode logo mono-color.png" images-dir)))
> ;; `org-cycle' -(state)-> `'children' display child inline images.
> (org-test-with-temp-text
> (format "<point>* Heading 1
> [[file:%s]]
> " org-logo-image)
> (org-overview)
> ;; (org-cycle)
> ;; (org-cycle-internal-local)
> ;; (org-cycle-display-inline-images 'children)
> (org-fold-show-children)
> (run-hook-with-args 'org-cycle-hook 'children)
> (org-next-link)
> (should org-inline-image-overlays)
> (should (overlays-at (point)))
> (org-toggle-inline-images)
> (should-not (overlays-at (point))))
>
> ;; `org-cycle' -(state)-> `'subtree' display subtrees inline images.
> (org-test-with-temp-text
> (format "<point>* Heading 1
> [[file:%s]]
> ** Subheading 1
> [[file:%s]]
> ** Subheading 2
> [[file:%s]]" org-logo-image org-logo-image org-logo-image)
> (org-overview)
> ;; (org-cycle)
> ;; (org-cycle)
> ;; (org-cycle-internal-global)
> (org-fold-show-subtree)
> (run-hook-with-args 'org-cycle-hook 'subtree)
> (org-next-link)
> (org-next-link)
> ;; (should org-inline-image-overlays)
> (should (overlays-at (point)))
> (org-toggle-inline-images)
> (should-not (overlays-at (point))))
>
> ;; `org-cycle' -(state)-> `'folded' remove inline image overlays.
> (org-test-with-temp-text
> (format "<point>* Heading 1
> [[file:%s]]
> ** Subheading 1
> [[file:%s]]
> ** Subheading 2
> [[file:%s]]" org-logo-image org-logo-image org-logo-image)
> (org-overview)
> (org-show-subtree)
> (org-fold-subtree t)
> (run-hook-with-args 'org-cycle-hook 'folded)
> (should (null org-inline-image-overlays))
> (should (null (overlays-in (point-min) (point-max))))
> (org-show-subtree)
> (should-not org-inline-image-overlays)
> (should-not (overlays-in (point-min) (point-max)))))))
> #+end_src
>
>
> And failed after command:
>
> #+begin_src shell
> make BTEST_RE="test-org-fold/org-fold-display-inline-images" test-dirty
> #+end_src
>
>
> Here is the output:
>
> #+begin_example
> ~/Code/Emacs/org-mode:main*:1 λ make BTEST_RE="test-org-fold/org-fold-display-inline-images" test-dirty
> install -m 755 -d /var/folders/ym/f3v5_yk1279g5ls70x3hzblh0000gn/T//tmp-orgtest
> TMPDIR=/var/folders/ym/f3v5_yk1279g5ls70x3hzblh0000gn/T//tmp-orgtest emacs -Q -batch --eval '(setq vc-handled-backends nil org-startup-folded nil org-element-cache-persistent nil)' --eval '(add-to-list '"'"'load-path (concat default-directory "lisp"))' --eval '(add-to-list '"'"'load-path (concat default-directory "testing"))' -l org-batch-test-init --eval '(setq org-batch-test t org-babel-load-languages (quote ( (awk . t) (C . t) (fortran . t) (maxima . t) (lilypond . t) (octave . t) (perl . t) (python . t) (emacs-lisp . t) (shell . t) (org . t))) org-test-select-re "test-org-fold/org-fold-display-inline-images" )' -l org-loaddefs.el -l cl -l testing/org-test.el -l ert -l org -l ox -l ol --eval '(org-test-run-batch-tests org-test-select-re)'
> Package cl is deprecated
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/org.el' newer than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/org-compat.el' newer than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/org-macs.el' newer than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/org-keys.el' newer than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/oc.el' newer than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/ol.el' newer than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/org-table.el' newer than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/org-cycle.el' newer than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/ob-awk.el' newer than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/ob-core.el' newer than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/ob-comint.el' newer than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/ob-exp.el' newer than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/ob-ref.el' newer than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/org-src.el' newer than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/ob-maxima.el' newer than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/ob-lilypond.el' newer than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/ob-octave.el' newer than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/ob-emacs-lisp.el' newer than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/org-list.el' newer than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/org-pcomplete.el' newer than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/org-macro.el' newer than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/org-id.el' newer than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/org-refile.el' newer than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/org.el' newer than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/ol-doi.el' newer than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/ol-irc.el' newer than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/org-element.el' newer than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/ox.el' newer than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/ox-html.el' newer than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/ox-icalendar.el' newer than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/org-agenda.el' newer than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/ol.el' newer than byte-compiled file; using older file
> Finding ID locations (1/26 files): /Users/stardiviner/Code/Emacs/org-mode/testing/examples/setupfile3.org
> Finding ID locations (2/26 files): /Users/stardiviner/Code/Emacs/org-mode/testing/examples/setupfile.org
> Finding ID locations (3/26 files): /Users/stardiviner/Code/Emacs/org-mode/testing/examples/property-inheritance.org
> Finding ID locations (4/26 files): /Users/stardiviner/Code/Emacs/org-mode/testing/examples/org-exp.org
> Finding ID locations (5/26 files): /Users/stardiviner/Code/Emacs/org-mode/testing/examples/ob-shell-test.org
> Finding ID locations (6/26 files): /Users/stardiviner/Code/Emacs/org-mode/testing/examples/ob-sed-test.org
> Finding ID locations (7/26 files): /Users/stardiviner/Code/Emacs/org-mode/testing/examples/ob-screen-test.org
> Finding ID locations (8/26 files): /Users/stardiviner/Code/Emacs/org-mode/testing/examples/ob-octave-test.org
> Finding ID locations (9/26 files): /Users/stardiviner/Code/Emacs/org-mode/testing/examples/ob-maxima-test.org
> Finding ID locations (10/26 files): /Users/stardiviner/Code/Emacs/org-mode/testing/examples/ob-lilypond-test.org
> Finding ID locations (11/26 files): /Users/stardiviner/Code/Emacs/org-mode/testing/examples/ob-lilypond-broken.org
> Finding ID locations (12/26 files): /Users/stardiviner/Code/Emacs/org-mode/testing/examples/ob-header-arg-defaults.org
> Finding ID locations (13/26 files): /Users/stardiviner/Code/Emacs/org-mode/testing/examples/ob-fortran-test.org
> Finding ID locations (14/26 files): /Users/stardiviner/Code/Emacs/org-mode/testing/examples/ob-awk-test.org
> Finding ID locations (15/26 files): /Users/stardiviner/Code/Emacs/org-mode/testing/examples/ob-C-test.org
> Finding ID locations (16/26 files): /Users/stardiviner/Code/Emacs/org-mode/testing/examples/normal.org
> Finding ID locations (17/26 files): /Users/stardiviner/Code/Emacs/org-mode/testing/examples/no-heading.org
> Finding ID locations (18/26 files): /Users/stardiviner/Code/Emacs/org-mode/testing/examples/macro-templates.org
> Finding ID locations (19/26 files): /Users/stardiviner/Code/Emacs/org-mode/testing/examples/links.org
> Finding ID locations (20/26 files): /Users/stardiviner/Code/Emacs/org-mode/testing/examples/link-in-heading.org
> Finding ID locations (21/26 files): /Users/stardiviner/Code/Emacs/org-mode/testing/examples/include2.org
> Finding ID locations (22/26 files): /Users/stardiviner/Code/Emacs/org-mode/testing/examples/include.org
> Finding ID locations (23/26 files): /Users/stardiviner/Code/Emacs/org-mode/testing/examples/babel.org
> Finding ID locations (24/26 files): /Users/stardiviner/Code/Emacs/org-mode/testing/examples/babel-dangerous.org
> Finding ID locations (25/26 files): /Users/stardiviner/Code/Emacs/org-mode/testing/examples/attachments.org
> Finding ID locations (26/26 files): /Users/stardiviner/Code/Emacs/org-mode/testing/examples/agenda-file.org
> 26 files scanned, 14 files contains IDs, and 58 IDs found.
> 0 source block added to Library of Babel
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/ob-sed.el' newer than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/org-inlinetask.el' newer than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/org-capture.el' newer than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/org-clock.el' newer than byte-compiled file; using older file
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/org-feed.el' newer than byte-compiled file; using older file
> Local variables list is not properly terminated
> Source file `/Users/stardiviner/Code/Emacs/org-mode/lisp/org-lint.el' newer than byte-compiled file; using older file
> selected tests: test-org-fold/org-fold-display-inline-images
> Running 1 tests (2022-10-10 16:31:04+0800, selector `"test-org-fold/org-fold-display-inline-images"')
> Test test-org-fold/org-fold-display-inline-images backtrace:
> signal(ert-test-failed (((should org-inline-image-overlays) :form or
> ert-fail(((should org-inline-image-overlays) :form org-inline-image-
> (if (unwind-protect (setq value-12536 org-inline-image-overlays) (se
> (let (form-description-12537) (if (unwind-protect (setq value-12536
> (let ((value-12536 (gensym "ert-form-evaluation-aborted-"))) (let (f
> (progn (org-mode) (let ((point (string-match "<point>" inside-text))
> (unwind-protect (progn (org-mode) (let ((point (string-match "<point
> (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn
> (let ((temp-buffer (generate-new-buffer " *temp*" t))) (save-current
> (let ((inside-text (if (stringp (format "<point>* Heading 1\n[[file:
> (let* ((org-cycle-inline-images-display t) (images-dir (expand-file-
> (progn (fset 'create-image vnew) (let* ((org-cycle-inline-images-dis
> (unwind-protect (progn (fset 'create-image vnew) (let* ((org-cycle-i
> (let* ((vnew #'(lambda (&rest _) '(image :type "dummy" :data "dummy"
> (closure (t) nil (let* ((vnew #'(lambda (&rest _) '(image :type "dum
> ert--run-test-internal(#s(ert--test-execution-info :test ... :result
> ert-run-test(#s(ert-test :name test-org-fold/org-fold-display-inline
> ert-run-or-rerun-test(#s(ert--stats :selector "test-org-fold/..." :t
> ert-run-tests("test-org-fold/org-fold-display-inline-images" #f(comp
> ert-run-tests-batch("test-org-fold/org-fold-display-inline-images")
> ert-run-tests-batch-and-exit("test-org-fold/org-fold-display-inline-
> (let ((org-id-track-globally t) (org-test-selector (if org-test-sele
> org-test-run-batch-tests("test-org-fold/org-fold-display-inline-imag
> eval((org-test-run-batch-tests org-test-select-re) t)
> command-line-1(("--eval" "(setq vc-handled-backends nil org-startup-
> command-line()
> normal-top-level()
> Test test-org-fold/org-fold-display-inline-images condition:
> (ert-test-failed
> ((should org-inline-image-overlays)
> :form org-inline-image-overlays :value nil))
> FAILED 1/1 test-org-fold/org-fold-display-inline-images (0.001214 sec) at ../lisp/test-org-fold.el:607
>
> Ran 1 tests, 0 results as expected, 1 unexpected (2022-10-10 16:31:04+0800, 0.166044 sec)
>
> 1 unexpected results:
> FAILED test-org-fold/org-fold-display-inline-images ((should org-inline-image-overlays) :form org-inline-image-overlays :value nil)
>
> make: *** [test-dirty] Error 1
> ~/Code/Emacs/org-mode:main*:1 λ
> #+end_example
--
[ stardiviner ]
I try to make every word tell the meaning that I want to express without misunderstanding.
Blog: https://stardiviner.github.io/
IRC(libera.chat, freenode): stardiviner, Matrix: stardiviner
GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]
next prev parent reply other threads:[~2022-10-22 1:38 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-22 6:34 [QUESTION] How to specific image size attributes under headline scope? Christopher M. Miles
2021-11-22 18:31 ` Timothy
2022-08-18 12:44 ` Christopher M. Miles
[not found] ` <m2o7whra7j.fsf@numbchild>
2022-08-22 17:10 ` Timothy
2022-08-23 0:24 ` Christopher M. Miles
2022-09-11 2:20 ` [SOLVED] " Christopher M. Miles
2022-09-11 2:25 ` Christopher M. Miles
[not found] ` <631d472b.c80a0220.2b4b2.bf86SMTPIN_ADDED_BROKEN@mx.google.com>
2022-09-11 12:34 ` Ihor Radchenko
2022-09-12 1:54 ` [PATCH] " Christopher M. Miles
2022-09-12 1:59 ` [PATCH] New: auto display inline images under subtree when `org-cycle' Christopher M. Miles
[not found] ` <m2wna9bbc2.fsf@numbchild>
2022-09-12 6:03 ` [ISSUE] " Christopher M. Miles
[not found] ` <631e92ee.050a0220.f9c18.92f5SMTPIN_ADDED_BROKEN@mx.google.com>
2022-09-12 10:51 ` Ihor Radchenko
2022-09-13 1:09 ` [PATCH 2] " Christopher M. Miles
[not found] ` <m2leqogiz8.fsf@numbchild>
2022-09-13 1:48 ` [PATCH 3] " Christopher M. Miles
[not found] ` <631fe1c9.050a0220.3ab2b.3f52SMTPIN_ADDED_BROKEN@mx.google.com>
2022-09-15 3:27 ` Ihor Radchenko
2022-09-15 4:53 ` [PATCH 4] " Christopher M. Miles
[not found] ` <6322b0a8.050a0220.59bb8.6923SMTPIN_ADDED_BROKEN@mx.google.com>
2022-09-15 8:47 ` Ihor Radchenko
2022-09-15 9:43 ` [PATCH 5] " Christopher M. Miles
[not found] ` <6322f5ad.c80a0220.5e936.823eSMTPIN_ADDED_BROKEN@mx.google.com>
2022-09-20 7:01 ` [PATCH v6] " Ihor Radchenko
2022-09-20 11:32 ` [PATCH v6] " Christopher M. Miles
[not found] ` <6329c8b0.050a0220.412d.0a6cSMTPIN_ADDED_BROKEN@mx.google.com>
2022-09-21 7:54 ` Ihor Radchenko
2022-09-28 12:55 ` [PATCH 2-v1] " Christopher M. Miles
[not found] ` <633454e3.050a0220.7278b.1fa5SMTPIN_ADDED_BROKEN@mx.google.com>
2022-09-29 3:05 ` Ihor Radchenko
2022-09-29 6:06 ` Christopher M. Miles
2022-09-29 6:57 ` [PATCH 2-v1 (test v1)] " Christopher M. Miles
[not found] ` <63353c69.370a0220.67788.e8a1SMTPIN_ADDED_BROKEN@mx.google.com>
2022-09-30 3:19 ` [PATCH 2-v1] " Ihor Radchenko
2022-09-30 8:27 ` [PATCH 2-v2] " Christopher M. Miles
[not found] ` <6336a955.050a0220.4e72e.2b23SMTPIN_ADDED_BROKEN@mx.google.com>
2022-10-01 3:16 ` Ihor Radchenko
2022-10-01 9:51 ` [PATCH 2-v3] " Christopher M. Miles
[not found] ` <63380f57.370a0220.a9d9a.dee8SMTPIN_ADDED_BROKEN@mx.google.com>
2022-10-03 3:21 ` Ihor Radchenko
2022-10-03 4:37 ` [PATCH 2-v4] " Christopher M. Miles
[not found] ` <633a67d8.050a0220.733e8.e57dSMTPIN_ADDED_BROKEN@mx.google.com>
2022-10-04 4:36 ` Ihor Radchenko
2022-10-04 7:27 ` Christopher M. Miles
[not found] ` <633be6d3.370a0220.4060.bacdSMTPIN_ADDED_BROKEN@mx.google.com>
2022-10-08 7:53 ` Ihor Radchenko
2022-10-08 9:50 ` Christopher M. Miles
[not found] ` <634149f4.c80a0220.1376.e564SMTPIN_ADDED_BROKEN@mx.google.com>
2022-10-09 7:21 ` Ihor Radchenko
2022-10-10 8:40 ` Christopher M. Miles
[not found] ` <m2v8os5aqy.fsf@numbchild>
2022-10-22 1:29 ` Christopher M. Miles [this message]
2022-10-23 4:33 ` Ihor Radchenko
2022-10-23 7:14 ` Christopher M. Miles
2022-10-25 7:23 ` Ihor Radchenko
2022-10-25 14:22 ` [PATCH v3] " Christopher M. Miles
2022-10-26 4:50 ` Ihor Radchenko
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
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m21qr0skzl.fsf@numbchild@gmail.com \
--to=numbchild@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=yantar92@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 public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).