[gtk/wip/compose-parser] tests: Fix composetable test in ci



commit 160919cc502d60ee37b31602e1704d04832b768f
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Jul 13 16:44:04 2021 -0400

    tests: Fix composetable test in ci
    
    We must arrange for the included Compose files to be found,
    by switching to the right directory beforehand.

 testsuite/gtk/compose/cycle   |  2 +-
 testsuite/gtk/compose/include |  2 +-
 testsuite/gtk/composetable.c  | 26 ++++++++++++++++++++++++--
 3 files changed, 26 insertions(+), 4 deletions(-)
---
diff --git a/testsuite/gtk/compose/cycle b/testsuite/gtk/compose/cycle
index b65eca834f..2f9a0c6a15 100644
--- a/testsuite/gtk/compose/cycle
+++ b/testsuite/gtk/compose/cycle
@@ -1,3 +1,3 @@
-include "testsuite/gtk/compose/cycle" # create an include cycle
+include "cycle" # create an include cycle
 
 <Multi_key> <s> <e> <q> : "!"
diff --git a/testsuite/gtk/compose/include b/testsuite/gtk/compose/include
index f69d7a79e7..d6c3ee7bb6 100644
--- a/testsuite/gtk/compose/include
+++ b/testsuite/gtk/compose/include
@@ -1,4 +1,4 @@
-include "testsuite/gtk/compose/included"   # see if this works
+include "included"   # see if this works
 
 <Multi_key> <s> <s> <s> : "!" # replace this entry
 <Multi_key> <a> <a> <a> : ""  # remove this entry
diff --git a/testsuite/gtk/composetable.c b/testsuite/gtk/composetable.c
index f852d43de6..49ed18c76b 100644
--- a/testsuite/gtk/composetable.c
+++ b/testsuite/gtk/composetable.c
@@ -1,6 +1,8 @@
 #include <gtk/gtk.h>
 #include <locale.h>
 
+#include <glib/gstdio.h>
+
 #include "../gtk/gtkcomposetable.h"
 #include "../gtk/gtkimcontextsimpleseqs.h"
 #include "testsuite/testutils.h"
@@ -107,13 +109,19 @@ compose_table_compare (gconstpointer data)
 {
   const char *basename = data;
   GtkComposeTable *table;
+  char *old_dir;
+  char *dir;
   char *file;
   char *expected;
   char *output;
   char *diff;
   GError *error = NULL;
 
-  file = g_build_filename (g_test_get_dir (G_TEST_DIST), "compose", basename, NULL);
+  old_dir = g_get_current_dir ();
+  dir = g_test_build_filename (G_TEST_DIST, "compose", NULL);
+  g_chdir (dir);
+
+  file = g_build_filename (dir, basename, NULL);
   expected = g_strconcat (file, ".expected", NULL);
 
   table = gtk_compose_table_parse (file);
@@ -130,7 +138,11 @@ compose_table_compare (gconstpointer data)
 
   g_free (output);
   g_free (file);
+  g_free (dir);
   g_free (expected);
+
+  g_chdir (old_dir);
+  g_free (old_dir);
 }
 
 static void
@@ -139,13 +151,23 @@ compose_table_cycle (void)
   if (g_test_subprocess ())
     {
       char *file;
+      char *dir;
+      char *old_dir;
       GtkComposeTable *table;
 
-      file = g_build_filename (g_test_get_dir (G_TEST_DIST), "compose", "cycle", NULL);
+      old_dir = g_get_current_dir ();
+      dir = g_test_build_filename (G_TEST_DIST, "compose", NULL);
+      g_chdir (dir);
+
+      file = g_build_filename (dir, "cycle", NULL);
 
       table = gtk_compose_table_parse (file);
       g_assert_nonnull (table);
       g_free (file);
+      g_free (dir);
+
+      g_chdir (old_dir);
+      g_free (old_dir);
 
       return;
     }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]