summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Kushnir <igorkuo@gmail.com>2021-10-11 20:32:26 +0300
committerIgor Kushnir <igorkuo@gmail.com>2021-10-11 21:02:24 +0300
commitd64963b0e57c37739c41b973ec1af410a594f0e6 (patch)
treec515d97c9744f10d29bbc413b71c7801cf207b16
parent1c521abcb7a6f8319ad5cfd9f3138ab12b39d5f0 (diff)
test-mime-data: fail when an error occurs
This change should prevent test file omissions like the one fixed in https://gitlab.freedesktop.org/xdg/shared-mime-info/-/commit/66c73d06805f1e8613bb44cf97de1f223971c60c Always print summary. The condition (error > 0 || failed > 0) was incomplete: xmatch > 0 should have been checked as well. shared-mime-info's test_mime.sh passes a list with many expected failures to test-mime-data, so the condition failed > 0 is always true. Therefore printing the summary unconditionally makes no difference, unless there are other users of test-mime-data that don't have expected failures in their test case lists.
-rw-r--r--src/test-mime-data.c27
1 files changed, 10 insertions, 17 deletions
diff --git a/src/test-mime-data.c b/src/test-mime-data.c
index 1dbc636..df5a650 100644
--- a/src/test-mime-data.c
+++ b/src/test-mime-data.c
@@ -312,22 +312,15 @@ main (int argc, char *argv[])
read_from_file (argv[i]);
}
- if (error > 0 || failed > 0)
- {
- printf ("%d errors, %d comparisons, %d failed",
- error, total, failed);
- if (xfailed > 0)
- printf (" (%d expected)", xfailed);
- if (xmatch > 0)
- printf (", %d unexpected successes", xmatch);
- printf ("\n");
-
- if (xmatch > 0)
- return 1;
- if (xfailed == failed)
- return 0;
- return 1;
- }
-
+ printf ("%d errors, %d comparisons, %d failed",
+ error, total, failed);
+ if (xfailed > 0)
+ printf (" (%d expected)", xfailed);
+ if (xmatch > 0)
+ printf (", %d unexpected successes", xmatch);
+ printf ("\n");
+
+ if (error > 0 || xmatch > 0 || failed != xfailed)
+ return 1;
return 0;
}