summaryrefslogtreecommitdiff
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
* gimarshallingtests: Return new floating gvariant in transfer containerHEADmainMarco Trevisan (Treviño)2023-04-171-1/+2
| | | | | | Apply the logic of previous commit to the array gvariant container function, so that bindings can test better the memory handling of those cases.
* gimarshallingtests: Add strong references to transfer full variantsMarco Trevisan (Treviño)2023-04-171-3/+9
| | | | | | | | | | We marked GVariant arrays containing floating references as transfer-full and this is leading bindings (i.e. gjs) to misleading behavior (see https://gitlab.gnome.org/GNOME/gjs/-/issues/499). This was definitely wrong, in fact a function returning a floating reference should have been transfer none, and so in this case the actual function transfer would have been container.
* tests/gimarshallingtests: Add a test case for zero-terminated GValue arraysMarco Trevisan (Treviño)2023-04-102-0/+24
| | | | Required to test how gjs handles this case.
* tests/gimarshallingtests: Unrefe the GByteArray object propertyMarco Trevisan (Treviño)2023-04-091-0/+1
| | | | We were leaking this, and so it was a false positive for the bindings
* gimarshallingtests: Do not leak GIMarshallingTests boxed structureMarco Trevisan (Treviño)2023-04-091-2/+4
| | | | | | | These are part of the array that we return, so there's no need to allocate a new structure. And this was leading to false positive leaks in bindings.
* Fix gir build when using subprojects' dependenciesAndoni Morales Alastruey2023-01-271-0/+1
| | | | | | | | https://github.com/mesonbuild/meson/pull/10275 introduced support in meson to use uninstalled .pc files in the meson-uninstalled directory to resolve dependencies built with subprojects. Replicate the same solution while all the custom_target are migrated to gnome.generate_dir
* tests: Use the appropriate assertion methodEmmanuele Bassi2023-01-081-53/+55
| | | | | | - assertEqual(value, None) → assertIsNone(value) - assertTrue(value is not None) → assertIsNotNone(value) - assertTrue(isinstance(value, Type)) → assertIsInstance(value, Type)
* Split disguised attribute into twoEmmanuele Bassi2023-01-085-6/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The disguised attribute started off as a way to indicate a typedef to a structure pointer, e.g. typedef struct Foo* FooPtr; Over the years, though, it started to include opaque structure types, e.g. typedef struct _FooObject FooObject; typedef struct _FooObjectClass FooObjectClass; This has led to issues in language bindings, code generators, and documentation generators, which now have issues when dealing with both pointer aliases and opaque types. An initial attempt at fixing this mess in commit f606183a ended up breaking Vala, and had to be reverted. To avoid breaking existing users we can follow a similar approach to the allow-none/nullable/optional solution: 1. introduce a new pair of attributes: "pointer" and "opaque" 2. deprecate the "disguised" attribute The "pointer" attribute covers the case of pointer types. The "opaque" attribute covers the case of opaque structured types. See also: https://gitlab.gnome.org/GNOME/vala/-/issues/735 Fixes: #101
* Revert "scanner: don't accept invalid symbols in binary expressions"Emmanuele Bassi2023-01-084-0/+48
| | | | This reverts commit b37f24b7e27a77c398f41cc331608aff806f0d42.
* GIMarshallingTests: Free and copy GStrv instancesMarco Trevisan (Treviño)2023-01-081-0/+2
| | | | | A GIMarshallingTestsBoxedStruct includes a GStrv, but we don't copy or free it properly.
* test: Add regression test for the new tagsEmmanuele Bassi2023-01-086-229/+260
|
* Add `default-value` annotationEmmanuele Bassi2023-01-082-7/+13
| | | | | | | An escape hatch to specify a freeform string for the default value of a property. Fixes: #4
* Skip default-value for non-transformable propertiesEmmanuele Bassi2023-01-081-34/+11
| | | | | | | If we can't transform a property default value to string, we are not going to add a default-value attribute to the GIR. This is necessary because non-transformable values may not always be pointers, so we cannot default to "NULL".
* Add an optional attribute for the property default valueEmmanuele Bassi2023-01-081-23/+64
| | | | | | | | | The default-value attribute for a property element is fundamentally meant for documentation generators. We only care about the GIR data, as the conversion from the default value to a string is lossy by definition, and may very well not roundtrip.
* scanner: don't accept invalid symbols in binary expressionsLubomir Rintel2023-01-084-48/+0
| | | | | | | | | | | | | | | | | | | | | The rules for binary expressions were entirely oblivious to the type of the operand symbols and assumed they're integer constants. This is very unfortunate, since it caused all sort of nonsense to end up getting accepted. One such example is the following define from NetworkManager's libnm: #define NM_SETTING_PARAM_SECRET (1 << (2 + G_PARAM_USER_SHIFT)) As G_PARAM_USER_SHIFT is unknown, it was parsed as an invalid symbol. The addition didn't care, treated it as: #define NM_SETTING_PARAM_SECRET (1 << (2 + 0)) Let's just ensure we get CSYMBOL_TYPE_CONST only when both operands actually have const_int_set. Otherwise just create CSYMBOL_TYPE_INVALID. That will cause the symbol to be dropped on the floor eventually, but that's probably much better than a having an invalid value.
* tests/scanner: add some tests for #definesLubomir Rintel2023-01-088-239/+337
| | | | | | | | Add one expanding to an expression we can't get a constant value from and another one for which we can. Note that the bad on one currently does evaluate, and it does so to a bad value. A separate commit with a diff to test suite will address that.
* gimarshallingtests: Add Structured Union types, unions with struct fieldsMarco Trevisan (Treviño)2022-11-212-0/+229
| | | | | | This allows to perform more introspection tests in gjs and other implementations when it comes to set/get fields or "cast" an union member to the main union type
* GIMarshallingTests: Add tests for caller allocated fixed size arraysMarco Trevisan (Treviño)2022-11-212-0/+36
| | | | | | | Such kind of arrays can be easily be allocated as we know the size of each array element. See: https://gitlab.gnome.org/GNOME/gjs/-/merge_requests/806
* Add missing (void) arguments to comply with -Wstrict-prototypesMarco Trevisan (Treviño)2022-10-061-1/+1
|
* gimarshallingtests: Fix annotation for GValue copy testPhilip Chimento2022-08-061-1/+1
| | | | | The test returns a newly allocated GValue, so it should not be marked transfer none.
* build: Add run_command() argumentEmmanuele Bassi2022-07-131-1/+1
| | | | The `check` argument to `run_command()` is now mandatory.
* Revert "scanner: Mark colliding properties as not introspectable"Emmanuele Bassi2022-02-133-1/+36
| | | | | | | | | This reverts commit 8e85d1ca937c166f07675d02fc84abb27d06ae11. Marking colliding properties as not introspectable breaks a bunch of existing API when compiling the GIR into the typelib, so we'll have to find another solution during the grace period.
* scanner: Mark colliding properties as not introspectableEmmanuele Bassi2022-02-123-36/+1
| | | | | We prefer methods, signals, and virtual methods to properties, in case of a collision.
* gimarshallingtests: Add GValue round-trip and copy functionsMarco Trevisan (Treviño)2022-01-112-0/+35
| | | | | We can use them in Gjs to verify whether a value is properly packed and unpacked to GValue.
* gimarshallingtests: Add some-string property to PropertiesObjectMarco Trevisan (Treviño)2022-01-112-0/+17
| | | | It's the only basic type missing, better to have for consistency.
* regress: Add a function to enable conversion between different fundamentalMarco Trevisan (Treviño)2022-01-114-147/+184
| | | | | We want to be able to test whether it's possible to convert two different fundamental types through GValue, so add a function for this.
* Regress: Add further subtype of fundamental with no set/get functionsMarco Trevisan (Treviño)2022-01-114-151/+242
| | | | | This can be used to test we don't do unexpected conversions between invalid types.
* regress: Add Fundamental type with no set/get-value-func'sMarco Trevisan (Treviño)2022-01-1126-149/+1184
| | | | | | | | | | A fundamental type may or may not provide set and get value functions, the regress implementations always provide one, so define a new type with no such functions so that we can test this case in Gjs. To avoid repeating lots of duplicated code, we re-use the same functions of RegressTestFundamentalObject when possible, by using the same structure.
* build: Do not use deprecated APIEmmanuele Bassi2022-01-111-2/+2
|
* build: Avoid the doctemplates hackEmmanuele Bassi2022-01-111-11/+13
| | | | | | | | | | | | The hack that copies the doctemplates directory into the build directory has stopped working with newer versions of Meson; while it's possible to copy files, custom_target() cannot depend on a directory. Additionally, the dependency has always been broken. Instead, we enumerate the template files—after all, it's not like they change a lot—and then we list them as dependencies for the test targets. Fixes: #414
* Add "forever" scopeEmmanuele Bassi2022-01-092-3/+3
| | | | | | | | Some functions are meant to exist for the entire duration of the process, and thus have no need for a notification function because one will never be called. Fixes: #49
* scanner: Warn if property annotations are mismatchedEmmanuele Bassi2021-08-051-3/+7
| | | | | | If the (set-property) and (get-property) annotations on methods do not round trip with the (setter) and (getter) annotations on the corresponding property, we want to emit a warning.
* scanner: Try to pair properties with accessor methodsEmmanuele Bassi2021-08-051-2/+9
| | | | | | | The heuristic is pretty trivial: for any given non-construct-only, writable property, we check if there's a `set_<property>` method; for any given readable property, we check if there's a `get_<property>` method.
* tests: Add a Regress test for the property accessors annotationsEmmanuele Bassi2021-08-052-5/+9
|
* tests: Check new property accessors annotationsEmmanuele Bassi2021-08-0510-275/+579
| | | | Add an accessors pair to Regress.TestObj and annotate them.
* build: Export warnlib sources as variablesPhilip Chimento2021-08-051-0/+2
| | | | | | | This is so that GJS can use these variables in its own build files when including gobject-introspection as a Meson subproject. Previously we took the approach of using the files in their installed locations, but that doesn't work as a subproject.
* introspection: Remove 'caller-allocates' from POD typesPhilip Chimento2021-07-292-4/+4
| | | | | | | | | The (out caller-allocates) and (out callee-allocates) annotations are meant for structured or pointer types. Plain old data types are just regular out parameters and don't need the annotation about who allocates them. See: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2005
* Add glib:name to enum memberMarc-André Lureau2021-06-201-28/+56
| | | | | | | This member will contain the string from the GEnumValue/GFlagsValue 'value_name' introspection dump. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* scanner: fix enum member c:identifierMarc-André Lureau2021-06-201-3/+3
| | | | | | Don't rely on runtime name, but on C header parsed symbol. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* tests/repository: Fix leak in test_constructor_return_typeDavid King2021-06-181-0/+1
| | | | | | Found by Coverity. https://bugzilla.redhat.com/show_bug.cgi?id=1938731
* Make test suite work with cross-related optionsJohn Ericson2021-05-233-41/+40
| | | | | | | | | | Because of skepticism I received in #224, I made this PR which keeps the testsuite and CI improvements but doesn't add any new build options. I hope this would be less controversial: - no new knobs - tests for those using existing build options - CI tests `build_introspection_data = false`
* Meson: Fix build when gobject-introspection is a subprojectXavier Claessens2021-03-251-6/+6
| | | | | meson.source_root() return the root of the main project, but in this case we want the root of the gobject-introspection (sub)project.
* tests: Update line numbers for expected Regress GIREmmanuele Bassi2021-03-121-8/+8
|
* Use g_memdup2() with newer versions of GLibEmmanuele Bassi2021-03-121-0/+20
| | | | | The g_memdup() function has been deprecated, so we should use the new g_memdup2() function if available.
* tests: Add "signals" test objectwip/carlosg/signal-testsCarlos Garnacho2021-03-032-0/+107
| | | | | | | | It is worth to test marshalling of signal arguments, add a basic (and barebones) object to add signals and emission methods to, so bindings can test the signal handlers. Related: https://gitlab.gnome.org/GNOME/gjs/-/issues/377
* Always pass an encoding to open() using text modeChristoph Reiter2020-11-073-3/+3
| | | | | | | | Otherwise we'll end up using the locale encoding. While it's usually utf-8, that's not the case on Windows. There is one place where a file with filenames is passed, not sure there so I left it and passed a explicit None.
* Revert "giscanner: Fix section matching for documentation"Mathieu Duponchelle2020-09-291-34/+0
| | | | | | | | | This reverts commit de6512b31b614567bf1800406303d1ccfb6d9455. This was causing naming conflicts when the SECTION documentation was picked over the class documentation. See https://gitlab.gnome.org/GNOME/gobject-introspection/-/issues/360
* girmarshalling tests: Diagnose GValue not holding enum/flagswip/smcv/test-more-flagsSimon McVittie2020-09-191-0/+4
| | | | | | | | If g_value_get_enum() or g_value_get_flags() is about to fail with a precondition check failure, we can improve diagnostics by issuing a more informative critical warning. Signed-off-by: Simon McVittie <smcv@debian.org>
* gimarshallingtests: Add more tests for flagsSimon McVittie2020-09-192-0/+30
| | | | | | | | Bindings sometimes need to handle flags and enums separately, so everything that is tested for enums should ideally be tested separately for flags. Signed-off-by: Simon McVittie <smcv@debian.org>
* tests: Add a test-case for a vfunc returning flags in different waysSimon McVittie2020-09-192-0/+44
| | | | | | | We already had a test for enums, but flags are not precisely the same, so testing both can give bindings better coverage. Signed-off-by: Simon McVittie <smcv@debian.org>