LCOV - code coverage report
Current view: top level - girepository/tests - test-common.c (source / functions) Coverage Total Hit
Test: unnamed Lines: 100.0 % 23 23
Test Date: 2024-11-26 05:23:01 Functions: 100.0 % 3 3
Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : /*
       2                 :             :  * Copyright 2023 GNOME Foundation, Inc.
       3                 :             :  * Copyright 2024 Philip Chimento <philip.chimento@gmail.com>
       4                 :             :  *
       5                 :             :  * SPDX-License-Identifier: LGPL-2.1-or-later
       6                 :             :  *
       7                 :             :  * This library is free software; you can redistribute it and/or
       8                 :             :  * modify it under the terms of the GNU Lesser General Public
       9                 :             :  * License as published by the Free Software Foundation; either
      10                 :             :  * version 2.1 of the License, or (at your option) any later version.
      11                 :             :  *
      12                 :             :  * This library is distributed in the hope that it will be useful,
      13                 :             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      14                 :             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      15                 :             :  * Lesser General Public License for more details.
      16                 :             :  *
      17                 :             :  * You should have received a copy of the GNU Lesser General
      18                 :             :  * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
      19                 :             :  */
      20                 :             : 
      21                 :             : #include "config.h"
      22                 :             : 
      23                 :             : #include "girepository.h"
      24                 :             : #include "glib.h"
      25                 :             : #include "test-common.h"
      26                 :             : 
      27                 :             : void
      28                 :          10 : repository_init (int *argc,
      29                 :             :                  char **argv[])
      30                 :             : {
      31                 :             :   /* Isolate from the system typelibs and GIRs. */
      32                 :          10 :   g_setenv ("GI_TYPELIB_PATH", "/dev/null", TRUE);
      33                 :          10 :   g_setenv ("GI_GIR_PATH", "/dev/null", TRUE);
      34                 :             : 
      35                 :          10 :   g_test_init (argc, argv, G_TEST_OPTION_ISOLATE_DIRS, NULL);
      36                 :          10 : }
      37                 :             : 
      38                 :             : void
      39                 :          62 : repository_setup (RepositoryFixture *fx,
      40                 :             :                   const void *data)
      41                 :             : {
      42                 :          62 :   GITypelib *typelib = NULL;
      43                 :          62 :   GError *local_error = NULL;
      44                 :          62 :   TypelibLoadSpec *load_spec = (TypelibLoadSpec *) data;
      45                 :             : 
      46                 :          62 :   fx->repository = gi_repository_new ();
      47                 :          62 :   g_assert_nonnull (fx->repository);
      48                 :             : 
      49                 :          62 :   fx->gobject_typelib_dir = g_test_build_filename (G_TEST_BUILT, "..", "introspection", NULL);
      50                 :          62 :   g_test_message ("Using GI_TYPELIB_DIR = %s", fx->gobject_typelib_dir);
      51                 :          62 :   gi_repository_prepend_search_path (fx->repository, fx->gobject_typelib_dir);
      52                 :             : 
      53                 :          62 :   if (load_spec)
      54                 :             :     {
      55                 :          62 :       typelib = gi_repository_require (fx->repository, load_spec->name, load_spec->version, 0, &local_error);
      56                 :          62 :       g_assert_no_error (local_error);
      57                 :          62 :       g_assert_nonnull (typelib);
      58                 :             :     }
      59                 :          62 : }
      60                 :             : 
      61                 :             : void
      62                 :          62 : repository_teardown (RepositoryFixture *fx,
      63                 :             :                      const void *unused)
      64                 :             : {
      65                 :          62 :   g_clear_pointer (&fx->gobject_typelib_dir, g_free);
      66                 :          62 :   g_clear_object (&fx->repository);
      67                 :          62 : }
        

Generated by: LCOV version 2.0-1