From 79659188464b3fba4bb497838f679bbb98f43d1a Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Thu, 26 Jul 2018 11:45:45 +0200 Subject: [PATCH] tests: fix self-dump validation --- src/context.c | 12 +++++++++--- src/types/decl_struct.c | 5 +++++ src/validate.c | 19 +++++++++++-------- tests/parser/dump001.phpt | 7 +++++-- 4 files changed, 30 insertions(+), 13 deletions(-) diff --git a/src/context.c b/src/context.c index d1f808c..449f98e 100644 --- a/src/context.c +++ b/src/context.c @@ -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]); + } } diff --git a/src/types/decl_struct.c b/src/types/decl_struct.c index d5309b9..fab2817 100644 --- a/src/types/decl_struct.c +++ b/src/types/decl_struct.c @@ -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; } diff --git a/src/validate.c b/src/validate.c index e7bceaf..2dfc3d4 100644 --- a/src/validate.c +++ b/src/validate.c @@ -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; } diff --git a/tests/parser/dump001.phpt b/tests/parser/dump001.phpt index 13e8a2f..441bec3 100644 --- a/tests/parser/dump001.phpt +++ b/tests/parser/dump001.phpt @@ -4,6 +4,8 @@ parse dump +--INI-- +psi.directory={PWD}/../../psi.d --FILE-- ===TEST=== ===DONE=== ---EXPECT-- +--EXPECTF-- ===TEST=== bool(true) bool(true) +int(%d) ===DONE=== --CLEAN--