Re: master d5f515e4a33 1/2: New image type canvas

Divya Ranjan Pattanaik <[email protected]>
Newsgroups gmane.emacs.devel
Message-ID <[email protected]>
Eli Zaretskii <[email protected]> writes:

>> From: Divya Ranjan Pattanaik <[email protected]>
>> Cc: [email protected]
>> Date: Sat, 22 Aug 2026 11:07:08 +0000
>>
>> Michael Albinus <[email protected]> writes:
>>
>> >
>> > Likely, the tests would profit from
>> >
>> > (skip-unless (functionp 'canvas-refresh))
>> >
>> > Best regards, Michael.
>> >
>>
>> Hello Michael, thank you for reporting this. Here's a patch, it uses
>> (display-graphic-p) instead. Do we need to do anything about the
>> canvas module function in emacs-module-resources/mod-test.c? Or, is
>> it okay if those never get called from emacs-module-tests.el?
>
> I'm quite sure there's more here than meets the eye, because all of
> these tests pass for me in batch mode, both on GNU/Linux and on
> MS-Windows.  So display-graphic-p test is definitely not right here,
> and will just skip tests for no good reason.
>
> Please look closer into these failures.  We need to understand how
> come they fail on Emba, but not on other systems.
>

I think it's because in Emba it's compiled without GUI, so none of the image types are available. There's this in emacs.c:

#ifdef HAVE_WINDOW_SYSTEM
      syms_of_fringe ();
      syms_of_image ();
#endif

I also checked the errors, and one of them is invalid image type. So clearly Emba's emacs build doesn't have the image type, and because it's compiled without GUI, the error when calling module_canvas_data is also valid.

So you are right, we shouldn't be using display-graphic-p which is too strong, maybe instead (skip-unless (image-type-available-p 'canvas))?

Using (skip-unless (image-type-available-p 'canvas)) would skip for Emba, but not for your build because the image type and the module function is still available when you use an Emacs built with GUI but used in TUI.

Patch with the above skip attached.


Regards,
-- 
Divya Ranjan Pattanaik,
Philosophy, Mathematics, Libre Software.

PGP Fingerprint: F0B3 1A69 8006 8FB8 096A  2F12 B245 10C6 108C 8D4A
fix-canvas-tests.patch (text/x-patch, 2.5 KB)
diff --git a/test/src/emacs-module-tests.el b/test/src/emacs-module-tests.el
index 5ee775d12f8..789d723b0d9 100644
--- a/test/src/emacs-module-tests.el
+++ b/test/src/emacs-module-tests.el
@@ -603,6 +603,7 @@ test-canvas-gen-file
     t))
 
 (ert-deftest mod-test-canvas/valid ()
+  (skip-unless (image-type-available-p 'canvas))
   (let* ((width 128) (height 215)
          (canvas `(image :type canvas :id test-canvas
                          :data-width ,width :data-height ,height))
@@ -614,6 +615,7 @@ mod-test-canvas/valid
       (should (not (eql hash-before hash-after))))))
 
 (ert-deftest mod-test-canvas/invalid ()
+  (skip-unless (image-type-available-p 'canvas))
   (should-error (mod-test-canvas-read nil nil nil))
   (should-error (mod-test-canvas-write nil nil nil))
   (should (mod-test-canvas-invalid nil))
@@ -622,6 +624,7 @@ mod-test-canvas/invalid
   (should-error (mod-test-canvas-write '(image :type canvas) 256 527)))
 
 (ert-deftest mod-test-canvas/vector ()
+  (skip-unless (image-type-available-p 'canvas))
   (let* ((width 327) (height 98)
          (canvas `(image :type canvas :id test-canvas
                          :data-width ,width :data-height ,height
@@ -639,6 +642,7 @@ mod-test-canvas/vector
     (should-error (mod-test-canvas-write canvas 187 210))))
 
 (ert-deftest mod-test-canvas/vector-reload ()
+  (skip-unless (image-type-available-p 'canvas))
   (let* ((width 198) (height 720)
          (test-vector (make-vector (* width height) #xFFFF0000))
          (canvas `(image :type canvas :id test-canvas
@@ -654,6 +658,7 @@ mod-test-canvas/vector-reload
       (should (not (eql hash-initial hash-mutated))))))
 
 (ert-deftest mod-test-canvas/unibyte ()
+  (skip-unless (image-type-available-p 'canvas))
   (let* ((width 458) (height 278)
          (pixel (unibyte-string #xFF #x80 #x40 #x80))
          (string-data (apply #'concat (make-list (* width height) pixel)))
@@ -675,6 +680,7 @@ mod-test-canvas/unibyte
     (should-error (mod-test-canvas-write canvas 378 453))))
 
 (ert-deftest mod-test-canvas/file ()
+  (skip-unless (image-type-available-p 'canvas))
   ;; Generate the canvas data file
   (test-canvas-gen-file 128 98 #x80800000)
   (let* ((width 128) (height 98)
@@ -696,6 +702,7 @@ mod-test-canvas/gc-stress
   "Allocate canvases in batches with GC between batches.
 Verifies that canvas pixel buffers are freed correctly and do not
 cause use-after-free crashes or GC assertion failures."
+  (skip-unless (image-type-available-p 'canvas))
   (dotimes (_ 10)
     (dotimes (x 20)
       (let* ((canvas `(image :type canvas :id test-canvas
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.