Commit Graph

29849 Commits

Author SHA1 Message Date
Philip Withnall
78698af73f Merge branch '3246-object-info-docs' into 'main'
girepository: Fix declaration of ‘find using interfaces’ methods

Closes #3246

See merge request GNOME/glib!3883
2024-02-08 10:19:16 +00:00
Philip Withnall
62abd578cd Merge branch '3155-typelib-boxed' into 'main'
gitypelib: Switch to refcounting

See merge request GNOME/glib!3900
2024-02-08 10:18:40 +00:00
Philip Withnall
a138589d57 Merge branch 'repository-n-elements' into 'main'
girepository: Add length ‘out’ arguments to several getter methods

See merge request GNOME/glib!3901
2024-02-08 10:18:12 +00:00
Philip Withnall
6fe7edbc8d Merge branch 'girepository-migration-docs' into 'main'
docs: Add migration guide for libgirepository

See merge request GNOME/glib!3881
2024-02-08 10:10:40 +00:00
Philip Withnall
01cf3a03c2 Merge branch 'wip/smcv/lint' into 'main'
Incorporate some lint checks into `meson test`

See merge request GNOME/glib!3898
2024-02-08 01:03:01 +00:00
Simon McVittie
e87db7dbf2 CI: Run all style/lint checks before failing
Even if we get warnings from the first lint check, we probably want to
see the warnings from later lint checks too, to reduce the number of
round-trips.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-02-08 00:18:23 +00:00
Simon McVittie
a7702505e0 CI: Extend submodule workaround to most jobs that run the test suite
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-02-08 00:18:23 +00:00
Simon McVittie
d7601f7eed Incorporate some lint checks into meson test
This will make it easier and more obvious for developers to run them
locally: I'm sure I'm not the only developer who had assumed that
`.gitlab-ci/` is private to the CI environment and inappropriate (or
perhaps even destructive) to run on a developer/user system.

The lint checks are automatically skipped (with TAP SKIP syntax) if we
are not in a git checkout, or if git or the lint tool is missing. They
can also be disabled explicitly with `meson test --no-suite=lint`,
which downstream distributions will probably want to do.

By default, most lint checks are reported as an "expected failure"
(with TAP TODO syntax) rather than a hard failure, because they do not
indicate a functional problem with GLib and there is a tendency for
lint tools to introduce additional checks or become more strict over
time. Developers can override this by configuring with `-Dwerror=true`
(which also makes compiler warnings into fatal errors), or by running
the test suite like `LINT_WARNINGS_ARE_ERRORS=1 meson test --suite=lint`.

One exception to this is tests/check-missing-install-tag.py, which is
checking a functionally significant feature of our build system, and
seems like it is unlikely to have false positives: if that one fails,
it is reported as a hard failure.

run-style-check-diff.sh and run-check-todos.sh are not currently given
this treatment, because they require search-common-ancestor.sh, which
uses Gitlab-CI-specific information to find out which commits are in-scope
for checking.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-02-08 00:18:23 +00:00
Philip Withnall
6929632ecb gitypelib: Add boxed type
This is needed because `GITypelib` is exposed in the public
libgirepository API, so needs to be introspectable.

This should fix a couple of warnings about `gi_repository_require()` and
related APIs not being introspectable as they return an unintrospectable
type.

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

Helps: #3155
2024-02-07 21:07:18 +00:00
Philip Withnall
5cc5f413f5 gitypelib: Switch to refcounting
Since `GITypelib` is exposed in the public libgirepository API, it needs
to be a boxed type. So we either need to add a `copy` method to mirror
the existing `free` method, or switch to refcounting. The latter option
seems better, since a `GITypelib` contains internal state about open
`GModule`s and the semantics for copying that would be potentially
complex.

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

Helps: #3155
2024-02-07 21:07:18 +00:00
Thomas Haller
89e85717c9 build: workaround compiler warning -Wnon-null in meson detection
Otherwise, `CFLAGS='-Wall -Werror' meson build` fails detection with:

  Running compile:
  Working directory:  /data/src/glib/build/meson-private/tmpmw16de74
  Code:
   #include <fcntl.h>
                    #include <sys/types.h>
                    #include <sys/stat.h>
                    void some_func (void) {
                      open(0, O_DIRECTORY, 0);
                    }
  -----------
  Command line: `cc /data/src/glib/build/meson-private/tmpmw16de74/testfile.c -o /data/src/glib/build/meson-private/tmpmw16de74/output.obj -c -Werror -Wall -D_FILE_OFFSET_BITS=64 -O0 -std=gnu99` -> 1
  stderr:
  /data/src/glib/build/meson-private/tmpmw16de74/testfile.c: In function 'some_func':
  /data/src/glib/build/meson-private/tmpmw16de74/testfile.c:5:21: error: argument 1 null where non-null expected [-Werror=nonnull]
      5 |                     open(0, O_DIRECTORY, 0);
        |                     ^~~~
  In file included from /usr/include/features.h:503,
                   from /usr/include/fcntl.h:25,
                   from /data/src/glib/build/meson-private/tmpmw16de74/testfile.c:1:
  /usr/include/fcntl.h:212:12: note: in a call to function 'open' declared 'nonnull'
    212 | extern int __REDIRECT (open, (const char *__file, int __oflag, ...), open64)
        |            ^~~~~~~~~~
  cc1: all warnings being treated as errors
  -----------
  Checking if "open() option O_DIRECTORY" compiles: NO
2024-02-07 20:40:59 +01:00
Thomas Haller
bcb6431bff build: workaround compiler warning -Wunused-variable in meson detection
Otherwise, `CFLAGS='-Wall -Werror' meson build` fails detection with:

  Running compile:
  ...
  Command line: `cc /data/src/glib/build/meson-private/tmplkxa94er/testfile.c -o /data/src/glib/build/meson-private/tmplkxa94er/output.exe -Werror -Wall -D_FILE_OFFSET_BITS=64 -O0 -std=gnu99` -> 1
  stderr:
  /data/src/glib/build/meson-private/tmplkxa94er/testfile.c: In function 'main':
  /data/src/glib/build/meson-private/tmplkxa94er/testfile.c:3:24: error: unused variable 'codeset' [-Werror=unused-variable]
      3 |                  char *codeset = nl_langinfo (CODESET);
        |                        ^~~~~~~
  cc1: all warnings being treated as errors
  -----------
  Checking if "nl_langinfo and CODESET" : links: NO
2024-02-07 20:40:59 +01:00
Thomas Haller
509e599eed build: workaround compiler warning in meson detection of nl_langinfo()
Otherwise, `CFLAGS='-Wall -Werror' meson build` fails detection with:

  Running compile:
  Working directory:  /data/src/glib/build/meson-private/tmpa3ebpbos
  Code:
   #include <langinfo.h>
                 int main (int argc, char ** argv) {
                   char *str;
                   str = nl_langinfo (PM_STR);
                   str = nl_langinfo (D_T_FMT);
                   str = nl_langinfo (D_FMT);
                   str = nl_langinfo (T_FMT);
                   str = nl_langinfo (T_FMT_AMPM);
                   str = nl_langinfo (MON_1);
                   str = nl_langinfo (ABMON_12);
                   str = nl_langinfo (DAY_1);
                   str = nl_langinfo (ABDAY_7);
                   return 0;
                 }
  -----------
  Command line: `cc /data/src/glib/build/meson-private/tmpa3ebpbos/testfile.c -o /data/src/glib/build/meson-private/tmpa3ebpbos/output.exe -Werror -Wall -D_FILE_OFFSET_BITS=64 -O0 -std=gnu99` -> 1
  stderr:
  /data/src/glib/build/meson-private/tmpa3ebpbos/testfile.c: In function 'main':
  /data/src/glib/build/meson-private/tmpa3ebpbos/testfile.c:3:24: error: variable 'str' set but not used [-Werror=unused-but-set-variable]
      3 |                  char *str;
        |                        ^~~
  cc1: all warnings being treated as errors
  -----------
  Checking if "nl_langinfo (PM_STR)" : links: NO
2024-02-07 20:40:59 +01:00
Thomas Haller
4bdadb6ccc build: workaround compiler warning in meson detection of __uint128_t
Otherwise, `CFLAGS='-Wall -Werror' meson build` fails detection with:

  Code:
   int main() {
  static __uint128_t v1 = 100;
  static __uint128_t v2 = 10;
  static __uint128_t u;
  u = v1 / v2;
  }
  -----------
  Command line: `cc /data/src/glib/build/meson-private/tmp451h9ogd/testfile.c -o /data/src/glib/build/meson-private/tmp451h9ogd/output.obj -c -Werror -Wall -D_FILE_OFFSET_BITS=64 -O0 -std=gnu99` -> 1
  stderr:
  /data/src/glib/build/meson-private/tmp451h9ogd/testfile.c: In function 'main':
  /data/src/glib/build/meson-private/tmp451h9ogd/testfile.c:4:20: error: variable 'u' set but not used [-Werror=unused-but-set-variable]
      4 | static __uint128_t u;
        |                    ^
  cc1: all warnings being treated as errors
  -----------
  Checking if "__uint128_t available" compiles: NO
2024-02-07 20:40:59 +01:00
Thomas Haller
d0afd2b783 build: drop unused variable from "C99 snprintf" meson check
Otherwise, `CFLAGS='-Wall -Werror' meson build` fails detection with:

  Running compile:
  ...
  int
  main(void)
  {
    doit();
    exit(1);
  }
  -----------
  Command line: `cc /data/src/glib/build/meson-private/tmp7n5yqh0h/testfile.c -o /data/src/glib/build/meson-private/tmp7n5yqh0h/output.exe -Werror -Wall -D_FILE_OFFSET_BITS=64 -O0 -std=gnu99` -> 1
  stderr:
  /data/src/glib/build/meson-private/tmp7n5yqh0h/testfile.c: In function 'doit':
  /data/src/glib/build/meson-private/tmp7n5yqh0h/testfile.c:10:11: error: unused variable 'args' [-Werror=unused-variable]
     10 |   va_list args;
        |           ^~~~
  /data/src/glib/build/meson-private/tmp7n5yqh0h/testfile.c:13:33: error: '1234567' directive output truncated writing 7 bytes into a region of size 5 [-Werror=format-truncation=]
     13 |   r = snprintf(buffer, 5, "1234567");
        |                            ~~~~~^~
  /data/src/glib/build/meson-private/tmp7n5yqh0h/testfile.c:13:7: note: 'snprintf' output 8 bytes into a destination of size 5
     13 |   r = snprintf(buffer, 5, "1234567");
        |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  cc1: all warnings being treated as errors
  -----------
  Could not compile test file /data/src/glib/build/meson-private/tmp7n5yqh0h/testfile.c: 1

  Checking if "C99 snprintf" runs: DID NOT COMPILE
2024-02-07 20:40:59 +01:00
Thomas Haller
5525672a5f build: avoid "-Werror=format-extra-args" warnings in detecting printf for gnulib
Otherwise, `CFLAGS='-Wall -Werror' meson build` fails detection with:

  Running compile:
  Working directory:  /data/src/glib/build/meson-private/tmpoozk2y4b
  Code:

  #include <stdio.h>
  #include <string.h>
  static char buf[100];
  static double zero = 0.0;
  int main ()
  {
    if (sprintf (buf, "%010f", 1.0 / zero, 33, 44, 55) < 0
        || (strcmp (buf, "       inf") != 0
            && strcmp (buf, "  infinity") != 0))
      return 1;
    return 0;
  }

  -----------
  Command line: `cc /data/src/glib/build/meson-private/tmpoozk2y4b/testfile.c -o /data/src/glib/build/meson-private/tmpoozk2y4b/output.exe -Werror -Wall -D_FILE_OFFSET_BITS=64 -O0 -std=gnu99` -> 1
  stderr:
  /data/src/glib/build/meson-private/tmpoozk2y4b/testfile.c: In function 'main':
  /data/src/glib/build/meson-private/tmpoozk2y4b/testfile.c:8:21: error: too many arguments for format [-Werror=format-extra-args]
      8 |   if (sprintf (buf, "%010f", 1.0 / zero, 33, 44, 55) < 0
        |                     ^~~~~~~
  cc1: all warnings being treated as errors
  -----------
  Could not compile test file /data/src/glib/build/meson-private/tmpoozk2y4b/testfile.c: 1

  Checking if "printf supports the zero flag correctly" runs: DID NOT COMPILE
2024-02-07 20:40:59 +01:00
Marco Trevisan
bc0e53aa27 Merge branch 'callable-docs' into 'main'
gicallableinfo: Clarify docs for callables with no return type

See merge request GNOME/glib!3902
2024-02-07 18:12:30 +00:00
Philip Withnall
389e8a439b gicallableinfo: Clarify docs for callables with no return type
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-02-07 15:59:56 +00:00
Philip Withnall
8f6926d4ce girepository: Document NULL-termination/length semantics for methods
This doesn’t change the existing behaviour, just documents it a bit more
clearly.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-02-07 15:47:13 +00:00
Philip Withnall
01f9796532 girepository: Add length ‘out’ arguments to several getter methods
This makes them consistent with the other getter methods in
`GIRepository` which return lists/arrays. It’s useful to return the
length, as that means the caller doesn’t have to work it out by
iterating over the entire array.

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

Helps: #3155
2024-02-07 15:47:13 +00:00
Philip Withnall
8dee910d77 Merge branch 'th/meson-werror-fixes' into 'main'
[th/meson-werror-fixes] some fixes for meson detection failure with -Werror

See merge request GNOME/glib!3895
2024-02-07 14:26:30 +00:00
Michael Catanzaro
b7ef29560d Merge branch 'statvfs-type' into 'main'
glocalfile: Support statvfs.f_type

See merge request GNOME/glib!3893
2024-02-07 14:24:52 +00:00
Michael Catanzaro
d753985708 Merge branch 'minor-fixes' into 'main'
Minor fixes/docs changes to GFileDescriptorBased and GTask

See merge request GNOME/glib!3894
2024-02-07 14:21:11 +00:00
Thomas Haller
a91219f164 build: fix compiler warnings in gnulib printf meson build checks
Otherwise, `CFLAGS='-Wall -Werror' meson build` fails detection with:

  ...
    if (sprintf (buf, "%.4000d %d", 1, 33, 44) < 4000 + 3)
      result |= 1;
    if (sprintf (buf, "%.4000f %d", 1.0, 33, 44) < 4000 + 5)
      result |= 2;
    if (sprintf (buf, "%.511f %d", 1.0, 33, 44) < 511 + 5
        || buf[0] != '1')
      result |= 4;
    if (sprintf (buf, "%.999f %d", 1.0, 33, 44) < 999 + 5
        || buf[0] != '1')
      result |= 4;
    return result;
  }

  -----------
  Command line: `cc /data/src/glib/build/meson-private/tmpu3dav6iy/testfile.c -o /data/src/glib/build/meson-private/tmpu3dav6iy/output.exe -Wall -Werror -D_FILE_OFFSET_BITS=64 -O0 -std=gnu99` -> 1
  stderr:
  /data/src/glib/build/meson-private/tmpu3dav6iy/testfile.c: In function 'main':
  /data/src/glib/build/meson-private/tmpu3dav6iy/testfile.c:12:21: error: too many arguments for format [-Werror=format-extra-args]
     12 |   if (sprintf (buf, "%.4000d %d", 1, 33, 44) < 4000 + 3)
        |                     ^~~~~~~~~~~~
  /data/src/glib/build/meson-private/tmpu3dav6iy/testfile.c:14:21: error: too many arguments for format [-Werror=format-extra-args]
     14 |   if (sprintf (buf, "%.4000f %d", 1.0, 33, 44) < 4000 + 5)
        |                     ^~~~~~~~~~~~
  /data/src/glib/build/meson-private/tmpu3dav6iy/testfile.c:16:21: error: too many arguments for format [-Werror=format-extra-args]
     16 |   if (sprintf (buf, "%.511f %d", 1.0, 33, 44) < 511 + 5
        |                     ^~~~~~~~~~~
  /data/src/glib/build/meson-private/tmpu3dav6iy/testfile.c:19:21: error: too many arguments for format [-Werror=format-extra-args]
     19 |   if (sprintf (buf, "%.999f %d", 1.0, 33, 44) < 999 + 5
        |                     ^~~~~~~~~~~
  cc1: all warnings being treated as errors
  -----------
  Could not compile test file /data/src/glib/build/meson-private/tmpu3dav6iy/testfile.c: 1
2024-02-07 14:46:57 +01:00
Thomas Haller
a65fa9a33f build: fix compiler warning in gl_cv_func_frexpl_works meson build check
Otherwise, `CFLAGS='-Wall -Werror' meson build` fails with:

  ...
  Command line: `cc ./glib/build/meson-private/tmp7iwplrgi/testfile.c -o ./glib/build/meson-private/tmp7iwplrgi/output.obj -c -O3 -Werror -Wall -D_FILE_OFFSET_BITS=64 -O0 -std=gnu99` -> 1
  stderr:
  ./glib/build/meson-private/tmp7iwplrgi/testfile.c: In function 'main':
  ./glib/build/meson-private/tmp7iwplrgi/testfile.c:83:21: error: unused variable 'y' [-Werror=unused-variable]
     83 |         long double y = frexpl (x, &exp);
        |                     ^
  cc1: all warnings being treated as errors
  -----------
  Checking if "frexpl prototype can be re-listed" compiles: NO

  glib/gnulib/meson.build:316:2: ERROR: Problem encountered: frexpl() is missing or broken beyond repair, and we have nothing to replace it with
2024-02-07 14:46:57 +01:00
Thomas Haller
90817d0fab build: workaround meson's cc.has_member() causing compiler warning.
Otherwise, `CFLAGS='-Wall -Werror' meson build` fails with:

  ...
  #include <sys/stat.h>
          void bar(void) {
              struct stat foo;
              foo.st_mtim.tv_nsec;

          }
  -----------
  Command line: `cc /data/src/glib/build/meson-private/tmpbjjq3ikp/testfile.c -o /data/src/glib/build/meson-private/tmpbjjq3ikp/output.obj -c -O3 -Werror -Wall -D_FILE_OFFSET_BITS=64 -O0 -std=gnu99` -> 1
  stderr:
  /data/src/glib/build/meson-private/tmpbjjq3ikp/testfile.c: In function 'bar':
  /data/src/glib/build/meson-private/tmpbjjq3ikp/testfile.c:45:24: error: statement with no effect [-Werror=unused-value]
     45 |             foo.st_mtim.tv_nsec;
        |             ~~~~~~~~~~~^~~~~~~~
  cc1: all warnings being treated as errors
  -----------
  Checking whether type "struct stat" has member "st_mtim.tv_nsec" : NO
2024-02-07 14:46:51 +01:00
Philip Withnall
27fb6ffce2 Merge branch 'wip/smcv/reuse' into 'main'
reuse: Fix screen-scraping expression for version 2.x

See merge request GNOME/glib!3897
2024-02-07 13:03:12 +00:00
Philip Withnall
ced299c7ad Merge branch 'reuse-updates' into 'main'
reuse: Add dep5 lines for gnulib and libcharset

See merge request GNOME/glib!3896
2024-02-07 12:50:40 +00:00
Simon McVittie
5d888bc7c2 reuse: Fix screen-scraping expression for version 2.x
reuse 2.1.0 outputs "files with ..." instead of "Files with ...",
but it's easy to accept both.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-02-07 12:38:25 +00:00
Philip Withnall
722805fd09 reuse: Update CI limits on files missing SPDX data
One more monotonic step on the way to full REUSE compliance.

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

Helps: #1415
2024-02-07 12:10:04 +00:00
Philip Withnall
b1f540d267 reuse: Add dep5 lines for gnulib and libcharset
Since they are copylibs, we don’t want to diverge from upstream by
adding SPDX lines to all the files, so add them to the dep5 file
instead.

gnulib discussed adding them upstream a couple of years ago but the
discussion seemed to peter out:
https://lists.gnu.org/archive/html/bug-gnulib/2021-06/msg00004.html.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-02-07 12:08:46 +00:00
Thomas Haller
8ea0f7d045 build: fix detection of int64_t_typedef in meson build check
Otherwise, `CFLAGS='-Wall -Werror' meson build` fails with:

  Checking for size of "ssize_t" : 8
  Running compile:
  Working directory:  ./glib/build/meson-private/tmpgwlkasyk
  Code:
   #if defined(_AIX) && !defined(__GNUC__)
                      #pragma options langlvl=stdc99
                      #endif
                      #pragma GCC diagnostic error "-Wincompatible-pointer-types"
                      #include <stdint.h>
                      #include <stdio.h>
                      int main () {
                        int64_t i1 = 1;
                        long *i2 = &i1;
                        return 1;
                      }
  -----------
  Command line: `cc ./glib/build/meson-private/tmpgwlkasyk/testfile.c -o ./glib/build/meson-private/tmpgwlkasyk/output.obj -c -O3 -Werror -Wall -D_FILE_OFFSET_BITS=64 -O0 -std=gnu99` -> 1
  stderr:
  ./glib/build/meson-private/tmpgwlkasyk/testfile.c: In function 'main':
  ./glib/build/meson-private/tmpgwlkasyk/testfile.c:9:29: error: unused variable 'i2' [-Werror=unused-variable]
      9 |                       long *i2 = &i1;
        |                             ^~
  cc1: all warnings being treated as errors
2024-02-07 11:49:57 +01:00
Philip Withnall
9eeb8a87d3 glocalfile: Support statvfs.f_type
This is another way to get the file system type from `statvfs()`, newly
added in glibc 2.39
(https://lwn.net/ml/libc-alpha/38790850.J2Yia2DhmK@pinacolada/).

This hasn’t been tested with glibc 2.39 as I don’t have it, but the
change seems fairly straightforward.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-02-07 10:34:59 +00:00
Philip Withnall
90ec3d3499 gtask: Clarify when GTask:completed is suitable to use
It’s not suitable to use to check if your own code has already called
`g_task_return_*()`, as it doesn’t directly correlate to that.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-02-07 10:34:08 +00:00
Philip Withnall
15cef2ea59 gfiledescriptorbased: Fix incorrect precondition return value
`0` is a valid FD, `-1` is not, so `-1` is more suitable to use.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-02-07 10:34:08 +00:00
Michael Catanzaro
a040562d6c Merge branch 'param-leak' into 'main'
gtestutils: Ensure test_data is freed even if a test is skipped

See merge request GNOME/glib!3887
2024-02-06 18:33:23 +00:00
Philip Withnall
20c7479cc8 Merge branch 'wip/smcv/codegen-stdout' into 'main'
codegen: Use `-` instead of `stdout` for output to stdout

See merge request GNOME/glib!3886
2024-02-06 15:13:59 +00:00
Simon McVittie
040caa5f6a gdbus-codegen(1): Suggest --pragma-once for headers written to stdout
Otherwise we would generate a multiple-inclusion guard of the
form `#ifndef __STDOUT__ ...`, which can only work for one D-Bus
interface per translation unit.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-02-06 14:06:51 +00:00
Simon McVittie
fc7942f46b gdbus-codegen: If writing body to stdout, don't try to include header
If we're writing the body to standard output, we cannot know what the
filename of the corresponding header is going to be, but it seems
vanishingly unlikely that it will be either `stdout.h` (which we would
traditionally have generated) or `-.h` (which we would have generated
since !3886).

This makes some of the output snippets sufficiently short that black(1)
requires that they are folded into a single line.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-02-06 14:06:45 +00:00
Simon McVittie
5e8f053d33 tests: Exercise gdbus-codegen --interface-info-header with empty input
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-02-06 13:55:35 +00:00
Simon McVittie
02a3417ac4 tests: Exercise gdbus-codegen --interface-info-body with empty input
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-02-06 13:55:33 +00:00
Philip Withnall
44e3ebccd1 tests: Add basic tests for GIUnionInfo
These would have caught the regression fixed in the previous commit.

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

Helps: #3155
2024-02-06 13:42:43 +00:00
Philip Withnall
c8946b8a92 gitypes: Fix integer values of GIInfoType
This effectively reverts commit 0910e2f6ad. I thought that `GIInfoType`
was decoupled from `GITypelibBlobType`, but it turns out that
`girepository.c` calls `gi_info_new_full()` with blob types, implicitly
converting them to info types.

This was causing anything with a type higher than the `INVALID_0` value
to be loaded as the wrong type.

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

Helps: #3155
2024-02-06 13:40:20 +00:00
Philip Withnall
e286497c1f giunioninfo: Mark get_discriminator_type() as nullable
It may (and should) return `NULL` if called on a union which isn’t
discriminated.

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

Helps: #3155
2024-02-06 13:35:23 +00:00
Philip Withnall
11e8075e51 giunioninfo: Split success and return value for get_discriminator_offset()
Otherwise there’s no obvious suitable return value to return when the
union is *not* discriminated.

This is an API break, but libgirepository has not been in a stable
release yet, so that’s fine.

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

Helps: #3155
2024-02-06 13:34:17 +00:00
Simon McVittie
1ba8386886 codegen: Document --output -
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-02-06 11:53:06 +00:00
Simon McVittie
6a1fdb8145 codegen: Use - instead of stdout for output to stdout
In command-line tools, ordinary filenames normally do not have
special-cased meanings, so commit 3ef742eb "Don't skip dbus-codegen tests
on Win32" was a command-line API break: in the unlikely event that a
user wanted to write to a file named exactly `stdout`, this would have
been an incompatible change.

There is a conventional pseudo-filename to represent standard output,
which is `-` (for example `cat -` is a no-op filter). Adding support
for this is technically also a command-line API break (in the very
unlikely event that a user wants to write to a file named exactly `-`,
they would now have to write it as `./-`), but filenames starting with
a dash often require special treatment anyway, so this probably will not
come as a surprise to anyone.

When the output filename is `-` we don't want to use `#ifdef _____` as
a header guard, so special-case it as `__STDOUT__` as before.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-02-06 11:53:06 +00:00
Philip Withnall
b06107579c gtestutils: Reformat docs for g_test_queue_destroy()
Fix a typo in them and improve the formatting while I’m there.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-02-06 11:05:13 +00:00
Philip Withnall
9dad94e7e5 gtestutils: Ensure test_data is freed even if a test is skipped
It’s reasonable for the `main()` function in a test suite to pass
ownership of some test data to `g_test_add_data_func_full()`, along with
a `GDestroyNotify`, and rely on GTest to free the data after all tests
have been run.

Unfortunately that only worked if the test was run, and not skipped
before its test function was called. This could happen if, for example,
it had `/subprocess` in its path.

Fix that by always freeing the test data. This required reworking how
tests are skipped, slightly, to bring all the logic for that within
`test_case_run()`, so that it could always handle the memory management.

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

Helps: #3248
2024-02-06 11:02:24 +00:00
Philip Withnall
5f6b1516ae tests: Rework how slow param test is skipped
It’s more helpful to always register the test, even if it’s normally
skipped, since then the skip is recorded in the test logs so people can
see what’s ‘missing’ from them.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-02-06 11:01:46 +00:00