unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Julien Lepiller <julien@lepiller.eu>
To: Taiju HIGASHI <higashi@taiju.info>
Cc: 52576@debbugs.gnu.org, Liliana Marie Prikler <liliana.prikler@gmail.com>
Subject: [bug#52576] About the upgrade of ibus-anthy
Date: Mon, 7 Feb 2022 15:50:16 +0100	[thread overview]
Message-ID: <20220207155016.1381bf8c@tachikoma.lepiller.eu> (raw)
In-Reply-To: <87v8xr1iph.fsf@taiju.info>

[-- Attachment #1: Type: text/plain, Size: 3080 bytes --]

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.

[-- Attachment #2: ibus-anthy.diff --]
[-- Type: text/x-patch, Size: 6612 bytes --]

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)))

  reply	other threads:[~2022-02-07 15:21 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-17 13:40 [bug#52576] [PATCH] gnu: ibus-anthy: Update to 1.15.12 Taiju HIGASHI
2021-12-17 16:54 ` Taiju HIGASHI
2021-12-22 22:20 ` Ludovic Courtès
2021-12-23  5:44   ` Taiju HIGASHI
2021-12-24  9:25   ` Taiju HIGASHI
2021-12-24  9:33   ` Taiju HIGASHI
2021-12-24 23:18 ` [bug#52576] [PATCH v2] gnu: ibus-anthy: Update to 1.5.14 Taiju HIGASHI
2022-02-06 15:56 ` [bug#52576] About the upgrade of ibus-anthy Taiju HIGASHI
2022-02-06 20:51   ` Liliana Marie Prikler
2022-02-07  3:03     ` Taiju HIGASHI
2022-02-07 14:50       ` Julien Lepiller [this message]
2022-02-07 15:51         ` Taiju HIGASHI
2022-06-24  2:53         ` bug#52576: [PATCH] gnu: ibus-anthy: Update to 1.15.12 Maxim Cournoyer
2022-06-24  3:10           ` [bug#52576] " Taiju HIGASHI
2022-06-24  4:21           ` Liliana Marie Prikler
2022-06-24 14:50             ` Maxim Cournoyer
2022-06-28  8:43 ` Alice BRENON
2022-06-29  8:50   ` Taiju HIGASHI
2022-06-29  9:25     ` Taiju HIGASHI
2022-06-29 13:46       ` Alice BRENON
2022-06-29 14:06         ` Taiju HIGASHI
2022-06-29 14:19           ` Taiju HIGASHI
2022-06-29 14:35             ` Alice BRENON
2022-06-29 14:49               ` Taiju HIGASHI
2022-06-29 14:56                 ` Taiju HIGASHI
2022-06-30  2:25               ` Maxim Cournoyer
2022-06-30 20:15                 ` Alice BRENON
2022-07-01  4:22                 ` Liliana Marie Prikler
2022-07-02  0:14                   ` Liliana Marie Prikler
2022-07-03  1:13                     ` Dominic Martinez

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://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220207155016.1381bf8c@tachikoma.lepiller.eu \
    --to=julien@lepiller.eu \
    --cc=52576@debbugs.gnu.org \
    --cc=higashi@taiju.info \
    --cc=liliana.prikler@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/guix.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).