Commit Graph

344 Commits

Author SHA1 Message Date
Simon McVittie
86d4da1634 gobject: Add a test for deprecated properties
Reproduces: https://gitlab.gnome.org/GNOME/glib/-/issues/2748
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-09-21 10:27:55 +01:00
Marco Trevisan
22f0522c10 Merge branch 'mcatanzaro/gtype-criticals' into 'main'
Replace most GObject warnings with criticals

See merge request GNOME/glib!2852
2022-09-19 14:35:12 +00:00
Sebastian Dröge
d41b5bf999 Revert "Merge branch 'wip/smcv/deprecated-construct-prop' into 'main'"
This reverts merge request !2888
2022-09-13 11:20:03 +00:00
Simon McVittie
fef0408eaa gobject: Add a test for deprecated properties
Reproduces: https://gitlab.gnome.org/GNOME/glib/-/issues/2748
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-09-13 11:20:45 +01:00
Emmanuele Bassi
903c004b37 Fix array-bounds compiler warnings with GCC 12
GCC isn't smart enough to recognise that the assertion on the size of
N_PROPERTIES also affects the assertion on the GParamSpec array access,
so we need to coalesce the two checks into one to avoid an array-bounds
compiler warning.
2022-09-02 12:46:57 +01:00
Michael Catanzaro
0ffe86a1f7 Replace most GObject warnings with criticals
All of these warnings indicate programmer error, so critical is most
appropriate here.

Exceptions: deprecation warnings are just warnings. Also, warnings that
are worded with uncertainty can remain warnings rather than criticals.
2022-08-09 13:18:47 -05:00
Emmanuele Bassi
8f68c1e646 Rename G_MARKUP_PARSE_FLAGS_NONE
The prefix for GMarkupParseFlags enumeration members is G_MARKUP; this
means that G_MARKUP_PARSE_FLAGS_NONE gets split into
GLib.MarkupParseFlags.PARSE_FLAGS_NONE by the introspection scanner.

The `/*< nick=none >*/` trigraph attribute is a glib-mkenum thing, and
does not affect the introspection scanner; it would also only affect the
GEnumValue nickname, which is not used by language bindings to resolve
the name of the enumeration member. Plus, GMarkupParseFlags does not
have a corresponding GType anyway.
2022-07-25 22:30:22 +01:00
Simon McVittie
72868c026d gobject/tests/performance: Only run a quick version as installed-tests
ginsttest-runner defaults to timing out each test after 5 minutes,
but gobject/tests/performance/performance.c defaults to running each
of 18 tests for 15 seconds. The result is close enough to 5 minutes
that the setup overhead is enough to make it time out.

We're only running these tests to prove that they still work, not to
get meaningful performance numbers, so cut them down to 1 second per
test-case (the result of which is that performance.c takes about a
minute).

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-07-24 17:34:55 +01:00
Simon McVittie
0714bcb7f4 gobject/tests/performance: Use the other installed-tests template
These are not GTest tests, and don't output TAP.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-07-24 17:15:47 +01:00
James Hilliard
d0b9ebbaac meson: fix build without cpp toolchain
We don't need a cpp toolchain for building glib so lets just
automatically disable tests requiring one when not available.

Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
2022-07-15 12:58:41 -06:00
Marco Trevisan (Treviño)
28dc989fc1 gobject/tests: Add test to verify that custom dispatch is called on init
As per this, rename the old test so that it's more in line with the
new one and with what it does.
2022-07-09 00:24:13 +02:00
Marco Trevisan (Treviño)
ed130c8d3b gobject/tests/custom-dispatch: Mark the foo property as explicit-notify
We're calling g_object_notify so let's not make gobject to call it for
us.

This also allows to test that changing a property again doesn't lead to
dispatch properties being called.
2022-07-08 23:54:43 +02:00
Matthias Clasen
edcd2d4df4 Add a test for custom dispatch_properties_changed
This tests that we call a custom dispatch_properties_changed,
even in the absence of connected notify handlers. (A recent
optimization broke that and caused a regression in GTK).
2022-07-08 14:03:34 +01:00
Philip Withnall
ed564b71dd Merge branch '2672-dataset-tests-and-fixes' into 'main'
gdataset: Preserve destruction order

Closes #2672 and #2676

See merge request GNOME/glib!2776
2022-07-07 11:52:19 +00:00
Philip Withnall
41691cc4c8 Merge branch 'more-spdx' into 'main'
Add more SPDX license headers

See merge request GNOME/glib!2706
2022-07-05 11:06:49 +00:00
Peter Bloomfield
4ef2025d47 gobject/tests/binding: Add a test with run-dispose
Add tests in which `g_object_run_dispose()` is called on the source or target
of a `GBinding`. After commit a4fa456e67,
the target test caused a failed assertion in `g_weak_ref_set()` that was not
found by the existing tests.  Commit 94ba14d542
weakens the assertion to allow the test to succeed.

See https://gitlab.gnome.org/GNOME/glib/-/issues/2676
2022-07-04 13:16:21 -04:00
Emmanuele Bassi
c0766caf20 Use varargs for enum types definition macros
Makes the syntax a little bit better.
2022-06-30 01:46:54 +01:00
Emmanuele Bassi
6cbf7a7461 Port enums tests to the appropriate assert functions
Do not use `g_assert()` inside tests, as the symbol can be disabled.
Instead, use `g_assert_null()` and `g_assert_nonnull()`.
2022-06-30 01:46:54 +01:00
Emmanuele Bassi
2a9ef1e0b4 Test the newly added G_DEFINE macros for enumeration types 2022-06-30 01:46:54 +01:00
Emmanuel Fleury
5699b7b169 Fix some coding style issues in python tests pointed out by black and flake8 2022-06-28 11:19:21 +01:00
Philip Withnall
191923ce61 Merge branch 'wip/smcv/none-flags' into 'main'
Add a NONE or DEFAULT member to most flags-sets

See merge request GNOME/glib!2576
2022-06-23 16:09:38 +00:00
Marc-André Lureau
a5d551e2be gobject/tests/performance: fix leaks
Easily spotted by ASAN.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-06-23 17:18:21 +04:00
Simon McVittie
879b9cd669 gregex: Add G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-06-23 10:47:39 +01:00
Simon McVittie
0d4e401ede gmarkup: Add G_MARKUP_PARSE_FLAGS_NONE
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-06-23 10:47:27 +01:00
Simon McVittie
de8672fe0b gtestutils: Add G_TEST_SUBPROCESS_DEFAULT, G_TEST_TRAP_DEFAULT
This makes calls to test subprocesses with default behaviour more
self-documenting.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-06-23 10:47:13 +01:00
Simon McVittie
7045260c22 gsignal: Add G_CONNECT_DEFAULT
This makes calls to g_signal_connect_data() and g_signal_connect_object()
with default flags more self-documenting.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-06-23 10:46:45 +01:00
Marco Trevisan
cb0cc996ee Merge branch 'test-suite-fixes' into 'main'
tests: Various fixes for TAP output of tests

See merge request GNOME/glib!2749
2022-06-22 18:48:59 +00:00
Philip Withnall
1aaf1e7de1 tests: Allow signal-handler performance tests to be smoketested
As with the previous commit, allow them to be smoketested when run
without `-m perf`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-06-21 12:57:33 +01:00
Philip Withnall
6f435e40cd tests: Run GObject performance tests under meson test
Pass arguments to them so that they take minimal time. This will not
produce useful performance profiling results, but will smoketest that
the tests still run, don’t crash, and therefore probably aren’t
bitrotting too badly.

This is useful because a fair amount of work has gone into these
performance tests, and they’re useful every few years to analyse and
compare GObject performance. We don’t want them to bitrot between uses.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-06-21 12:57:33 +01:00
Philip Withnall
6747702d77 tests: Fix use of deprecated threading API in performance-threaded
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-06-21 12:50:31 +01:00
Philip Withnall
6b8240f061 tests: Fix performance-threaded test when run for zero seconds
When running the test with `-s 0` it would previously crash. Fix that,
and make it so that it only does a single test run in that case.

This will be useful in an upcoming commit for smoketesting the test to
avoid bitrot.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-06-21 12:50:31 +01:00
Philip Withnall
74e71c78c0 tests: Fix a non-TAP formatted debug message in the basics-gobject test
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-06-21 12:50:31 +01:00
Philip Withnall
1b377e6574 build: Drop MALLOC_PERTURB_ from test environments
It’s set already by Meson, to an actually random value.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-06-21 12:50:31 +01:00
Matthias Clasen
dccab10d9f Add another testcase
This is similar to the notify-in-init testcase
added recently, but with a custom constructor.
2022-06-12 12:01:16 -04:00
Matthias Clasen
fb380b9899 Add a testcase for notify-in-instance-init
This is reproducing a problem that was observed
in gtk3's gtk_check_button_init.
2022-06-12 12:01:08 -04:00
Matthias Clasen
12152788f9 tests: Add a singleton construct-property test
Beef up the singleton testcase to reproduce a
freeze count underflow when setting properties
at construction time, with a custom constructor.

Helps: #2666
2022-06-10 14:09:07 +01:00
Philip Withnall
9af0444b92 tests: Simplify singleton test code using G_DECLARE_FINAL_TYPE
This doesn’t functionally change the test, just drops some boilerplate.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-06-10 14:09:07 +01:00
Philip Withnall
7a4560e052 tests: Port GObject singleton test to GTest framework
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-06-10 14:09:07 +01:00
Philip Withnall
edd497fc99 Merge branch 'binding-code-duplication' into 'main'
gbinding: Remove some duplicated code for checking property names and improve tests slightly

See merge request GNOME/glib!2740
2022-06-10 11:24:09 +00:00
Philip Withnall
103a9d5ae1 Merge branch 'gobject-query' into 'main'
gobject-query: Minor cleanups and add unit tests

See merge request GNOME/glib!2739
2022-06-09 17:33:13 +00:00
Philip Withnall
67a168c5d1 tests: Test g_binding_get_source() and g_binding_get_target()
These are deprecated, but it’s easy enough to test them anyway. This
bumps up code coverage a bit and hopefully ensures we don’t accidentally
regress on them in future.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-06-09 18:20:29 +01:00
Philip Withnall
c49f481967 tests: Add basic tests for gobject-query utility
At the moment these tests basically just ensure that the program’s
compiled properly and doesn’t crash on startup. They don’t check
functionality very deeply.

But they’re a start.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-06-09 13:26:15 +01:00
Philip Withnall
d463de05b1 tests: Move GObject performance tests to gobject/tests/performance/
This doesn’t change the tests’ behaviour, but moves them to a slightly
more logical location.

They are still not installed or run by default.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #1434
2022-06-08 11:30:31 +01:00
Philip Withnall
5d498f4d1c Merge branch 'move_testgobject' into 'main'
Move tests/gobject/testgobject.c to gobject/tests/basics-gobject.c

See merge request GNOME/glib!2696
2022-06-08 09:52:55 +00:00
Matthias Clasen
426724d51c Add some tests around properties
Install the properties with a mixture of
g_object_class_install_properties and
g_object_class_install_properties, and verify
that finding them still works, regardless of
whether we use string literals or not.
2022-06-07 22:49:30 -04:00
Philip Withnall
26409f19cd Add SPDX license headers for LGPL-2.1-or-later to various files
These have all been added manually, as I’ve finished all the files which
I can automatically detect.

All the license headers in this commit are for LGPL-2.1-or-later, and
all have been double-checked against the license paragraph in the file
header.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #1415
2022-06-01 12:44:23 +01:00
Philip Withnall
b2272ffb81 tests: Add SPDX license headers automatically
Add SPDX license (but not copyright) headers to all files which follow a
certain pattern in their existing non-machine-readable header comment.

This commit was entirely generated using the command:
```
git ls-files gobject/tests/*.[ch] | xargs perl -0777 -pi -e 's/\n \*\n \* This library is free software; you can redistribute it and\/or\n \* modify it under the terms of the GNU Lesser General Public/\n \*\n \* SPDX-License-Identifier: LGPL-2.1-or-later\n \*\n \* This library is free software; you can redistribute it and\/or\n \* modify it under the terms of the GNU Lesser General Public/igs'
```

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #1415
2022-06-01 12:17:28 +01:00
Philip Withnall
0611999fed tests: Remove various bits of overly-verbose test output
None of these messages are particularly helpful, but they increase the
overall test log output size, which has to be stored by the CI for every
test run.

With these messages removed, the size of a full test log is reduced from
6.5MB to 1.8MB for me.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-05-31 15:21:46 +01:00
Matthias Clasen
3db1d260ee testsuite: Make tests not fail in !debug builds
Some of our tests rely on on warning that only
occur in debug builds. Skip them in non-debug
builds.

Fixes: #2656
2022-05-28 08:02:16 -04:00
Emmanuel Fleury
ee67ca43cd Move tests/gobject/testgobject.c to gobject/tests/basics-gobject.c
Helps issue #1434
2022-05-27 22:31:13 +02:00