[bug#52576] About the upgrade of ibus-anthy

Message ID 20220207155016.1381bf8c@tachikoma.lepiller.eu
State New
Headers
Series [bug#52576] About the upgrade of ibus-anthy |

Commit Message

Julien Lepiller Feb. 7, 2022, 2:50 p.m. UTC
  Le Mon, 07 Feb 2022 12:03:38 +0900,
Taiju HIGASHI <higashi@taiju.info> a écrit :

> Hi Liliana,
> 
> Thank you for your response.
> 
> You are right. My attitude of expecting someone else to solve the
> problem was no good.
> 
> So far, I haven't even been able to get the tests to run properly on
> Guix.  Therefore, I can't even properly mention which test is the
> problem.
> 
> I think it will take a long time to solve this problem due to my lack
> of skills.
> In particular, I think I will have a hard time reading the intent of
> the test code. Also, other distributions skip the tests, so I have no
> source to refer to.
> 
> I don't know if I will be able to start working on it right away, but
> I would like to take the time to tackle it properly.
> 
> 
> 

Hi!

I gave a look at the test failures and found a few issues. I attached
the current diff I have, but it's still not working.

The first test checks that the current year is present is a data file
that helps converting gregorian years to Japanese era (such as 2022 ->
れいわ4). However, the file stops at 2021. I fixed that by setting a
fixed year in the test, 2021. Adding 2022 to the data file would have
fixed the issue for now, but in 2023 it would have failed again, and
the time-machine wouldn't work either. That's a time bomb :)

The next test is much more important, and much more difficult to make
it work. First, it needs to open an xorg session, and it needs a bus
session to start ibus. I do that by replacing the check phase with a
call to start dbus and xfvb.

Then, the test fails to find some data in the installation directory,
so I moved the tests after the install phase. It's probably not a real
issue, but it avoids a few warnings. One remains.

The python script that runs the tests fails to use GDK, because the
script that runs it redefines a few variables that are required in a
guix environment, to find gi libraries. I changed the script to only
augment these variables.

Then, the python script tries to open a window on the graphical display
and waits for focus before it starts the tests. Since there is no
interaction possible, I changed the test code to ensure the window is
focused when opened. When creating the window, I use GLib.idle_add to
add an action to run when the main event loop is idle. After that, the
main event loop is started (a call to Gtk.main()). As soon as it
starts, the window is focused and the test starts.

After the window gets focus, the python script starts ibus and
ibus-anthy-test. It complains about not being able to read
/var/lib/dbus/machine-id, but this seems benign. It also complained
about not finding the "profile directory", and after investigation, I
modified anthy itself to introduce GUIX_ANTHY_HOME, which I set before
ibus-anthy tests.

After two test lines, the tests hang, either because of an issue with
ibus-anthy, or the setup of ibus, or because it's waiting for ibus'
window to get focus. At this point, I don't know how to investigate
further.
  

Comments

Taiju HIGASHI Feb. 7, 2022, 3:51 p.m. UTC | #1
Hi Julien,

Thank you so much for looking into solving the testing problem! I am very
happy!

I have read your email and the patch, and I can see that this is a very
difficult problem for me, and not one that I can solve.
I probably would not have been able to get to the point where I could
identify and explain the specific problem as you did.

My skills may not be able to help, but if there is anything I can do to
help with verification, etc., I will cooperate.
  
Maxim Cournoyer June 24, 2022, 2:53 a.m. UTC | #2
Hello,

Julien Lepiller <julien@lepiller.eu> writes:

> Le Mon, 07 Feb 2022 12:03:38 +0900,
> Taiju HIGASHI <higashi@taiju.info> a écrit :
>
>> Hi Liliana,
>> 
>> Thank you for your response.
>> 
>> You are right. My attitude of expecting someone else to solve the
>> problem was no good.
>> 
>> So far, I haven't even been able to get the tests to run properly on
>> Guix.  Therefore, I can't even properly mention which test is the
>> problem.
>> 
>> I think it will take a long time to solve this problem due to my lack
>> of skills.
>> In particular, I think I will have a hard time reading the intent of
>> the test code. Also, other distributions skip the tests, so I have no
>> source to refer to.
>> 
>> I don't know if I will be able to start working on it right away, but
>> I would like to take the time to tackle it properly.
>> 
>> 
>> 
>
> Hi!
>
> I gave a look at the test failures and found a few issues. I attached
> the current diff I have, but it's still not working.

I tried it too; and got a different result [0].  Seeing how not even
upstream run the test suite in a containerized environment and other
projects simply disable it, I think it's reasonable to disable it too
until upstream share more information about how it's supposed to work.

Pushed as 2dc43d7d5b50b3ef6ef506dc2572c9cc3beed334, and salvaged
python-pycotap as 06902a6766f089e4da812876ddcf33e7ba8afce0 (with
improved synopsis and description).

Thanks!

Closing.

Maxim
  
Taiju HIGASHI June 24, 2022, 3:10 a.m. UTC | #3
Hi Maxim,

I'm glad to hear your opinion because I've been stuck.

Yes, I was having trouble because I had disabled testing in other
distributions and had no code to refer to.
Anyway, I'm glad this issue is closed.

Thanks,
  
Liliana Marie Prikler June 24, 2022, 4:21 a.m. UTC | #4
Am Donnerstag, dem 23.06.2022 um 22:53 -0400 schrieb Maxim Cournoyer:
> Pushed as 2dc43d7d5b50b3ef6ef506dc2572c9cc3beed334, and salvaged
> python-pycotap as 06902a6766f089e4da812876ddcf33e7ba8afce0 (with
> improved synopsis and description).
Totally minor, but you forgot a ChangeLog :P
  
Maxim Cournoyer June 24, 2022, 2:50 p.m. UTC | #5
Hi,

Liliana Marie Prikler <liliana.prikler@gmail.com> writes:

> Am Donnerstag, dem 23.06.2022 um 22:53 -0400 schrieb Maxim Cournoyer:
>> Pushed as 2dc43d7d5b50b3ef6ef506dc2572c9cc3beed334, and salvaged
>> python-pycotap as 06902a6766f089e4da812876ddcf33e7ba8afce0 (with
>> improved synopsis and description).
> Totally minor, but you forgot a ChangeLog :P

Oh, and less minor, I broke the package in
39b118776bbbaed049f8bcafa27bde30d9d0b2f6.  Now fixed.

Apologies!

Maxim
  

Patch

diff --git a/gnu/packages/anthy.scm b/gnu/packages/anthy.scm
index 0d86347e88..b662d48d2c 100644
--- a/gnu/packages/anthy.scm
+++ b/gnu/packages/anthy.scm
@@ -48,7 +48,17 @@  (define-public anthy
          (replace 'check
            (lambda _
              (with-directory-excursion "test"
-               (invoke "./anthy" "--all")))))))
+               (invoke "./anthy" "--all"))))
+         (add-after 'unpack 'support-guix-anthy-home
+           (lambda _
+             ;; This is required to test ibus-anthy
+             (with-fluids ((%default-port-encoding "ISO-8859-1"))
+               (substitute* "src-diclib/conf.c"
+                 (("add_val\\(\"HOME\", pw->pw_dir")
+                  "char* home = getenv(\"GUIX_ANTHY_HOME\");
+if(home == NULL)
+  home = pw->pw_dir;
+add_val(\"HOME\", home"))))))))
     (home-page "https://anthy.osdn.jp/")
     (synopsis "Japanese input method")
     (description "Anthy is a Japanese input method for converting
diff --git a/gnu/packages/ibus.scm b/gnu/packages/ibus.scm
index edaeb59641..b8a17df4b5 100644
--- a/gnu/packages/ibus.scm
+++ b/gnu/packages/ibus.scm
@@ -52,10 +52,12 @@  (define-module (gnu packages ibus)
   #:use-module (gnu packages gnome)
   #:use-module (gnu packages gtk)
   #:use-module (gnu packages iso-codes)
+  #:use-module (gnu packages linux)
   #:use-module (gnu packages logging)
   #:use-module (gnu packages perl)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages python)
+  #:use-module (gnu packages python-check)
   #:use-module (gnu packages python-xyz)
   #:use-module (gnu packages python-web)
   #:use-module (gnu packages serialization)
@@ -307,7 +309,7 @@  (define-public libpinyin
 (define-public ibus-anthy
   (package
     (name "ibus-anthy")
-    (version "1.5.9")
+    (version "1.5.14")
     (source (origin
               (method url-fetch)
               (uri (string-append
@@ -315,7 +317,7 @@  (define-public ibus-anthy
                     version "/ibus-anthy-" version ".tar.gz"))
               (sha256
                (base32
-                "1y8sf837rmp662bv6zakny0xcm7c9c5qda7f9kq9riv9ywpcbw6x"))))
+                "16vd0k8wm13s38869jqs3dnwmjvywgn0snnpyi41m28binhlssf8"))))
     (build-system gnu-build-system)
     (arguments
      '(#:configure-flags
@@ -323,6 +325,46 @@  (define-public ibus-anthy
        (list (string-append "--libexecdir=" %output "/libexec"))
        #:phases
        (modify-phases %standard-phases
+         (add-after 'unpack 'fix-date
+           (lambda _
+             (substitute* "data/Makefile.in"
+               ;; The test would get the current year and check if its data
+               ;; contains it.  However, this will fail in the future, as
+               ;; running this test in a later year would fail.
+               ;; XXX: Future versions will have more recent years, change this
+               ;; to the most recent year in data/era.t (last line).
+               (("S_YEAR=.*;") "S_YEAR=2021;"))))
+         (add-before 'check 'pre-check
+           (lambda _
+             ;; Fix running ibus
+             (substitute* "tests/test-build.sh"
+               (("export GSETTINGS_SCHEMA_DIR=")
+                "export GSETTINGS_SCHEMA_DIR=$GSETTINGS_SCHEMA_DIR${GSETTINGS_SCHEMA_DIR:+:}")
+               (("export GI_TYPELIB_PATH=")
+                "export GI_TYPELIB_PATH=$GI_TYPELIB_PATH${GI_TYPELIB_PATH:+:}"))
+             ;; Do not wait for focus, but wait for the window to be available
+             (substitute* "tests/anthytest.py"
+               (("window =") "self.window =")
+               (("window\\.") "self.window.")
+               (("window.show_all\\(\\)")
+                "window.show_all()
+        GLib.idle_add(self.bring_to_front)
+
+    def bring_to_front(self):
+        self.window.present()"))))
+         (delete 'check)
+         (add-after 'install 'check
+           (lambda* (#:key tests? #:allow-other-keys)
+             (when tests?
+               (setenv "HOME" (getcwd))
+               (setenv "GUIX_ANTHY_HOME" (getcwd))
+               (setenv "XDG_DATA_HOME" (getcwd))
+               (setenv "XVFB_SERVER_ARGS" "+iglx -noreset")
+               (setenv "XDG_RUNTIME_DIR" (string-append (getcwd) "/runtime-dir"))
+               (mkdir-p (getenv "XDG_RUNTIME_DIR"))
+               (invoke "dbus-run-session" "--"
+                       "xvfb-run" "-a" "-s" (getenv "XVFB_SERVER_ARGS")
+                       "make" "check"))))
          (add-after 'install 'wrap-programs
            (lambda* (#:key outputs #:allow-other-keys)
              (let ((out (assoc-ref outputs "out")))
@@ -337,12 +379,18 @@  (define-public ibus-anthy
                 '("ibus-engine-anthy" "ibus-setup-anthy"))
                #t))))))
     (native-inputs
-     `(("gettext" ,gettext-minimal)
+     `(("dbus" ,dbus)
+       ("gettext" ,gettext-minimal)
+       ("glib" ,glib "bin") ;for glib-compile-schemas, used by tests
        ("intltool" ,intltool)
        ("pkg-config" ,pkg-config)
-       ("python" ,python)))
+       ("procps" ,procps)
+       ("python-pycotap" ,python-pycotap)
+       ("python-wrapper" ,python-wrapper)
+       ("util-linux" ,util-linux) ;for getopt, used by tests
+       ("xvfb-run" ,xvfb-run)))
     (inputs
-     (list anthy gtk+ ibus gobject-introspection python-pygobject))
+     (list anthy gdk-pixbuf gtk+ ibus gobject-introspection python-pygobject python-pycairo))
     (synopsis "Anthy Japanese language input method for IBus")
     (description "IBus-Anthy is an engine for the input bus \"IBus\").  It
 adds the Anthy Japanese language input method to IBus.  Because most graphical
diff --git a/gnu/packages/python-check.scm b/gnu/packages/python-check.scm
index 05a378601f..3d3067a770 100644
--- a/gnu/packages/python-check.scm
+++ b/gnu/packages/python-check.scm
@@ -2004,3 +2004,21 @@  (define-public python-xunitparser
 Python objects.  It tries to use the objects available in the standard
 @code{unittest} module.")
     (license license:expat)))
+
+(define-public python-pycotap
+  (package
+    (name "python-pycotap")
+    (version "1.2.2")
+    (source
+      (origin
+        (method url-fetch)
+        (uri (pypi-uri "pycotap" version))
+        (sha256
+          (base32 "1v69fxial9i5wlap6wc4igq3hydvxbak7dlgb7cikk8wjgafqf7r"))))
+    (build-system python-build-system)
+    (home-page "https://el-tramo.be/pycotap")
+    (synopsis "Tiny test runner that outputs TAP results to standard output.")
+    (description
+      "This package provides a tiny test runner that outputs TAP results to standard
+output.")
+    (license license:expat)))