mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2024-12-18 08:22:13 +00:00
Improved testsuite diagnostics
This commit is contained in:
parent
79b8435877
commit
628ed253b3
1 changed files with 32 additions and 6 deletions
30
test.c
30
test.c
|
@ -802,7 +802,7 @@ void task_destroy(const char *curdir) {
|
||||||
* using the template passed into it for call-flags and user defined
|
* using the template passed into it for call-flags and user defined
|
||||||
* messages.
|
* messages.
|
||||||
*/
|
*/
|
||||||
bool task_execute(task_template_t *template) {
|
bool task_execute(task_template_t *template, char ***line) {
|
||||||
bool success = false;
|
bool success = false;
|
||||||
FILE *execute;
|
FILE *execute;
|
||||||
char buffer[4096];
|
char buffer[4096];
|
||||||
|
@ -866,6 +866,12 @@ bool task_execute(task_template_t *template) {
|
||||||
* implementing multi-line match is TODO.
|
* implementing multi-line match is TODO.
|
||||||
*/
|
*/
|
||||||
success = !!!(strcmp(data, template->comparematch[compare++]));
|
success = !!!(strcmp(data, template->comparematch[compare++]));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copy to output vector for diagnostics if execution match
|
||||||
|
* fails.
|
||||||
|
*/
|
||||||
|
vec_push(*line, data);
|
||||||
}
|
}
|
||||||
mem_d(data);
|
mem_d(data);
|
||||||
data = NULL;
|
data = NULL;
|
||||||
|
@ -883,6 +889,7 @@ bool task_execute(task_template_t *template) {
|
||||||
void task_schedualize() {
|
void task_schedualize() {
|
||||||
bool execute = false;
|
bool execute = false;
|
||||||
char *data = NULL;
|
char *data = NULL;
|
||||||
|
char **match = NULL;
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
|
@ -949,12 +956,31 @@ void task_schedualize() {
|
||||||
* If we made it here that concludes the task is to be executed
|
* If we made it here that concludes the task is to be executed
|
||||||
* in the virtual machine.
|
* in the virtual machine.
|
||||||
*/
|
*/
|
||||||
if (!task_execute(task_tasks[i].template)) {
|
if (!task_execute(task_tasks[i].template, &match)) {
|
||||||
|
size_t d = 0;
|
||||||
|
|
||||||
con_err("test failure: `%s` [%s] (invalid results from execution)\n",
|
con_err("test failure: `%s` [%s] (invalid results from execution)\n",
|
||||||
task_tasks[i].template->description,
|
task_tasks[i].template->description,
|
||||||
(task_tasks[i].template->failuremessage) ?
|
(task_tasks[i].template->failuremessage) ?
|
||||||
task_tasks[i].template->failuremessage : "unknown"
|
task_tasks[i].template->failuremessage : "unknown"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Print nicely formatted expected match lists to console error
|
||||||
|
* handler for the all the given matches in the template file and
|
||||||
|
* what was actually returned from executing.
|
||||||
|
*/
|
||||||
|
con_err(" Expected From %u Matches:\n", vec_size(task_tasks[i].template->comparematch));
|
||||||
|
for (; d < vec_size(task_tasks[i].template->comparematch); d++) {
|
||||||
|
char *select = task_tasks[i].template->comparematch[d];
|
||||||
|
size_t length = 40 - strlen(select);
|
||||||
|
|
||||||
|
con_err(" Expected: \"%s\"", select);
|
||||||
|
while (length --)
|
||||||
|
con_err(" ");
|
||||||
|
con_err("| Got: \"%s\"\n", (d >= vec_size(match)) ? "<<nothing else to compare>>" : match[d]);
|
||||||
|
}
|
||||||
|
vec_free(match);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue