|
From: Kouhei S. <nul...@cl...> - 2014-01-19 09:20:50
|
Kouhei Sutou 2014-01-19 18:20:25 +0900 (Sun, 19 Jan 2014) New Revision: 36e514e268ace2897c4f97e034f45b92c76d9394 https://github.com/clear-code/cutter/commit/36e514e268ace2897c4f97e034f45b92c76d9394 Message: Add loader customizer mechanism Added files: cutter/cut-loader-customizer-factory-builder.c cutter/cut-loader-customizer-factory-builder.h cutter/cut-loader-customizer.c cutter/cut-loader-customizer.h Modified files: configure.ac cutter/Makefile.am cutter/cut-contractor.c cutter/cut-repository.c cutter/cut-repository.h cutter/cut-run-context.c cutter/cut-run-context.h test/run-test.sh Modified: configure.ac (+12 -0) =================================================================== --- configure.ac 2014-01-19 17:52:52 +0900 (178d072) +++ configure.ac 2014-01-19 18:20:25 +0900 (a616d13) @@ -333,6 +333,16 @@ stream_factory_moduledir="\${factory_moduledir}/stream" AC_SUBST(stream_factory_moduledir) dnl ************************************************************** +dnl Configure for LoaderCustomizer modules. +dnl ************************************************************** + +loader_customizer_moduledir="\${moduledir}/loader-customizer" +AC_SUBST(loader_customizer_moduledir) + +loader_customizer_factory_moduledir="\${factory_moduledir}/loader-customizer" +AC_SUBST(loader_customizer_factory_moduledir) + +dnl ************************************************************** dnl Check for GTK+ dnl ************************************************************** m4_ifdef([AM_PATH_GTK_2_0], @@ -683,6 +693,8 @@ CUTTER_CFLAGS="$CUTTER_CFLAGS -DREPORT_MODULE_DIR=\\\"\"\$(report_moduledir)\"\\ CUTTER_CFLAGS="$CUTTER_CFLAGS -DREPORT_FACTORY_MODULE_DIR=\\\"\"\$(report_factory_moduledir)\"\\\"" CUTTER_CFLAGS="$CUTTER_CFLAGS -DSTREAM_MODULE_DIR=\\\"\"\$(stream_moduledir)\"\\\"" CUTTER_CFLAGS="$CUTTER_CFLAGS -DSTREAM_FACTORY_MODULE_DIR=\\\"\"\$(stream_factory_moduledir)\"\\\"" +CUTTER_CFLAGS="$CUTTER_CFLAGS -DLOADER_CUSTOMIZER_MODULE_DIR=\\\"\"\$(loader_customizer_moduledir)\"\\\"" +CUTTER_CFLAGS="$CUTTER_CFLAGS -DLOADER_CUSTOMIZER_FACTORY_MODULE_DIR=\\\"\"\$(loader_customizer_factory_moduledir)\"\\\"" CUTTER_CFLAGS="$CUTTER_CFLAGS -DFACTORY_MODULE_DIR=\\\"\"\$(factory_moduledir)\"\\\"" CUTTER_CFLAGS="$CUTTER_CFLAGS -DICONS_DIR=\\\"\"\$(iconsdir)\"\\\"" AC_SUBST(CUTTER_CFLAGS) Modified: cutter/Makefile.am (+6 -2) =================================================================== --- cutter/Makefile.am 2014-01-19 17:52:52 +0900 (40178fa) +++ cutter/Makefile.am 2014-01-19 18:20:25 +0900 (c4d0745) @@ -71,7 +71,9 @@ libcutter_public_headers = \ cut-ui.h \ cut-unified-differ.h \ cut-verbose-level.h \ - cut-logger.h + cut-logger.h \ + cut-loader-customizer-factory-builder.h \ + cut-loader-customizer.h noinst_headers = \ cut-crash-backtrace.h \ @@ -173,7 +175,9 @@ libcutter_sources = \ cut-unified-differ.c \ cut-utils.c \ cut-verbose-level.c \ - cut-logger.c + cut-logger.c \ + cut-loader-customizer-factory-builder.c \ + cut-loader-customizer.c libcutter_la_SOURCES = \ $(cutter_public_headers) \ Modified: cutter/cut-contractor.c (+20 -1) =================================================================== --- cutter/cut-contractor.c 2014-01-19 17:52:52 +0900 (af304b8) +++ cutter/cut-contractor.c 2014-01-19 18:20:25 +0900 (1c3b8e6) @@ -1,6 +1,6 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* - * Copyright (C) 2007 Kouhei Sutou <ko...@co...> + * Copyright (C) 2007-2014 Kouhei Sutou <ko...@cl...> * * This library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -31,6 +31,7 @@ #include "cut-report-factory-builder.h" #include "cut-stream-factory-builder.h" #include "cut-ui-factory-builder.h" +#include "cut-loader-customizer-factory-builder.h" #define CUT_CONTRACTOR_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), CUT_TYPE_CONTRACTOR, CutContractorPrivate)) @@ -38,6 +39,7 @@ typedef struct _CutContractorPrivate CutContractorPrivate; struct _CutContractorPrivate { GList *listener_builders; + CutLoaderCustomizerFactoryBuilder *loader_customizer_factory_builder; }; G_DEFINE_TYPE(CutContractor, cut_contractor, G_TYPE_OBJECT) @@ -89,14 +91,31 @@ load_ui_factory (CutContractor *contractor) } static void +load_loader_customizer_factory (CutContractor *contractor) +{ + CutContractorPrivate *priv = CUT_CONTRACTOR_GET_PRIVATE(contractor); + CutFactoryBuilder *builder; + const gchar *module_dir; + + builder = CUT_FACTORY_BUILDER(priv->loader_customizer_factory_builder); + + module_dir = cut_factory_builder_get_module_dir(builder); + + cut_module_factory_load(module_dir, "loader-customizer"); +} + +static void cut_contractor_init (CutContractor *contractor) { CutContractorPrivate *priv = CUT_CONTRACTOR_GET_PRIVATE(contractor); cut_module_factory_init(); priv->listener_builders = create_default_listener_builders(); + priv->loader_customizer_factory_builder = + g_object_new(CUT_TYPE_LOADER_CUSTOMIZER_FACTORY_BUILDER, NULL); load_ui_factory(contractor); + load_loader_customizer_factory(contractor); } static void Added: cutter/cut-loader-customizer-factory-builder.c (+141 -0) 100644 =================================================================== --- /dev/null +++ cutter/cut-loader-customizer-factory-builder.c 2014-01-19 18:20:25 +0900 (71b3154) @@ -0,0 +1,141 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2014 Kouhei Sutou <ko...@cl...> + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif /* HAVE_CONFIG_H */ + +#include <string.h> +#include <glib.h> +#include <glib/gi18n-lib.h> + +#include "cut-utils.h" +#include "cut-loader-customizer-factory-builder.h" +#include "cut-module-factory.h" +#include "cut-module-factory-utils.h" + +static CutLoaderCustomizerFactoryBuilder *the_builder = NULL; +#ifdef G_OS_WIN32 +static gchar *win32_loader_customizer_factory_module_dir = NULL; +#endif + +static GObject *constructor (GType type, + guint n_props, + GObjectConstructParam *props); + +static GList *build (CutFactoryBuilder *builder); +static GList *build_all (CutFactoryBuilder *builder); +static const gchar *get_type_name (CutFactoryBuilder *builder); + +G_DEFINE_TYPE(CutLoaderCustomizerFactoryBuilder, + cut_loader_customizer_factory_builder, + CUT_TYPE_FACTORY_BUILDER) + +static void +cut_loader_customizer_factory_builder_class_init (CutLoaderCustomizerFactoryBuilderClass *klass) +{ + GObjectClass *gobject_class; + CutFactoryBuilderClass *builder_class; + + gobject_class = G_OBJECT_CLASS(klass); + builder_class = CUT_FACTORY_BUILDER_CLASS(klass); + + gobject_class->constructor = constructor; + + builder_class->build = build; + builder_class->build_all = build_all; + builder_class->get_type_name = get_type_name; +} + +static GObject * +constructor (GType type, guint n_props, GObjectConstructParam *props) +{ + GObject *object; + + if (!the_builder) { + GObjectClass *klass; + klass = G_OBJECT_CLASS(cut_loader_customizer_factory_builder_parent_class); + object = klass->constructor(type, n_props, props); + the_builder = CUT_LOADER_CUSTOMIZER_FACTORY_BUILDER(object); + } else { + object = g_object_ref(the_builder); + } + + return object; +} + +static void +cut_loader_customizer_factory_builder_init (CutLoaderCustomizerFactoryBuilder *builder) +{ + const gchar *dir; + + dir = g_getenv("CUT_LOADER_CUSTOMIZER_FACTORY_MODULE_DIR"); + if (!dir) { +#ifdef G_OS_WIN32 + if (!win32_loader_customizer_factory_module_dir) + win32_loader_customizer_factory_module_dir = + cut_win32_build_factory_module_dir_name("loader-cutomizer"); + dir = win32_loader_customizer_factory_module_dir; +#else + dir = LOADER_CUSTOMIZER_FACTORY_MODULE_DIR; +#endif + } + + g_object_set(G_OBJECT(builder), + "module-dir", dir, + NULL); + cut_module_factory_load(dir, "loader-customizer"); +} + +static GList * +build (CutFactoryBuilder *builder) +{ + return build_all(builder); +} + +static GList * +build_all (CutFactoryBuilder *builder) +{ + GList *factories = NULL, *node; + GList *factory_names; + + factory_names = cut_module_factory_get_names("loader-customizer"); + + for (node = factory_names; node; node = g_list_next(node)) { + CutModuleFactory *module_factory; + module_factory = cut_module_factory_new("loader-customizer", + node->data, NULL); + factories = g_list_prepend(factories, module_factory); + } + + g_list_foreach(factory_names, (GFunc)g_free, NULL); + g_list_free(factory_names); + + return g_list_reverse(factories); +} + +static const gchar * +get_type_name (CutFactoryBuilder *builder) +{ + return "loader-cutomizer"; +} + +/* +vi:ts=4:nowrap:ai:expandtab:sw=4 +*/ Added: cutter/cut-loader-customizer-factory-builder.h (+71 -0) 100644 =================================================================== --- /dev/null +++ cutter/cut-loader-customizer-factory-builder.h 2014-01-19 18:20:25 +0900 (eb8f3d9) @@ -0,0 +1,71 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2014 Kouhei Sutou <ko...@cl...> + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#ifndef __CUT_LOADER_CUSTOMIZER_FACTORY_BUILDER_H__ +#define __CUT_LOADER_CUSTOMIZER_FACTORY_BUILDER_H__ + +#include <glib-object.h> + +#include <cutter/cut-factory-builder.h> + +G_BEGIN_DECLS + +#define CUT_TYPE_LOADER_CUSTOMIZER_FACTORY_BUILDER \ + (cut_loader_customizer_factory_builder_get_type ()) +#define CUT_LOADER_CUSTOMIZER_FACTORY_BUILDER(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj), \ + CUT_TYPE_LOADER_CUSTOMIZER_FACTORY_BUILDER, \ + CutLoaderCustomizerFactoryBuilder)) +#define CUT_LOADER_CUSTOMIZER_FACTORY_BUILDER_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass), \ + CUT_TYPE_LOADER_CUSTOMIZER_FACTORY_BUILDER, \ + CutLoaderCustomizerFactoryBuilderClass)) +#define CUT_IS_LOADER_CUSTOMIZER_FACTORY_BUILDER(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj), \ + CUT_TYPE_LOADER_CUSTOMIZER_FACTORY_BUILDER)) +#define CUT_IS_LOADER_CUSTOMIZER_FACTORY_BUILDER_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE((klass), \ + CUT_TYPE_LOADER_CUSTOMIZER_FACTORY_BUILDER)) +#define CUT_LOADER_CUSTOMIZER_FACTORY_BUILDER_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS((obj), \ + CUT_TYPE_LOADER_CUSTOMIZER_FACTORY_BUILDER, \ + CutLoaderCustomizerFactoryBuilderClass)) + +typedef struct _CutLoaderCustomizerFactoryBuilder CutLoaderCustomizerFactoryBuilder; +typedef struct _CutLoaderCustomizerFactoryBuilderClass CutLoaderCustomizerFactoryBuilderClass; + +struct _CutLoaderCustomizerFactoryBuilder +{ + CutFactoryBuilder object; +}; + +struct _CutLoaderCustomizerFactoryBuilderClass +{ + CutFactoryBuilderClass parent_class; +}; + +GType cut_loader_customizer_factory_builder_get_type (void) G_GNUC_CONST; + +G_END_DECLS + +#endif /* __CUT_LOADER_CUSTOMIZER_FACTORY_BUILDER_H__ */ + +/* +vi:nowrap:ai:expandtab:sw=4 +*/ Added: cutter/cut-loader-customizer.c (+82 -0) 100644 =================================================================== --- /dev/null +++ cutter/cut-loader-customizer.c 2014-01-19 18:20:25 +0900 (6aeaa65) @@ -0,0 +1,82 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2014 Kouhei Sutou <ko...@cl...> + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif /* HAVE_CONFIG_H */ + +#include <glib.h> + +#include "cut-loader-customizer.h" +#include "cut-module.h" + +#define CUT_LOADER_CUSTOMIZER_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE((obj), \ + CUT_TYPE_LOADER_CUSTOMIZER, \ + CutLoaderCustomizerPrivate)) + +G_DEFINE_ABSTRACT_TYPE(CutLoaderCustomizer, cut_loader_customizer, G_TYPE_OBJECT) +CUT_MODULE_DEFINE_INTERNAL_DEFINITIONS(loader_customizer, LOADER_CUSTOMIZER) + +static void +cut_loader_customizer_class_init (CutLoaderCustomizerClass *klass) +{ +} + +static void +cut_loader_customizer_init (CutLoaderCustomizer *report) +{ +} + +CutLoaderCustomizer * +cut_loader_customizer_new (const gchar *name, + const gchar *first_property, ...) +{ + CutModule *module; + GObject *customizer; + va_list var_args; + + module = cut_loader_customizer_load_module(name); + g_return_val_if_fail(module != NULL, NULL); + + va_start(var_args, first_property); + customizer = cut_module_instantiate(module, + first_property, var_args); + va_end(var_args); + + return CUT_LOADER_CUSTOMIZER(customizer); +} + +void +cut_loader_customizer_customize (CutLoaderCustomizer *customizer, + CutLoader *loader) +{ + CutLoaderCustomizerClass *klass; + + g_return_val_if_fail(CUT_IS_LOADER_CUSTOMIZER(customizer), NULL); + + klass = CUT_LOADER_CUSTOMIZER_GET_CLASS(customizer); + if (klass->customize) { + klass->customize(customizer, loader); + } +} + +/* +vi:ts=4:nowrap:ai:expandtab:sw=4 +*/ Added: cutter/cut-loader-customizer.h (+81 -0) 100644 =================================================================== --- /dev/null +++ cutter/cut-loader-customizer.h 2014-01-19 18:20:25 +0900 (c40b16b) @@ -0,0 +1,81 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2014 Kouhei Sutou <ko...@cl...> + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#ifndef __CUT_LOADER_CUSTOMIZER_H__ +#define __CUT_LOADER_CUSTOMIZER_H__ + +#include <glib-object.h> + +#include <cutter/cut-loader.h> + +G_BEGIN_DECLS + +#define CUT_TYPE_LOADER_CUSTOMIZER \ + (cut_loader_customizer_get_type()) +#define CUT_LOADER_CUSTOMIZER(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj), \ + CUT_TYPE_LOADER_CUSTOMIZER, \ + CutLoaderCustomizer)) +#define CUT_LOADER_CUSTOMIZER_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass), \ + CUT_TYPE_LOADER_CUSTOMIZER, \ + CutLoaderCustomizerClass)) +#define CUT_IS_LOADER_CUSTOMIZER(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj), \ + CUT_TYPE_LOADER_CUSTOMIZER)) +#define CUT_IS_LOADER_CUSTOMIZER_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE((klass), \ + CUT_TYPE_LOADER_CUSTOMIZER)) +#define CUT_LOADER_CUSTOMIZER_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS((obj), \ + CUT_TYPE_LOADER_CUSTOMIZER, \ + CutLoaderCustomizerClass)) + +typedef struct _CutLoaderCustomizer CutLoaderCustomizer; +typedef struct _CutLoaderCustomizerClass CutLoaderCustomizerClass; + +struct _CutLoaderCustomizer +{ + GObject object; +}; + +struct _CutLoaderCustomizerClass +{ + GObjectClass parent_class; + + void (*customize) (CutLoaderCustomizer *customizer, + CutLoader *loader); +}; + +GType cut_loader_customizer_get_type (void) G_GNUC_CONST; + +CutLoaderCustomizer * + cut_loader_customizer_new (const gchar *name, + const gchar *first_property, + ...); +void cut_loader_customizer_customize (CutLoaderCustomizer *customizer, + CutLoader *loader); + +G_END_DECLS + +#endif /* __CUT_LOADER_CUSTOMIZER_H__ */ + +/* +vi:ts=4:nowrap:ai:expandtab:sw=4 +*/ Modified: cutter/cut-repository.c (+25 -1) =================================================================== --- cutter/cut-repository.c 2014-01-19 17:52:52 +0900 (ec9a0b6) +++ cutter/cut-repository.c 2014-01-19 18:20:25 +0900 (307d701) @@ -1,6 +1,6 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* - * Copyright (C) 2007-2010 Kouhei Sutou <ko...@cl...> + * Copyright (C) 2007-2014 Kouhei Sutou <ko...@cl...> * * This library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -38,6 +38,7 @@ struct _CutRepositoryPrivate gchar *directory; GList *exclude_files_regexs; GList *exclude_dirs_regexs; + GList *loader_customizers; GList *loaders; gint deep; @@ -96,6 +97,7 @@ cut_repository_init (CutRepository *repository) priv->loaders = NULL; priv->exclude_files_regexs = NULL; priv->exclude_dirs_regexs = NULL; + priv->loader_customizers = NULL; priv->deep = 0; priv->test_suite_loader = NULL; priv->keep_opening_modules = FALSE; @@ -135,6 +137,12 @@ dispose (GObject *object) priv->exclude_dirs_regexs = NULL; } + if (priv->loader_customizers) { + g_list_foreach(priv->loader_customizers, (GFunc)g_object_unref, NULL); + g_list_free(priv->loader_customizers); + priv->loader_customizers = NULL; + } + if (priv->test_suite_loader) { g_object_unref(priv->test_suite_loader); priv->test_suite_loader = NULL; @@ -305,6 +313,7 @@ cut_repository_collect_loader (CutRepository *repository, const gchar *dir_name, } else { CutLoader *loader; gchar *relative_path; + GList *node; if (cut_utils_filter_match(priv->exclude_files_regexs, entry) || !g_str_has_suffix(entry, "."G_MODULE_SUFFIX)) { @@ -318,6 +327,10 @@ cut_repository_collect_loader (CutRepository *repository, const gchar *dir_name, cut_loader_set_keep_opening(loader, priv->keep_opening_modules); cut_loader_set_enable_convenience_attribute_definition( loader, priv->enable_convenience_attribute_definition); + for (node = priv->loader_customizers; node; node = g_list_next(node)) { + CutLoaderCustomizer *customizer = node->data; + cut_loader_customizer_customize(customizer, loader); + } if (is_test_suite_so_path_name(path_name)) { update_test_suite_loader(priv, loader, paths->len); } else { @@ -394,6 +407,17 @@ cut_repository_set_exclude_directories (CutRepository *repository, const gchar * priv->exclude_dirs_regexs = cut_utils_filter_to_regexs(dirs); } +void +cut_repository_add_loader_customizer (CutRepository *repository, + CutLoaderCustomizer *customizer) +{ + CutRepositoryPrivate *priv = CUT_REPOSITORY_GET_PRIVATE(repository); + + g_object_ref(customizer); + priv->loader_customizers = + g_list_append(priv->loader_customizers, customizer); +} + /* vi:ts=4:nowrap:ai:expandtab:sw=4 */ Modified: cutter/cut-repository.h (+5 -1) =================================================================== --- cutter/cut-repository.h 2014-01-19 17:52:52 +0900 (c42f4bd) +++ cutter/cut-repository.h 2014-01-19 18:20:25 +0900 (322ace2) @@ -1,6 +1,6 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* - * Copyright (C) 2007 Kouhei Sutou <ko...@co...> + * Copyright (C) 2007-2014 Kouhei Sutou <ko...@cl...> * * This library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -24,6 +24,7 @@ #include "cut-test.h" #include "cut-test-suite.h" +#include "cut-loader-customizer.h" G_BEGIN_DECLS @@ -66,6 +67,9 @@ void cut_repository_set_exclude_files (CutRepository *repository, void cut_repository_set_exclude_directories (CutRepository *repository, const gchar **directory_names); +void cut_repository_add_loader_customizer + (CutRepository *repository, + CutLoaderCustomizer *customizer); G_END_DECLS Modified: cutter/cut-run-context.c (+31 -1) =================================================================== --- cutter/cut-run-context.c 2014-01-19 17:52:52 +0900 (2addf3b) +++ cutter/cut-run-context.c 2014-01-19 18:20:25 +0900 (27e6028) @@ -1,6 +1,6 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* - * Copyright (C) 2008-2013 Kouhei Sutou <ko...@cl...> + * Copyright (C) 2008-2014 Kouhei Sutou <ko...@cl...> * * This library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -77,6 +77,7 @@ struct _CutRunContextPrivate gchar *log_directory; gchar **target_test_case_names; gchar **target_test_names; + GList *loader_customizers; gboolean canceled; CutTestSuite *test_suite; GList *listeners; @@ -972,6 +973,7 @@ cut_run_context_init (CutRunContext *context) priv->exclude_directories = NULL; priv->target_test_case_names = NULL; priv->target_test_names = NULL; + priv->loader_customizers = NULL; priv->canceled = FALSE; priv->test_suite = NULL; priv->listeners = NULL; @@ -1052,6 +1054,10 @@ dispose (GObject *object) g_strfreev(priv->target_test_names); priv->target_test_names = NULL; + g_list_foreach(priv->loader_customizers, (GFunc)g_object_unref, NULL); + g_list_free(priv->loader_customizers); + priv->loader_customizers = NULL; + g_strfreev(priv->command_line_args); priv->command_line_args = NULL; @@ -1718,6 +1724,24 @@ cut_run_context_get_target_test_names (CutRunContext *context) return (const gchar **)priv->target_test_names; } +void +cut_run_context_add_loader_customizer (CutRunContext *context, + CutLoaderCustomizer *customizer) +{ + CutRunContextPrivate *priv = CUT_RUN_CONTEXT_GET_PRIVATE(context); + + g_object_ref(customizer); + priv->loader_customizers = g_list_append(priv->loader_customizers, + customizer); +} + +const GList * +cut_run_context_get_loader_customizers (CutRunContext *context) +{ + CutRunContextPrivate *priv = CUT_RUN_CONTEXT_GET_PRIVATE(context); + return priv->loader_customizers; +} + guint cut_run_context_get_n_tests (CutRunContext *context) { @@ -1852,6 +1876,7 @@ cut_run_context_create_test_suite (CutRunContext *context) CutRepository *repository; CutTestSuite *suite; const gchar **exclude_files, **exclude_directories; + GList *node; priv = CUT_RUN_CONTEXT_GET_PRIVATE(context); repository = cut_repository_new(priv->test_directory); @@ -1863,6 +1888,11 @@ cut_run_context_create_test_suite (CutRunContext *context) cut_repository_set_exclude_files(repository, exclude_files); exclude_directories = (const gchar **)priv->exclude_directories; cut_repository_set_exclude_directories(repository, exclude_directories); + for (node = priv->loader_customizers; node; node = g_list_next(node)) { + CutLoaderCustomizer *customizer = node->data; + cut_repository_add_loader_customizer(repository, customizer); + } + suite = cut_repository_create_test_suite(repository); g_object_unref(repository); Modified: cutter/cut-run-context.h (+6 -1) =================================================================== --- cutter/cut-run-context.h 2014-01-19 17:52:52 +0900 (0ea6fa3) +++ cutter/cut-run-context.h 2014-01-19 18:20:25 +0900 (be3362f) @@ -1,6 +1,6 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* - * Copyright (C) 2008-2009 Kouhei Sutou <ko...@co...> + * Copyright (C) 2008-2014 Kouhei Sutou <ko...@cl...> * * This library is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -24,6 +24,7 @@ #include <cutter/cut-test-suite.h> #include <cutter/cut-test-iterator.h> +#include <cutter/cut-loader-customizer.h> #include <cutter/cut-private.h> G_BEGIN_DECLS @@ -251,6 +252,10 @@ const gchar **cut_run_context_get_target_test_case_names(CutRunContext *context void cut_run_context_set_target_test_names(CutRunContext *context, const gchar **names); const gchar **cut_run_context_get_target_test_names(CutRunContext *context); +void cut_run_context_add_loader_customizer(CutRunContext *context, + CutLoaderCustomizer *customizer); +const GList *cut_run_context_get_loader_customizers + (CutRunContext *context); guint cut_run_context_get_n_tests (CutRunContext *context); guint cut_run_context_get_n_successes (CutRunContext *context); Modified: test/run-test.sh (+4 -0) =================================================================== --- test/run-test.sh 2014-01-19 17:52:52 +0900 (8dda060) +++ test/run-test.sh 2014-01-19 18:20:25 +0900 (5180d96) @@ -45,6 +45,8 @@ CUT_REPORT_MODULE_DIR=$top_dir/module/report/.libs CUT_REPORT_FACTORY_MODULE_DIR=$top_dir/module/report/.libs CUT_STREAM_MODULE_DIR=$top_dir/module/stream/.libs CUT_STREAM_FACTORY_MODULE_DIR=$top_dir/module/stream/.libs +CUT_LOADER_CUSTOMIZER_MODULE_DIR=$top_dir/module/loader-customizer/.libs +CUT_LOADER_CUSTOMIZER_FACTORY_MODULE_DIR=$top_dir/module/loader-customizer/.libs export CUTTER export CUT_ICONS_DIR @@ -55,6 +57,8 @@ export CUT_REPORT_MODULE_DIR export CUT_REPORT_FACTORY_MODULE_DIR export CUT_STREAM_MODULE_DIR export CUT_STREAM_FACTORY_MODULE_DIR +export CUT_LOADER_CUSTOMIZER_MODULE_DIR +export CUT_LOADER_CUSTOMIZER_FACTORY_MODULE_DIR CUTTER_ARGS="$CUTTER_ARGS -s $BASE_DIR --exclude-directory fixtures" CUTTER_ARGS="$CUTTER_ARGS --exclude-directory lib" |