poke-devel
[Top][All Lists]
Advanced

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

Re: master is broken due to latest changes to pk-mi-json


From: Jose E. Marchesi
Subject: Re: master is broken due to latest changes to pk-mi-json
Date: Sun, 28 Nov 2021 20:12:19 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

> I would still just skip() the tests that rely on comparing JSON objects
> if the json library doesn't provide a way to compare JSON objects.

I just pushed the patch below to this effect.
Salud!



    testsuite: fix poke-mi test driver to work with older versions of json-c
    
    2021-11-28  Jose E. Marchesi  <jemarch@gnu.org>
    
            * testsuite/poke.mi-json/mi-json.c (J_UND): Define.
            (test_val_to_json): Return J_UND if json_object_equal is not
            available.
            (test_json_file): Mark test as `unresolved' whenever appropriate.
            * poke/pk-mi-json.c (pk_json_object_object_add): Fix return value.

diff --git a/ChangeLog b/ChangeLog
index f4e5b8b6..59195245 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2021-11-28  Jose E. Marchesi  <jemarch@gnu.org>
+
+       * testsuite/poke.mi-json/mi-json.c (J_UND): Define.
+       (test_val_to_json): Return J_UND if json_object_equal is not
+       available.
+       (test_json_file): Mark test as `unresolved' whenever appropriate.
+       * poke/pk-mi-json.c (pk_json_object_object_add): Fix return value.
+
 2021-11-26  Jose E. Marchesi  <jemarch@gnu.org>
 
        * poke/pk-mi-json.c (pk_json_object_object_add): Define.
diff --git a/poke/pk-mi-json.c b/poke/pk-mi-json.c
index 61762f73..9886643c 100644
--- a/poke/pk-mi-json.c
+++ b/poke/pk-mi-json.c
@@ -43,7 +43,7 @@ pk_json_object_object_add (struct json_object* obj, const 
char *key,
 {
 #if JSON_C_MAJOR_VERSION == 0 && JSON_C_MINOR_VERSION < 13
   json_object_object_add (obj, key, val);
-  return J_OK;
+  return 0; /* Always success.  */
 #else
   return json_object_object_add (obj, key, val);
 #endif
diff --git a/testsuite/poke.mi-json/mi-json.c b/testsuite/poke.mi-json/mi-json.c
index b8b29fe6..00b9b086 100644
--- a/testsuite/poke.mi-json/mi-json.c
+++ b/testsuite/poke.mi-json/mi-json.c
@@ -35,8 +35,9 @@
 #include "../poke.libpoke/term-if.h"
 #include "pk-utils.h"
 
+#define J_NOK 0
 #define J_OK 1
-#define J_NOK 0 /* Not OK */
+#define J_UND 2
 
 void
 test_json_to_msg ()
@@ -236,6 +237,10 @@ test_val_to_json (pk_compiler pkc, const char *obj_str, 
pk_val val)
       return J_NOK;
     }
 
+  /* json_object_equal was introduced in libjson-c 0.13  */
+#if JSON_C_MAJOR_VERSION == 0 && JSON_C_MINOR_VERSION < 13
+  return J_UND;
+#else
   if (!json_object_equal (j_value, j_test))
     {
       printf ("json_object_equal () failed\n");
@@ -249,6 +254,7 @@ test_val_to_json (pk_compiler pkc, const char *obj_str, 
pk_val val)
 
       return J_NOK;
     }
+#endif
 
   return J_OK;
 }
@@ -259,7 +265,7 @@ test_json_file (const char *filename, FILE *ifp)
   const char *json_obj_str;
   pk_compiler pkc;
   pk_val val;
-  int should_fail;
+  int should_fail, ret;
 
   should_fail = strstr (filename, "fail") != NULL;
   pkc = pk_compiler_new (&poke_term_if);
@@ -279,8 +285,11 @@ test_json_file (const char *filename, FILE *ifp)
   if (test_json_to_val (pkc, json_obj_str, val) == J_NOK)
     goto error;
 
-  if (test_val_to_json (pkc, json_obj_str, val) == J_NOK)
+  ret = test_val_to_json (pkc, json_obj_str, val);
+  if (ret == J_NOK)
     goto error;
+  else if (ret == J_UND)
+    goto unresolved;
 
   pass (filename);
   return;
@@ -290,6 +299,10 @@ error:
     xfail (filename);
   else
     fail (filename);
+  return;
+
+ unresolved:
+  unresolved (filename);
 }
 
 void



reply via email to

[Prev in Thread] Current Thread [Next in Thread]