tests: fix self-dump validation
authorMichael Wallner <mike@php.net>
Thu, 26 Jul 2018 09:45:45 +0000 (11:45 +0200)
committerMichael Wallner <mike@php.net>
Thu, 26 Jul 2018 09:45:45 +0000 (11:45 +0200)
src/context.c
src/types/decl_struct.c
src/validate.c
tests/parser/dump001.phpt

index d1f808cb19512d076f90b4b024325d64ca25a9a8..449f98eef5699101aad1d4bb80eaadc52e612989 100644 (file)
@@ -324,8 +324,14 @@ void psi_context_free(struct psi_context **C)
 
 void psi_context_dump(struct psi_context *C, int fd)
 {
-       dprintf(fd, "// psi.engine=%s\n",
-                       (char *) C->ops->query(C, PSI_CONTEXT_QUERY_SELF, NULL));
+       size_t i;
+       struct psi_data *D;
 
-       psi_data_dump(fd, PSI_DATA(C));
+       dprintf(fd, "// psi.engine=%s\n// %lu files\n",
+                       (char *) C->ops->query(C, PSI_CONTEXT_QUERY_SELF, NULL),
+                       C->count);
+
+       for (i = 0; i < C->count; ++i) {
+               psi_data_dump(fd, &C->data[i]);
+       }
 }
index d5309b9cb041d95337bfe3cbd3db0286bed78f5b..fab2817669690c0ea7e208795d52eaf73f759f7e 100644 (file)
@@ -92,6 +92,11 @@ bool psi_decl_struct_validate(struct psi_data *data, struct psi_decl_struct *s,
        }
 
        if (!s->size && !psi_plist_count(s->args)) {
+               /* TODO: return true and check those structs are only used by address */
+               /* suppress needless warning
+               data->error(data, s->token, PSI_WARNING, "Empty struct %s",
+                               s->name);
+                               */
                return false;
        }
 
index e7bceafd845eb957ff6ea38e7b5ae5cf17b5bd00..2dfc3d46103b7d4a96be8069f19cdcf467670f3e 100644 (file)
@@ -203,17 +203,20 @@ bool psi_validate(struct psi_validate_scope *scope,
                }
 
                /* nothing changed; bail out */
-               if (count_all && (dst->flags & PSI_SILENT) && !(flags & PSI_SILENT)) {
-                       /* one last error-spitting round, if not explicitly suppressed */
-                       dst->flags ^= PSI_SILENT;
-                       check_count = ~0;
+               if (count_all) {
+                       src->errors += count_all;
 
-                       PSI_DEBUG_PRINT(dst, "PSI: validation bail out with %zu"
-                                       " type checks remaining, errors follow\n", count_all);
-                       continue;
+                       if ((dst->flags & PSI_SILENT) && !(flags & PSI_SILENT)) {
+                               /* one last error-spitting round, if not explicitly suppressed */
+                               dst->flags ^= PSI_SILENT;
+                               check_count = ~0;
+
+                               PSI_DEBUG_PRINT(dst, "PSI: validation bail out with %zu"
+                                               " type checks remaining, errors follow\n", count_all);
+                               continue;
+                       }
                }
 
-               src->errors += count_all;
                break;
        }
 
index 13e8a2f22e5e6ecffa8d3dd7e24796882b2eb12b..441bec3d7991ca94a9cd44cb2e121f0c72a74759 100644 (file)
@@ -4,6 +4,8 @@ parse dump
 <?php 
 extension_loaded("psi") or die("skip - need ext/psi");
 ?>
+--INI--
+psi.directory={PWD}/../../psi.d
 --FILE--
 ===TEST===
 <?php 
@@ -13,16 +15,17 @@ psi_dump($fd);
 fclose($fd);
 
 var_dump(file_exists($fn));
-var_dump(psi_validate($fn));
+var_dump(psi_validate($fn, 0, $e), $e);
 
 @unlink(__DIR__."/dump001.psi");
 
 ?>
 ===DONE===
---EXPECT--
+--EXPECTF--
 ===TEST===
 bool(true)
 bool(true)
+int(%d)
 ===DONE===
 --CLEAN--
 <?php