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 752123 - harness: don't run code inside g_assert()
harness: don't run code inside g_assert()
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
git master
Other Linux
: Normal enhancement
: 1.5.90
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-07-08 13:01 UTC by Luis de Bethencourt
Modified: 2015-08-16 13:40 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
proposed patch (10.32 KB, patch)
2015-07-08 13:01 UTC, Luis de Bethencourt
committed Details | Review

Description Luis de Bethencourt 2015-07-08 13:01:59 UTC
Created attachment 307072 [details] [review]
proposed patch

Submitting this here for review in case anybody is against it.
Comment 1 Olivier Crête 2015-07-08 16:14:43 UTC
Disabling asserts in unit tests makes no sense.
Comment 2 Sebastian Dröge (slomo) 2015-07-08 16:17:34 UTC
Doing things with side-effects in assertions is generally bad style though
Comment 3 Tim-Philipp Müller 2015-07-08 16:23:15 UTC
Not clear to me this is a huge improvement over the existing code. And in case something does fail you now get less information printed (just the variable name, not the function plus parameters).
Comment 4 Luis de Bethencourt 2015-07-08 17:02:55 UTC
Olivier, in the case of GstHarness you can't disable them. They are forced in.

Sebastian, I agree. Also strange to read.

Tim, OH! didn't realize this.

As it stands I feel inclined to mark this as rejected. Keeping it open for a little while so other people can comment.
Comment 5 Olivier Crête 2015-07-08 17:48:58 UTC
Could use the fail_unless() from gstcheck instead ?
Comment 6 Sebastian Dröge (slomo) 2015-07-08 18:18:13 UTC
Yeah, fail_unless() would be nicer than g_assert(). Some of our other unit tests using g_assert() always annoys me ;)
Comment 7 Håvard Graff (hgr) 2015-07-08 18:21:34 UTC
However, there is a difference in fail_unless and g_assert in that fail_unless will keep going (in some cases) where g_assert will stop. Now, when writing a test fail_unless is always the right answer, but you are not "testing" the code inside the harness, and this is never supposed to fail, hence the assert.
Comment 8 Luis de Bethencourt 2015-08-05 12:29:23 UTC
Review of attachment 307072 [details] [review]:

Marking the patch as rejected.
Comment 9 Luis de Bethencourt 2015-08-05 13:09:05 UTC
Review of attachment 307072 [details] [review]:

After some discussion in IRC. It was decided to push this change.

commit 60de1f26c78feb0cde6d3f82cf86cf35daa71cc0
Author: Luis de Bethencourt <luis@debethencourt.com>
Date:   Wed Aug 5 14:05:25 2015 +0100

    harness: don't run code inside g_assert

    Even though asserts can't be disabled in GstHarness, Coverity still
    complains about running code inside them. Moving the code to outside the
    g_asserts().

    CID #1311326, #1311327, #1311328
Comment 10 Luis de Bethencourt 2015-08-05 13:09:09 UTC
Review of attachment 307072 [details] [review]:

After some discussion in IRC. It was decided to push this change.

commit 60de1f26c78feb0cde6d3f82cf86cf35daa71cc0
Author: Luis de Bethencourt <luis@debethencourt.com>
Date:   Wed Aug 5 14:05:25 2015 +0100

    harness: don't run code inside g_assert

    Even though asserts can't be disabled in GstHarness, Coverity still
    complains about running code inside them. Moving the code to outside the
    g_asserts().

    CID #1311326, #1311327, #1311328