From: Simon McVittie Date: Wed, 15 Dec 2021 12:31:54 +0000 (+0000) Subject: test: Avoid misleading diagnostic when some tests are skipped X-Git-Tag: dbus-1.13.20~5^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fedb33179ec43606497b3f27ab8e8aaf35e799d2;p=thirdparty%2Fdbus.git test: Avoid misleading diagnostic when some tests are skipped If we have 7 test-cases, of which we ran 3 and skipped 4, then it's misleading to say "7 tests passed". Diagnose this as "3 tests passed (4 skipped)" instead. We can either skip tests by putting a specific test name on the test command-line, or programmatically (for example the fd-passing test is always skipped on Windows, because Windows cannot implement Unix fd-passing). Resolves: https://gitlab.freedesktop.org/dbus/dbus/-/issues/363 Signed-off-by: Simon McVittie --- diff --git a/dbus/dbus-test-tap.c b/dbus/dbus-test-tap.c index 46738de72..3e763d4b1 100644 --- a/dbus/dbus-test-tap.c +++ b/dbus/dbus-test-tap.c @@ -39,6 +39,7 @@ #include static unsigned int failures = 0; +static unsigned int skipped = 0; static unsigned int tap_test_counter = 0; /* @@ -148,6 +149,7 @@ _dbus_test_skip (const char *format, va_list ap; printf ("ok %u # SKIP ", ++tap_test_counter); + ++skipped; va_start (ap, format); vprintf (format, ap); va_end (ap); @@ -194,10 +196,14 @@ _dbus_test_check_memleaks (const char *test_name) int _dbus_test_done_testing (void) { + _dbus_assert (skipped <= tap_test_counter); + if (failures == 0) - _dbus_test_diag ("%u tests passed", tap_test_counter); + _dbus_test_diag ("%u tests passed (%d skipped)", + tap_test_counter - skipped, skipped); else - _dbus_test_diag ("%u/%u tests failed", failures, tap_test_counter); + _dbus_test_diag ("%u/%u tests failed (%d skipped)", + failures, tap_test_counter - skipped, skipped); printf ("1..%u\n", tap_test_counter); fflush (stdout);