From 8a4755106d191bb99a4ff5c60fab7ce434418cee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 20 Dec 2023 07:36:04 +0100 Subject: [PATCH 1/4] girepository: Add gthash test to tests and run it --- girepository/gthash.c | 1 + girepository/{gthash-test.c => tests/gthash.c} | 2 ++ girepository/tests/meson.build | 1 + 3 files changed, 4 insertions(+) rename girepository/{gthash-test.c => tests/gthash.c} (99%) diff --git a/girepository/gthash.c b/girepository/gthash.c index 4a23e4ace..bc1c22a53 100644 --- a/girepository/gthash.c +++ b/girepository/gthash.c @@ -131,6 +131,7 @@ gi_typelib_hash_builder_prepare (GITypelibHashBuilder *builder) builder->dirmap_offset = ALIGN_VALUE (offset, 4); builder->packed_size = builder->dirmap_offset + (num_elts * sizeof(guint16)); out: + g_strfreev (strs); cmph_config_destroy (config); cmph_io_vector_adapter_destroy (io); return builder->buildable; diff --git a/girepository/gthash-test.c b/girepository/tests/gthash.c similarity index 99% rename from girepository/gthash-test.c rename to girepository/tests/gthash.c index ac55db91d..1b5dce115 100644 --- a/girepository/gthash-test.c +++ b/girepository/tests/gthash.c @@ -53,6 +53,8 @@ test_build_retrieve (void) g_assert (gi_typelib_hash_search (buf, "ZLibDecompressor", 4) == 42); g_assert (gi_typelib_hash_search (buf, "VolumeMonitor", 4) == 9); g_assert (gi_typelib_hash_search (buf, "FileMonitorFlags", 4) == 31); + + g_free (buf); } int diff --git a/girepository/tests/meson.build b/girepository/tests/meson.build index a3386a166..c89a8660e 100644 --- a/girepository/tests/meson.build +++ b/girepository/tests/meson.build @@ -3,6 +3,7 @@ girepository_tests = {} # Some GIR files are needed to test against if enable_gir girepository_tests += { + 'gthash' : {}, 'repository' : { 'depends': [glib_gir, gobject_gir], }, From 18d0b0eb403d9291cab77765ce5e5a168f5ce88f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 20 Dec 2023 07:38:01 +0100 Subject: [PATCH 2/4] girepository: Move cmph-bdz test to tests subfolder We can avoid to maintain the special case and still works fine --- girepository/cmph/meson.build | 20 ------------------- .../{cmph-bdz-test.c => tests/cmph-bdz.c} | 0 girepository/tests/meson.build | 3 +++ 3 files changed, 3 insertions(+), 20 deletions(-) rename girepository/{cmph-bdz-test.c => tests/cmph-bdz.c} (100%) diff --git a/girepository/cmph/meson.build b/girepository/cmph/meson.build index 2f4160f85..816294500 100644 --- a/girepository/cmph/meson.build +++ b/girepository/cmph/meson.build @@ -64,23 +64,3 @@ if cc.get_id() != 'msvc' '-Wno-type-limits', ]) endif - -test_env = environment() -test_env.set('G_TEST_SRCDIR', meson.current_source_dir()) -test_env.set('G_TEST_BUILDDIR', meson.current_build_dir()) - -cmph_test = executable('cmph-bdz-test', '../cmph-bdz-test.c', - dependencies: [ - cmph_dep, - libglib_dep, - libgobject_dep, - ], - c_args: custom_c_args + ['-UG_DISABLE_ASSERT'], -) - -test('cmph-bdz-test', cmph_test, - env: test_env, - protocol: test_protocol, - suite: ['girepository'], - timeout: test_timeout, -) diff --git a/girepository/cmph-bdz-test.c b/girepository/tests/cmph-bdz.c similarity index 100% rename from girepository/cmph-bdz-test.c rename to girepository/tests/cmph-bdz.c diff --git a/girepository/tests/meson.build b/girepository/tests/meson.build index c89a8660e..be560d2ad 100644 --- a/girepository/tests/meson.build +++ b/girepository/tests/meson.build @@ -3,6 +3,9 @@ girepository_tests = {} # Some GIR files are needed to test against if enable_gir girepository_tests += { + 'cmph-bdz': { + 'dependencies': [cmph_dep], + }, 'gthash' : {}, 'repository' : { 'depends': [glib_gir, gobject_gir], From d78b6c55bcc50e6749506f0633cdb05f305f2041 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 21 Dec 2023 02:36:41 +0100 Subject: [PATCH 3/4] girepository/tests: Add further checks on GObject methods infos --- girepository/tests/repository.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/girepository/tests/repository.c b/girepository/tests/repository.c index 762f9be79..c74d66605 100644 --- a/girepository/tests/repository.c +++ b/girepository/tests/repository.c @@ -80,6 +80,7 @@ test_repository_info (void) GITypelib *typelib = NULL; GIObjectInfo *object_info = NULL; GISignalInfo *signal_info = NULL; + GIFunctionInfo *method_info = NULL; GError *local_error = NULL; g_test_summary ("Test retrieving some basic info blobs from a typelib"); @@ -109,6 +110,20 @@ test_repository_info (void) g_assert_cmpint (gi_signal_info_get_flags (signal_info), ==, G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE | G_SIGNAL_DETAILED | G_SIGNAL_NO_HOOKS | G_SIGNAL_ACTION); + g_assert_cmpuint (gi_object_info_get_n_methods (object_info), >, 2); + + method_info = gi_object_info_find_method (object_info, "get_property"); + g_assert_nonnull (method_info); + g_assert_true (gi_callable_info_is_method ((GICallableInfo *) method_info)); + g_assert_cmpuint (gi_callable_info_get_n_args ((GICallableInfo *) method_info), ==, 2); + g_clear_pointer ((GIBaseInfo **) &method_info, gi_base_info_unref); + + method_info = gi_object_info_get_method (object_info, + gi_object_info_get_n_methods (object_info) - 1); + g_assert_true (gi_callable_info_is_method ((GICallableInfo *) method_info)); + g_assert_cmpuint (gi_callable_info_get_n_args ((GICallableInfo *) method_info), >, 0); + g_clear_pointer ((GIBaseInfo **) &method_info, gi_base_info_unref); + gi_base_info_unref ((GIBaseInfo *) signal_info); gi_base_info_unref ((GIBaseInfo *) object_info); g_clear_object (&repository); From 2ee2088f4a3514c841d9888da6d856addf686259 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 20 Dec 2023 23:41:10 +0100 Subject: [PATCH 4/4] girrepository: Drop trailing new line on GMessages --- girepository/girffi.c | 6 +++--- girepository/girmodule.c | 6 +++--- girepository/girnode.c | 15 +++++++-------- girepository/girparser.c | 8 ++++---- girepository/girwriter.c | 4 ++-- 5 files changed, 19 insertions(+), 20 deletions(-) diff --git a/girepository/girffi.c b/girepository/girffi.c index 590918623..f14ab84c7 100644 --- a/girepository/girffi.c +++ b/girepository/girffi.c @@ -392,7 +392,7 @@ gi_callable_info_create_closure (GICallableInfo *callable_info, closure = ffi_closure_alloc (sizeof (GIClosureWrapper), &exec_ptr); if (!closure) { - g_warning ("could not allocate closure\n"); + g_warning ("could not allocate closure"); return NULL; } closure->writable_self = closure; @@ -405,7 +405,7 @@ gi_callable_info_create_closure (GICallableInfo *callable_info, atypes); if (status != FFI_OK) { - g_warning ("ffi_prep_cif failed: %d\n", status); + g_warning ("ffi_prep_cif failed: %d", status); ffi_closure_free (closure); return NULL; } @@ -413,7 +413,7 @@ gi_callable_info_create_closure (GICallableInfo *callable_info, status = ffi_prep_closure_loc (&closure->ffi_closure, cif, callback, user_data, exec_ptr); if (status != FFI_OK) { - g_warning ("ffi_prep_closure failed: %d\n", status); + g_warning ("ffi_prep_closure failed: %d", status); ffi_closure_free (closure); return NULL; } diff --git a/girepository/girmodule.c b/girepository/girmodule.c index f81bc761f..d48572165 100644 --- a/girepository/girmodule.c +++ b/girepository/girmodule.c @@ -368,7 +368,7 @@ gi_ir_module_build_typelib (GIIrModule *module) nodes_with_attributes = NULL; n_entries = g_list_length (module->entries); - g_message ("%d entries (%d local), %d dependencies\n", n_entries, n_local_entries, + g_message ("%d entries (%d local), %d dependencies", n_entries, n_local_entries, g_list_length (module->dependencies)); dir_size = n_entries * sizeof (DirEntry); @@ -397,7 +397,7 @@ gi_ir_module_build_typelib (GIIrModule *module) size += sizeof (Section) * NUM_SECTIONS; - g_message ("allocating %d bytes (%d header, %d directory, %d entries)\n", + g_message ("allocating %d bytes (%d header, %d directory, %d entries)", size, header_size, dir_size, size - header_size - dir_size); data = g_malloc0 (size); @@ -535,7 +535,7 @@ gi_ir_module_build_typelib (GIIrModule *module) header->n_attributes = build.n_attributes; if (offset2 > old_offset + gi_ir_node_get_full_size (node)) - g_error ("left a hole of %d bytes\n", offset2 - old_offset - gi_ir_node_get_full_size (node)); + g_error ("left a hole of %d bytes", offset2 - old_offset - gi_ir_node_get_full_size (node)); } entry++; diff --git a/girepository/girnode.c b/girepository/girnode.c index 004d670e5..fb02e2425 100644 --- a/girepository/girnode.c +++ b/girepository/girnode.c @@ -192,7 +192,7 @@ gi_ir_node_new (GIIrNodeTypeId type, break; default: - g_error ("Unhandled node type %d\n", type); + g_error ("Unhandled node type %d", type); break; } @@ -421,7 +421,7 @@ gi_ir_node_free (GIIrNode *node) break; default: - g_error ("Unhandled node type %d\n", node->type); + g_error ("Unhandled node type %d", node->type); break; } @@ -560,8 +560,7 @@ gi_ir_node_get_size (GIIrNode *node) break; default: - g_error ("Unhandled node type '%s'\n", - gi_ir_node_type_to_string (node->type)); + g_error ("Unhandled node type '%s'", gi_ir_node_type_to_string (node->type)); size = 0; } @@ -672,7 +671,7 @@ gi_ir_node_get_full_size_internal (GIIrNode *parent, size += sizeof (ErrorTypeBlob); break; default: - g_error ("Unknown type tag %d\n", type->tag); + g_error ("Unknown type tag %d", type->tag); break; } } @@ -879,7 +878,7 @@ gi_ir_node_get_full_size_internal (GIIrNode *parent, break; default: - g_error ("Unknown type tag %d\n", node->type); + g_error ("Unknown type tag %d", node->type); size = 0; } @@ -991,7 +990,7 @@ gi_ir_node_add_member (GIIrNode *node, break; } default: - g_error ("Cannot add a member to unknown type tag type %d\n", + g_error ("Cannot add a member to unknown type tag type %d", node->type); break; } @@ -1576,7 +1575,7 @@ gi_ir_node_build_typelib (GIIrNode *node, break; default: - g_error ("Unknown type tag %d\n", type->tag); + g_error ("Unknown type tag %d", type->tag); break; } } diff --git a/girepository/girparser.c b/girepository/girparser.c index f6f65932f..04008a1a7 100644 --- a/girepository/girparser.c +++ b/girepository/girparser.c @@ -698,7 +698,7 @@ resolve_aliases (ParseContext *ctx, const gchar *type) seen_values = g_slist_prepend (seen_values, (char*)lookup); while (g_hash_table_lookup_extended (ctx->current_module->aliases, lookup, &orig, &value)) { - g_debug ("Resolved: %s => %s\n", lookup, (char*)value); + g_debug ("Resolved: %s => %s", lookup, (char*)value); lookup = value; if (g_slist_find_custom (seen_values, lookup, (GCompareFunc)strcmp) != NULL) @@ -1064,7 +1064,7 @@ parse_property_transfer (GIIrNodeProperty *property, GIIrNodeInterface *iface = (GIIrNodeInterface *)CURRENT_NODE (ctx); g_debug ("required attribute 'transfer-ownership' is missing from " - "property '%s' in type '%s.%s'. Assuming 'none'\n", + "property '%s' in type '%s.%s'. Assuming 'none'", property->node.name, ctx->namespace, iface->node.name); #endif transfer = "none"; @@ -2849,7 +2849,7 @@ parse_include (GMarkupParseContext *context, } g_free (girname); - g_debug ("Parsing include %s\n", girpath); + g_debug ("Parsing include %s", girpath); if (!g_file_get_contents (girpath, &buffer, &length, &error)) { @@ -3640,7 +3640,7 @@ end_element_handler (GMarkupParseContext *context, state_switch (ctx, ctx->prev_state); break; default: - g_error ("Unhandled state %d in end_element_handler\n", ctx->state); + g_error ("Unhandled state %d in end_element_handler", ctx->state); } } diff --git a/girepository/girwriter.c b/girepository/girwriter.c index 6bc9918de..c01aef27c 100644 --- a/girepository/girwriter.c +++ b/girepository/girwriter.c @@ -168,7 +168,7 @@ check_unresolved (GIBaseInfo *info) if (gi_base_info_get_info_type (info) != GI_INFO_TYPE_UNRESOLVED) return; - g_critical ("Found unresolved type '%s' '%s'\n", + g_critical ("Found unresolved type '%s' '%s'", gi_base_info_get_name (info), gi_base_info_get_namespace (info)); } @@ -1452,7 +1452,7 @@ gi_ir_writer_write (const char *filename, break; default: - g_error ("unknown info type %d\n", gi_base_info_get_info_type (info)); + g_error ("unknown info type %d", gi_base_info_get_info_type (info)); } gi_base_info_unref (info);