Commit Graph

27148 Commits

Author SHA1 Message Date
Philip Withnall
afcd0bb900 tests: Add some explanatory comments to appmonitor test
This should split the code up into logical blocks a bit better, and make
it a bit easier to see what the test is doing at a glance.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-03-22 15:12:52 +00:00
Philip Withnall
e4546614a8 tests: Port appmonitor test from GMainLoop to using GMainContext directly
This makes the exit conditions for each main loop clearer, and
eliminates use of global variables. It introduces no functional changes.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-03-22 15:12:52 +00:00
Philip Withnall
666c72c9c5 tests: Fix non-removal of a timeout in appmonitor test
If the first part of the test takes less than 3s (which is normal), the
timeout for it is not removed, and could spuriously fire during the
second part of the test, causing a false failure.

Instead of relying on source IDs, just use (and explicitly destroy) a
`GSource` for the timeouts.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-03-22 15:12:52 +00:00
Philip Withnall
c0ca3f995b tests: Fix a FIXME in the appmonitor test
The test thought that calling `g_app_info_get()` was a bit of a hack,
but actually it (or calling another `g_app_info_*()` function) is the
right way to use the `GAppInfoMonitor` API.

See the documentation improvements a couple of commits back for details.

The remaining FIXME higher up in the test should probably be fixed by
getting `g_app_info_monitor_get()` to arm the signal. That requires
changes in `g_app_info_monitor_get()` to call `desktop_file_dir_init()`.
That will have to happen another time.

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

Helps: #799
2023-03-22 15:12:49 +00:00
Marco Trevisan
bd63436fad Merge branch 'default-branch-docs' into 'main'
docs: Drop section about default branch renaming from README.md

See merge request GNOME/glib!3345
2023-03-22 15:09:58 +00:00
Philip Withnall
9279f3b0f9 tests: Use g_assert_*() rather than g_assert() in appmonitor tests
It won’t get compiled out with `G_DISABLE_ASSERT`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-03-22 14:38:04 +00:00
Philip Withnall
0a10851faa tests: Add copyright/licensing header to appmonitor tests
This is put together through git archaeology:
```
git log gio/tests/appmonitor.c
```

The following commits were too trivial to have meaningful copyright:
 - 54047080e9
 - 4e7d22e268
 - f2c1cfe8c7
 - f8f344923e
 - 3ce00b29ec
 - 3468369625
 - e9d9edde82

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

Helps: #1415
2023-03-22 14:36:57 +00:00
Philip Withnall
c62643adc3 gappinfo: Clarify one-shot behaviour of GAppInfoMonitor::changed in docs
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #799
2023-03-22 14:30:39 +00:00
Marco Trevisan
0be2555704 Merge branch 'drop-check-abis' into 'main'
tools: Drop check-abis.sh script

See merge request GNOME/glib!3344
2023-03-22 13:13:07 +00:00
Philip Withnall
9970ee1c97 docs: Drop section about default branch renaming from README.md
It’s been there for 2 years (since commit d81165216d), people have
probably got the message by now.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-03-22 12:53:05 +00:00
Philip Withnall
180713772f
2.76.1
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-03-22 11:28:01 +00:00
Philip Withnall
077b87aa9c tools: Drop check-abis.sh script
It hasn’t been used for years, and isn’t really needed since we changed
to explicitly exporting symbols (using `GLIB_AVAILABLE_IN_*`) rather than
implicitly exporting them unless they were hidden.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-03-22 10:44:01 +00:00
Danial Behzadi
babd275330 Update Persian translation 2023-03-22 10:34:36 +00:00
Philip Withnall
2aaa3250c9 Merge branch '2907-revert-gfileinfo-criticals' into 'main'
gfileinfo: Temporarily downgrade missing attribute criticals to debugs

See merge request GNOME/glib!3338
2023-03-21 16:15:37 +00:00
Philip Withnall
4cad66580b gfileinfo: Temporarily downgrade missing attribute criticals to debugs
This partially reverts ed8e86a7d4.

The change to add the criticals (commit ed8e86a7d4) is correct, but
landed too late in the cycle. Let’s downgrade the criticals to debugs
for now, to stop applications seeing a lot of new criticals in their
output. Those criticals are particularly disruptive for command line
applications and unit tests.

Early in the next cycle, the debugs will be re-upgraded to criticals.
This will give applications a whole additional cycle to fix their
ambiguous use of API.

It turned out that a lot of applications have latent bugs around
calling `g_file_info_get_*()` without checking whether an attribute
is set first, and were hence relying on the ‘unknown’ return value
also being an appropriate default for them.

This was compounded by the fact that several non-local GVFS backends
were not setting `GFileInfo` attributes all the time, which caused the
‘missing attribute’ code path to be hit more frequently. For example,
they would only call `g_file_info_set_is_hidden()` with a true value and
never bother with a false one.

It was further compounded by the fact that, while this change landed for
the 2.75.4 release, there did not seem to be extensive integration
testing of that release, and distributions and downstreams went straight
to 2.76.0. That meant we missed the window between 2.75.4 and 2.76.0 to
change, fix or revert this behaviour. GLib relies on distros and
downstreams doing integration testing of unstable releases. We test with
downstream GNOME as part of gnome-build-meta, but do not have the
resources to do integration testing for everybody.

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

See: #2907
See: #2932
See: #2934
See: #2945
See: #2948
2023-03-21 15:01:10 +00:00
Philip Withnall
2630b7d2d5 Merge branch '352-file-enumerator-docs' into 'main'
gfileenumerator: Clarify termination condition for next_files_async()

Closes #352

See merge request GNOME/glib!3339
2023-03-21 14:58:45 +00:00
Marco Trevisan
076e656f30 Merge branch 'strfuncs-check-results' into 'main'
tests: Check a few results in strfuncs tests

See merge request GNOME/glib!3330
2023-03-21 14:52:59 +00:00
Marco Trevisan
8d0c92e65e Merge branch '159-strstr-len-docs' into 'main'
gstrfuncs: Clarify haystack_len behaviour of g_strstr_len()

Closes #159

See merge request GNOME/glib!3331
2023-03-21 14:52:16 +00:00
Marco Trevisan
fc5fc89841 Merge branch '2948-gio-is-hidden' into 'main'
gio: Add some missing file info attribute checks in gio-list and gio-tree

Closes #2948

See merge request GNOME/glib!3336
2023-03-21 14:47:47 +00:00
Philip Withnall
a046492a19 gfileenumerator: Add an example of using next_files_async() to the docs
This is written in pseudocode C which omits all the callback boilerplate
for the async calls. This should hopefully make the overall structure of
the loop more obvious.

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

Helps: #352
2023-03-21 14:07:08 +00:00
Owen Taylor
67a9367598 gfileenumerator: Clarify termination condition for next_files_async()
As suggested on #352 by Owen Taylor (commit put together by Philip
Withnall, but in Owen’s name as it’s his wording).

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

Fixes: #352
2023-03-21 13:56:52 +00:00
Philip Withnall
2953c08261 gfileinfo: Zero GTimeVal when failing g_file_info_get_modification_time()
Before commit ed8e86a7d4, this function would have silently returned a
zero-valued `GTimeVal` if the correct attributes weren’t present.

That partially regressed in commit ed8e86a7d4, which made it return with
a critical warning, but without zeroing the `GTimeVal`. The critical
warning can be ignored by users (it doesn’t abort the process unless
`G_DEBUG=fatal-criticals` is set), but the change in behaviour of
zeroing the `GTimeVal` could cause bugs.

See: #2907

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-03-21 12:15:50 +00:00
Philip Withnall
2029d7e900 gpollfilemonitor: Add missing attribute checks for g_file_info_get_size()
Missed from the fixes for #2907.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-03-21 12:15:50 +00:00
Philip Withnall
4ba3470269 gio: Add some missing file info attribute checks in gio-list and gio-tree
Further fallout from #2907.

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

Fixes: #2948
2023-03-21 12:15:50 +00:00
Philip Withnall
23a009b2cb Merge branch '919-variant-dict-lookup-docs' into 'main'
gvariant: Document failure behaviour of g_variant_dict_lookup() better

Closes #919

See merge request GNOME/glib!3334
2023-03-21 12:07:20 +00:00
Jan Beich
f6c40b1d27 meson: allow -Dlibelf=enabled without pkg-config
gio/meson.build:933:0: ERROR: Dependency "libelf" not found, tried pkgconfig
2023-03-20 14:57:36 +00:00
Colin Walters
8d7c1f9b75 tests: Finish update of gdbus-example-proxy-subclass to new GDBus API
This fixes bug #624696.

Incorporates a more recent change from 1dc774a653 to drop the
`g_type_init()` call, and reformats the indentation a bit.

Fixes: #322
2023-03-20 13:03:04 +00:00
Philip Withnall
7d090d1510 gvariant: Document failure behaviour of g_variant_dict_lookup() better
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #919
2023-03-20 12:16:54 +00:00
Philip Withnall
3d7e88a77d build: Drop old .gitignore files from test directories
They just listed built files. Since the move to Meson, these are all
kept in a separate build directory, not the source tree, so don’t need
to be ignored.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-03-20 12:09:02 +00:00
Philip Withnall
7dfde773f6 gstrfuncs: Clarify haystack_len behaviour of g_strstr_len()
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #159
2023-03-20 11:55:53 +00:00
Philip Withnall
5fdacf78e2 tests: Check a few results in strfuncs tests
This fixes some written-but-never-read warnings from `scan-build`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-03-20 10:43:25 +00:00
Emmanuele Bassi
e979fd9a15 Merge branch '2943-g-test-init-docs' into 'main'
gtestutils: Clarify docs about calling g_test_init() before anything

Closes #2943

See merge request GNOME/glib!3327
2023-03-17 11:29:29 +00:00
Philip Withnall
045bc7adde gtestutils: Clarify docs about calling g_test_init() before anything
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #2943
2023-03-17 11:03:09 +00:00
Philip Withnall
98a567ce7f Merge branch 'queue-test' into 'main'
tests: Reduce number of iterations in queue test

See merge request GNOME/glib!3324
2023-03-16 17:45:22 +00:00
Philip Withnall
790fbfab4c Merge branch 'xry111/issue2936' into 'main'
gstrfuncs: Improve inline version of g_strdup() to avoid breaking C++ code

Closes #2936

See merge request GNOME/glib!3322
2023-03-16 12:13:10 +00:00
Philip Withnall
9d7c796f1e Merge branch 'fix-monitor-root-directory-fail' into 'main'
inotify: Avoid empty root directory string

See merge request GNOME/glib!3241
2023-03-16 12:12:01 +00:00
Philip Withnall
eff90c09f5 tests: Simplify a helper function in queue test
Remove an unnecessary intermediate variable.

This introduces no functional changes.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-03-16 12:05:07 +00:00
Philip Withnall
ea852e2683 tests: Fix signed/unsigned comparisons and assignments in queue test
This introduces no functional changes.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-03-16 12:05:07 +00:00
Philip Withnall
2d89f84267 tests: Reduce number of iterations in queue test
Unless `-m thorough` is passed to the tests, reduce the number of
iterations in the random test.

This one test case takes the bulk of the time to run the `queue` test
suite, and is sometimes causing timeouts when running on CI
(particularly under valgrind). Reduce it to a fifth.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-03-16 12:05:07 +00:00
Philip Withnall
1f6a4d60d4 tests: Add copyright/licensing header to queue tests
This is put together through git archaeology:
```
git log glib/tests/queue.c
git log -- tests/queue-test.c
```

The following commits were too trivial to have meaningful copyright:
 - 8f02fac4ad
 - d81ac5339f
 - 29f2ced8eb
 - 1a2c5e155d
 - 8a90f5e9f6
 - 45dae4b506
 - 2aa71ab63b
 - 3a74ad128e

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

Helps: #1415
2023-03-16 12:05:07 +00:00
Philip Withnall
8b25142cb2 tests: Use g_assert_*() rather than g_assert() in queue tests
It won’t get compiled out with `G_DISABLE_ASSERT`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-03-16 12:05:07 +00:00
Guillaume Desmottes
6b39af34aa glib: unicode: add some empty string tests 2023-03-15 15:14:53 +00:00
Guillaume Desmottes
deb495de42 glib: unicode: add tests for g_utf8_normalize()
Test corner cases and some examples from Unicode Standard Annex #15
http://unicode.org/reports/tr15/
2023-03-15 15:14:53 +00:00
Guillaume Desmottes
221bbde429 glib: unicode: fix unicode standard link 2023-03-15 15:14:53 +00:00
Philip Withnall
f535d0915f tests: Add a test for creating a file monitor on the root directory
While we can’t check for any events on it, this at least tests that
creating a file monitor works. It should cover the fix from the previous
commit.

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

Helps: !3241
2023-03-15 14:45:10 +00:00
Marco Trevisan
7fec23ed5e Merge branch 'desktop-app-info-startup-id' into 'main'
gdesktopappinfo: Add a missing NULL check

See merge request GNOME/glib!3325
2023-03-15 14:03:58 +00:00
Philip Withnall
1a9be3a1c8 tests: Add a test for D-Bus activating an unknown app with a context
This should catch regressions in the critical warning fixed in the
previous commit.

The launch has to have several conditions:
 - Session bus is running (to avoid the launch happening via the spawn
   codepath)
 - Use a non-existent D-Bus name (to trigger a launch error)
 - Use a launch context (to hit the critical warning code path)
 - Not have a startup ID specified in the platform data — this implies
   having an empty launch context
 - Use an async launch, as that provides an error handling path

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-03-15 13:50:51 +00:00
Xi Ruoyao
cc7f2f81cc
gstrfuncs: Improve inline version of g_strdup() to avoid breaking C++ code
Wrap the logic into a G_ALWAYS_INLINE function, instead of using a
complex statement-expression which is not allowed in braced initializer
lists and expanded into some bad thing when it's used as
`::g_strdup(...)`.

We cannot use `__builtin_constant_p (str)` because GCC documentation
clearly states that it always produces 0 when str is a const char *
argument of an inline function.  But `__builtin_constant_p (!str)`,
`__builtin_constant_p (!!str)`, and
`__builtin_constant_p (strlen (str))` functions properly with `-O1` or
above enabled.

Fixes #2936.
2023-03-15 15:18:34 +08:00
Philip Withnall
7cd57b3e85 gdesktopappinfo: Add a missing NULL check
It’s possible for the startup ID to be `NULL` if one wasn’t provided in
the platform data passed to `launch_uris_with_dbus()`.

Passing `NULL` to `g_app_launch_context_launch_failed()` causes a
critical warning.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-03-14 14:37:14 +00:00
Philip Withnall
8fbb8dc442 Merge branch 'test-failures' into 'main'
tests: Fix timeout sources in gdbus-auth and gapplication tests

See merge request GNOME/glib!3323
2023-03-14 10:26:27 +00:00