After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 720263 - gtestutils: skipping a test should count as success, not failure
gtestutils: skipping a test should count as success, not failure
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
: 709894 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2013-12-11 15:33 UTC by Dan Winship
Modified: 2014-01-23 00:08 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gtestutils: skipping a test should count as success, not failure (1.50 KB, patch)
2013-12-11 15:33 UTC, Dan Winship
committed Details | Review
gtestutils: rename test_skip_count to test_startup_skip_count (1.71 KB, patch)
2013-12-18 15:09 UTC, Dan Winship
committed Details | Review
Make g_test_run() return 77 if all tests are skipped (5.21 KB, patch)
2013-12-18 15:09 UTC, Dan Winship
committed Details | Review

Description Dan Winship 2013-12-11 15:33:23 UTC
In particular, the test program as a whole should exit with status 0
if you skipped some tests but did not fail any.
Comment 1 Dan Winship 2013-12-11 15:33:28 UTC
Created attachment 263990 [details] [review]
gtestutils: skipping a test should count as success, not failure
Comment 2 Allison Karlitskaya (desrt) 2013-12-11 16:38:43 UTC
Review of attachment 263990 [details] [review]:

Agreed with this patch, but there is another bug here.

The overall return value from g_test_run() is the number of failed tests, even if this number is 77.  We should probably fix that to never return 77, and then return 77 in the case that all tests were skipped.
Comment 3 Dan Winship 2013-12-18 15:09:55 UTC
Created attachment 264483 [details] [review]
gtestutils: rename test_skip_count to test_startup_skip_count
Comment 4 Dan Winship 2013-12-18 15:09:57 UTC
Created attachment 264484 [details] [review]
Make g_test_run() return 77 if all tests are skipped

Change g_test_run() to return 1 on failure (rather than the number of
failed tests), and 77 if all tests are skipped (since automake and
some other test harnesses recognize that status code).

Previously g_test_run() returned the number of failed tests, but this
behavior was not documented, and at any rate, prior to 2.39,
g_test_run() would normally not return at all if an error occurred.
Comment 5 Allison Karlitskaya (desrt) 2013-12-18 16:12:55 UTC
Review of attachment 264484 [details] [review]:

::: glib/gtestutils.c
@@ +1531,3 @@
+    return 1;
+
+  if (test_run_count > 0 && test_run_count == test_skipped_count)

Why specifically check this?

It's easy to imagine some situation like so:

main ()
{
  test_init()

  if (cond) { add tests; }
  if (other_cond) { add tests; }

  return test_run();
}

where no tests actually get added.  In that case, I'd actually expect to see the 77.

On the other hand, this could be considered an incompatible change because it would cause a process that used to return 0 to start returning 77... some users of gtester who are not "77-aware" might be hit by that...
Comment 6 Allison Karlitskaya (desrt) 2013-12-18 16:13:25 UTC
Review of attachment 264483 [details] [review]:

Makes sense if we decide to commit the other one, but please wait until then.
Comment 7 Allison Karlitskaya (desrt) 2013-12-18 16:28:00 UTC
Review of attachment 264484 [details] [review]:

11:25 < danw> desrt: because really you should do the perf check inside the test and call g_test_skip() if you're 
              skipping, so that it shows up as skipped in the output and the user is made aware that there are tests 
              that are not being run
11:26 < danw> desrt: you could make an argument for any of the three return values when there are no test cases...
11:27 < desrt> so i guess we can allow the argument of 'preserve current behaviour' to prevail
Comment 8 Dan Winship 2013-12-18 16:29:36 UTC
Attachment 263990 [details] pushed as 8c188fc - gtestutils: skipping a test should count as success, not failure
Attachment 264483 [details] pushed as 10d82f9 - gtestutils: rename test_skip_count to test_startup_skip_count
Attachment 264484 [details] pushed as fab0805 - Make g_test_run() return 77 if all tests are skipped
Comment 9 Dan Winship 2014-01-22 17:43:42 UTC
*** Bug 709894 has been marked as a duplicate of this bug. ***
Comment 10 Ross Burton 2014-01-23 00:08:03 UTC
Any chance of this being backported into the 2.38 branch?