Add unit testing to a gtk C application

Hi,

I would like to add testing to a project that use glib in C.

I found GLib – 2.0: Testing Framework
I’m using glib version installed on my system: libglib2.0-dev:amd64 2.64.6-1~ubuntu20.04.4

I found /usr/share/automake-1.16/tap-driver.sh
But I didn’t found none of glib-tap.mk nor tap-test file mentioned in the doc.
I did look into git cloned repository: HEAD detached at 2.64.6 not here.

It seems to have been removed at some point. was here in version 2.58

How does it work, now?
Could you give me to useful links?
Or could someone point me to some code repository with some test suite already in place?

I would add non-regression automated tests on some complex data structure manipulation involving double linked list and a dynamic array of index pointing to list element. It is not for GUI testing.

Regards,
Sylvain.

We strongly encourage you to use Meson, instead of Autotools.

Nevertheless, the various Autotools-related files shouldn’t have been removed, just like we didn’t remove the m4 macros.

In any case, you can effectively download the glib-tap.mk and tap-test files from the 2.58 tag: they have not been changed, and won’t ever be changed anyway. The tap-driver.sh script from Automake can be re-used.

When using Meson, we use the test function with a binary built using the GLib testing API, using the protocol: 'tap' argument. GLib’s testing API defaults to the Test Anything Protocol for its output, and Meson has a native TAP harness.

1 Like

Hi @ebassi,

Thanks for the detail.

The project I’m modifying is autotools based, so that was my concern to keep it “simple”.
But it won’t be simple. :thinking:

Could you update the glib documentation about testing with link to the correct source file?
I mean add URL link to the removed files: glib-tap.mk, tap-test and tap-driver.sh. + add a deprecation warning.

Should I contribute and edit that myself somewhere?

I will explore more, thanks.

I wish I could post URL to help other reader but discourse is blocking my new user, you will have copy them manually.

My learning path will be:

  • meson building suite: your link above
  • a sample of code using glib C + meson + testing: (may be some example in the glib test folder?)
  • may be a sample a code using glib C + autotools + tap testing (https://stackoverflow.com/questions/19958861/how-to-properly-set-up-glib-testing-framework-with-autotools 6 years old answer you already produced :wink: )
  • autotools may be: (https://www.gnu.org/software/automake/manual/html_node/Use-TAP-with-the-Automake-test-harness.html (may be deprecated or mandatory within the project I’m modifying)
  • migration from autotools to meson: Porting from Autotools

Regards,
Sylvain.

This was already done 2 years ago, so it seems that there’s a problem in rendering the links in the new version of the documentation. @ebassi, any ideas? Is GLib doing something invalid in Markdown?

No, I think I just missed out the links when I turned the documentation into a separate markdown file for docs.gtk.org.

The links should now be fixed; the online docs will update at the end of the CI pipeline.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.