mirror of
https://github.com/libgit2/libgit2.git
synced 2026-06-22 06:26:26 +00:00
clar: iterate errors in report_all / report_errors
Instead of trying to have a clever iterator pattern that increments the error number, just iterate over errors in the report errors or report all functions as it's easier to reason about in this fashion.
This commit is contained in:
34
tests/clar.c
34
tests/clar.c
@@ -217,32 +217,28 @@ void cl_trace_register(cl_trace_cb *cb, void *payload)
|
||||
|
||||
/* Core test functions */
|
||||
static void
|
||||
clar_report(int *i, struct clar_error *error)
|
||||
{
|
||||
while (error != NULL) {
|
||||
clar_print_error((*i)++, _clar.last_report, error);
|
||||
error = error->next;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
clar_report_errors(struct clar_error *error)
|
||||
clar_report_errors(struct clar_report *report)
|
||||
{
|
||||
struct clar_error *error;
|
||||
int i = 1;
|
||||
clar_report(&i, error);
|
||||
|
||||
for (error = report->errors; error; error = error->next)
|
||||
clar_print_error(i++, _clar.last_report, error);
|
||||
}
|
||||
|
||||
static void
|
||||
clar_report_all(void)
|
||||
{
|
||||
int i = 1;
|
||||
struct clar_report *report;
|
||||
struct clar_error *error;
|
||||
int i = 1;
|
||||
|
||||
report = _clar.reports;
|
||||
while (report != NULL) {
|
||||
if (report->status == CL_TEST_FAILURE)
|
||||
clar_report(&i, report->errors);
|
||||
report = report->next;
|
||||
for (report = _clar.reports; report; report = report->next) {
|
||||
if (report->status != CL_TEST_FAILURE)
|
||||
continue;
|
||||
|
||||
for (error = report->errors; error; error = error->next)
|
||||
clar_print_error(i++, report, error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,7 +281,7 @@ clar_run_test(
|
||||
_clar.local_cleanup_payload = NULL;
|
||||
|
||||
if (_clar.report_errors_only) {
|
||||
clar_report_errors(_clar.last_report->errors);
|
||||
clar_report_errors(_clar.last_report);
|
||||
} else {
|
||||
clar_print_ontest(test->name, _clar.tests_ran, _clar.last_report->status);
|
||||
}
|
||||
@@ -576,7 +572,7 @@ static void abort_test(void)
|
||||
if (!_clar.trampoline_enabled) {
|
||||
clar_print_onabort(
|
||||
"Fatal error: a cleanup method raised an exception.");
|
||||
clar_report_errors(_clar.last_report->errors);
|
||||
clar_report_errors(_clar.last_report);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user