Subject: Re: bug#64356: [PATCH 0/4] Fix GDM and VNC tests

From: Maxim Cournoyer <[email-masked]>
Date: Wed, 19 Jul 2023 10:50:17 -0400

Hi,

Bruno Victal <[email-masked]> writes:

[...]

> -(define* (marionette-screen-text marionette #:key (ocr "ocrad"))
> +(define* (marionette-screen-text marionette #:key (ocr "ocrad")
> +                                 ocr-arguments)
>    "Take a screenshot of MARIONETTE, perform optical character
>  recognition (OCR), and return the text read from the screen as a string, along
>  the screen dump image used.  Do this by invoking OCR, which should be the file
> @@ -324,14 +330,19 @@ (define* (marionette-screen-text marionette #:key (ocr "ocrad"))
>    ;; Process it via the OCR.
>    (cond
>     ((string-contains ocr "ocrad")
> -    (values (invoke-ocrad-ocr image #:ocrad ocr) image))
> +    (values (invoke-ocrad-ocr image
> +                              #:ocrad ocr
> +                              #:ocr-arguments ocr-arguments) image))
>     ((string-contains ocr "tesseract")
> -    (values (invoke-tesseract-ocr image #:tesseract ocr) image))
> +    (values (invoke-tesseract-ocr image
> +                                  #:tesseract ocr
> +                                  #:ocr-arguments ocr-arguments) image))
>     (else (error "unsupported ocr command"))))
>  
>  (define* (wait-for-screen-text marionette predicate
>                                 #:key
>                                 (ocr "ocrad")
> +                               ocr-arguments

Care must be taken here to avoid overwriting the default arguments of
the 'invoke-ocrad-ocr' and 'invoke-tesseract-ocr' procedures.  I've
handled this by extracting a %default-ocrad-arguments and or'ing the
argument here with it in this procedure, like:

--8<---------------cut here---------------start------------->8---
@@ -324,14 +334,22 @@ (define* (marionette-screen-text marionette #:key (ocr "ocrad"))
   ;; Process it via the OCR.
   (cond
    ((string-contains ocr "ocrad")
-    (values (invoke-ocrad-ocr image #:ocrad ocr) image))
+    (values (invoke-ocrad-ocr image
+                              #:ocrad ocr
+                              #:ocr-arguments
+                              (or ocr-arguments %default-ocrad-arguments))
+            image))
    ((string-contains ocr "tesseract")
-    (values (invoke-tesseract-ocr image #:tesseract ocr) image))
+    (values (invoke-tesseract-ocr image
+                                  #:tesseract ocr
+                                  #:ocr-arguments (or ocr-arguments '()))
+            image))
    (else (error "unsupported ocr command"))))
 
 (define* (wait-for-screen-text marionette predicate
                                #:key
                                (ocr "ocrad")
--8<---------------cut here---------------end--------------->8---

Otherwise, LGTM.

-- 
Thanks,
Maxim