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 d1f808c..449f98e 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 d5309b9..fab2817 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 e7bceaf..2dfc3d4 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 13e8a2f..441bec3 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