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 788561 - Document how to integrate GTest into your project
Document how to integrate GTest into your project
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: docs
unspecified
Other All
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2017-10-05 14:58 UTC by Emmanuele Bassi (:ebassi)
Modified: 2017-10-11 11:19 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Document how to integrate GTest into your project (3.59 KB, patch)
2017-10-05 14:58 UTC, Emmanuele Bassi (:ebassi)
none Details | Review
Document how to integrate GTest into your project (3.63 KB, patch)
2017-10-05 16:21 UTC, Emmanuele Bassi (:ebassi)
none Details | Review
Document how to integrate GTest into your project (3.83 KB, patch)
2017-10-11 09:05 UTC, Philip Withnall
committed Details | Review

Comment 1 Emmanuele Bassi (:ebassi) 2017-10-05 14:58:47 UTC
Created attachment 360968 [details] [review]
Document how to integrate GTest into your project

We are missing the documentation on how to use GTest inside a project.

While we mention in passing gtester and gtester-report, the reality is
that we don't tell anybody how to use them inside their own build
system. Additionally, gtester and gtester-report are deprecated and kind
of abandoned, in favour of tools native to common build systems, such as
the TAP harness in Autotools, and the test harness in Meson.

See also:

  https://stackoverflow.com/questions/19958861/how-to-properly-set-up-glib-testing-framework-with-autotools
Comment 2 Philip Withnall 2017-10-05 15:34:56 UTC
Review of attachment 360968 [details] [review]:

::: glib/gtestutils.c
@@ +178,3 @@
+ *
+ * If your test loads files using g_test_build_filename(), you will also need
+ * to define the environment necessary for GTest to find those files, e.g.:

I think it’s probably simpler to combine the two examples and unconditionally define G_TEST_{SRCDIR,BUILDDIR}, since they’re needed fairly commonly, and if they’re not initially defined by the build system, people might forget about them and come up with some ad-hoc hack instead.

@@ +197,3 @@
+ *   - [glib-tap.mk](https://git.gnome.org/browse/glib/tree/glib-tap.mk)
+ *   - [tap-test](https://git.gnome.org/browse/glib/tree/tap-test)
+ *   - [tap-driver.sh](https://git.gnome.org/browse/glib/tree/tap-driver.sh)

tap-driver.sh and tap-test need to be listed in EXTRA_DIST somewhere. (glib-tap.mk does not.)
Comment 3 Emmanuele Bassi (:ebassi) 2017-10-05 16:21:31 UTC
Created attachment 360972 [details] [review]
Document how to integrate GTest into your project

We are missing the documentation on how to use GTest inside a project.

While we mention in passing gtester and gtester-report, the reality is
that we don't tell anybody how to use them inside their own build
system. Additionally, gtester and gtester-report are deprecated and kind
of abandoned, in favour of tools native to common build systems, such as
the TAP harness in Autotools, and the test harness in Meson.

See also:

  https://stackoverflow.com/questions/19958861/how-to-properly-set-up-glib-testing-framework-with-autotools
Comment 4 Philip Withnall 2017-10-06 09:51:32 UTC
Review of attachment 360972 [details] [review]:

Looks good to push with this change. Thanks!

::: glib/gtestutils.c
@@ +216,3 @@
+ * Make sure you add `tap-driver.sh` and `tap-test` to the `EXTRA_DIST`
+ * clause in your project, so they will be part of the distributable
+ * archive.

Probably better to put this in the example code above (as `EXTRA_DIST += \ tap-driver.sh \ tap-test`) or people will copy-paste the code above and miss this paragraph.
Comment 5 Emmanuele Bassi (:ebassi) 2017-10-06 10:22:45 UTC
(In reply to Philip Withnall from comment #4)
> Review of attachment 360972 [details] [review] [review]:
> 
> Looks good to push with this change. Thanks!
> 
> ::: glib/gtestutils.c
> @@ +216,3 @@
> + * Make sure you add `tap-driver.sh` and `tap-test` to the `EXTRA_DIST`
> + * clause in your project, so they will be part of the distributable
> + * archive.
> 
> Probably better to put this in the example code above (as `EXTRA_DIST += \
> tap-driver.sh \ tap-test`) or people will copy-paste the code above and miss
> this paragraph.

Unless we use:

```
EXTRA_DIST = $(top_srcdir)/tap-driver.sh $(top_srcdir)/tap-test
```

we can't really do this, because the files reside in the top-level. I'm not entirely sure how this will work with recursive Make, and I'm not going to suggest a non-recursive set up.
Comment 6 Philip Withnall 2017-10-06 10:43:26 UTC
(In reply to Emmanuele Bassi (:ebassi) from comment #5)
> (In reply to Philip Withnall from comment #4)
> > Review of attachment 360972 [details] [review] [review] [review]:
> > 
> > Looks good to push with this change. Thanks!
> > 
> > ::: glib/gtestutils.c
> > @@ +216,3 @@
> > + * Make sure you add `tap-driver.sh` and `tap-test` to the `EXTRA_DIST`
> > + * clause in your project, so they will be part of the distributable
> > + * archive.
> > 
> > Probably better to put this in the example code above (as `EXTRA_DIST += \
> > tap-driver.sh \ tap-test`) or people will copy-paste the code above and miss
> > this paragraph.
> 
> Unless we use:
> 
> ```
> EXTRA_DIST = $(top_srcdir)/tap-driver.sh $(top_srcdir)/tap-test
> ```
> 
> we can't really do this, because the files reside in the top-level. I'm not
> entirely sure how this will work with recursive Make, and I'm not going to
> suggest a non-recursive set up.

I was assuming non-recursive automake, since that’s the recommended way of autotooling yourself. Why would you not suggest it? You could put the EXTRA_DIST example in a separate code block and say to put it in the top-level Makefile.am.
Comment 7 Philip Withnall 2017-10-11 09:05:44 UTC
Created attachment 361302 [details] [review]
Document how to integrate GTest into your project

We are missing the documentation on how to use GTest inside a project.

While we mention in passing gtester and gtester-report, the reality is
that we don't tell anybody how to use them inside their own build
system. Additionally, gtester and gtester-report are deprecated and kind
of abandoned, in favour of tools native to common build systems, such as
the TAP harness in Autotools, and the test harness in Meson.

See also:

  https://stackoverflow.com/questions/19958861/how-to-properly-set-up-glib-testing-framework-with-autotools
Comment 8 Philip Withnall 2017-10-11 09:06:12 UTC
Here’s an updated patch with my suggestion incorporated. What do you think?
Comment 9 Emmanuele Bassi (:ebassi) 2017-10-11 10:26:14 UTC
Review of attachment 361302 [details] [review]:

Looks good; thanks for the update.
Comment 10 Philip Withnall 2017-10-11 11:19:49 UTC
Attachment 361302 [details] pushed as 17e29be - Document how to integrate GTest into your project