You can subscribe to this list here.
| 2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(52) |
Nov
(902) |
Dec
(89) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2008 |
Jan
(10) |
Feb
(103) |
Mar
(216) |
Apr
(184) |
May
(435) |
Jun
(123) |
Jul
(145) |
Aug
(107) |
Sep
(53) |
Oct
(140) |
Nov
(59) |
Dec
(40) |
| 2009 |
Jan
(28) |
Feb
(39) |
Mar
(70) |
Apr
(35) |
May
(146) |
Jun
(23) |
Jul
(6) |
Aug
(110) |
Sep
(65) |
Oct
(111) |
Nov
(127) |
Dec
(1) |
| 2010 |
Jan
(12) |
Feb
(2) |
Mar
(56) |
Apr
(123) |
May
(13) |
Jun
(120) |
Jul
(42) |
Aug
(2) |
Sep
(23) |
Oct
(3) |
Nov
(10) |
Dec
(1) |
| 2011 |
Jan
(9) |
Feb
(99) |
Mar
(3) |
Apr
(1) |
May
(18) |
Jun
|
Jul
(43) |
Aug
(1) |
Sep
(1) |
Oct
(34) |
Nov
(7) |
Dec
(74) |
| 2012 |
Jan
(10) |
Feb
(10) |
Mar
(71) |
Apr
(1) |
May
(9) |
Jun
(8) |
Jul
(2) |
Aug
(97) |
Sep
(1) |
Oct
(16) |
Nov
(3) |
Dec
(33) |
| 2013 |
Jan
(26) |
Feb
(3) |
Mar
|
Apr
(4) |
May
(9) |
Jun
(2) |
Jul
(6) |
Aug
(2) |
Sep
|
Oct
|
Nov
(32) |
Dec
(2) |
| 2014 |
Jan
(38) |
Feb
(39) |
Mar
|
Apr
|
May
(11) |
Jun
(22) |
Jul
|
Aug
(3) |
Sep
(3) |
Oct
(7) |
Nov
|
Dec
|
| 2015 |
Jan
(3) |
Feb
(1) |
Mar
(12) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Kouhei S. <nul...@cl...> - 2014-01-23 15:40:27
|
Kouhei Sutou 2014-01-24 00:40:08 +0900 (Fri, 24 Jan 2014) New Revision: 4d8e21015d6fe627f68d45b435b453a51a49aae8 https://github.com/clear-code/cutter/commit/4d8e21015d6fe627f68d45b435b453a51a49aae8 Message: Add missing compiler flags for coverage Modified files: test/cppcutter/Makefile.am test/fixtures/loader/cpp-fixture/Makefile.am test/fixtures/loader/cpp/Makefile.am Modified: test/cppcutter/Makefile.am (+3 -1) =================================================================== --- test/cppcutter/Makefile.am 2014-01-24 00:38:57 +0900 (f679c92) +++ test/cppcutter/Makefile.am 2014-01-24 00:40:08 +0900 (7182eaa) @@ -6,7 +6,9 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/cppcutter \ -I$(top_srcdir)/test/lib -AM_CXXFLAGS = $(CUTTER_CFLAGS) +AM_CXXFLAGS = \ + $(CUTTER_CFLAGS) \ + $(COVERAGE_CFLAGS) CLEANFILES = *.gcno *.gcda Modified: test/fixtures/loader/cpp-fixture/Makefile.am (+4 -1) =================================================================== --- test/fixtures/loader/cpp-fixture/Makefile.am 2014-01-24 00:38:57 +0900 (cbcc162) +++ test/fixtures/loader/cpp-fixture/Makefile.am 2014-01-24 00:40:08 +0900 (3d8751d) @@ -6,7 +6,10 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/gcutter \ -I$(top_srcdir)/cppcutter -noinst_LTLIBRARIES = \ +AM_CXXFLAGS = \ + $(COVERAGE_CFLAGS) + +noinst_LTLIBRARIES = \ with-prefix.la \ without-prefix.la \ all.la Modified: test/fixtures/loader/cpp/Makefile.am (+3 -0) =================================================================== --- test/fixtures/loader/cpp/Makefile.am 2014-01-24 00:38:57 +0900 (d4c605e) +++ test/fixtures/loader/cpp/Makefile.am 2014-01-24 00:40:08 +0900 (6660168) @@ -6,6 +6,9 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/gcutter \ -I$(top_srcdir)/cppcutter +AM_CXXFLAGS = \ + $(COVERAGE_CFLAGS) + noinst_LTLIBRARIES = \ stub-namespace.la \ stub-multi-namespace.la \ |
|
From: Kouhei S. <nul...@cl...> - 2014-01-23 15:39:19
|
Kouhei Sutou 2014-01-24 00:38:57 +0900 (Fri, 24 Jan 2014) New Revision: cd9ba4b1d84f02af36d0bf6e9b0f497861062626 https://github.com/clear-code/cutter/commit/cd9ba4b1d84f02af36d0bf6e9b0f497861062626 Message: Remove needles spaces Modified files: gcutter/Makefile.am soupcutter/Makefile.am Modified: gcutter/Makefile.am (+5 -5) =================================================================== --- gcutter/Makefile.am 2014-01-20 23:10:43 +0900 (e50c4b4) +++ gcutter/Makefile.am 2014-01-24 00:38:57 +0900 (c499d6e) @@ -1,9 +1,9 @@ -AM_CPPFLAGS = \ +AM_CPPFLAGS = \ -I$(top_builddir) \ -I$(top_srcdir) \ -I$(top_srcdir)/cutter -AM_CFLAGS = \ +AM_CFLAGS = \ $(CUTTER_CFLAGS) \ $(COVERAGE_CFLAGS) @@ -47,14 +47,14 @@ gcutter_public_headers = \ gcut-glib-event-loop.h \ gcut-main.h -noinst_headers = \ +noinst_headers = \ gbsearcharray.h -pkginclude_HEADERS = \ +pkginclude_HEADERS = \ gcutter.h gcutter_includedir=$(pkgincludedir)/gcutter -gcutter_include_HEADERS = \ +gcutter_include_HEADERS = \ $(gcutter_public_headers) libgcutter_sources = \ Modified: soupcutter/Makefile.am (+4 -4) =================================================================== --- soupcutter/Makefile.am 2014-01-20 23:10:43 +0900 (77b4339) +++ soupcutter/Makefile.am 2014-01-24 00:38:57 +0900 (2e5371b) @@ -1,10 +1,10 @@ -AM_CPPFLAGS = \ +AM_CPPFLAGS = \ -I$(top_builddir) \ -I$(top_srcdir) \ -I$(top_srcdir)/cutter \ -I$(top_srcdir)/gcutter -AM_CFLAGS = \ +AM_CFLAGS = \ $(CUTTER_CFLAGS) \ $(LIBSOUP_CFLAGS) \ $(COVERAGE_CFLAGS) @@ -14,11 +14,11 @@ CLEANFILES = *.gcno *.gcda if HAVE_LIBSOUP lib_LTLIBRARIES = libsoupcutter.la -pkginclude_HEADERS = \ +pkginclude_HEADERS = \ soupcutter.h soupcutter_includedir=$(pkgincludedir)/soupcutter -soupcutter_include_HEADERS = \ +soupcutter_include_HEADERS = \ $(soupcutter_public_headers) endif |
|
From: Kouhei S. <nul...@cl...> - 2014-01-20 14:12:10
|
Kouhei Sutou 2014-01-20 23:09:34 +0900 (Mon, 20 Jan 2014) New Revision: 5ac85fb6c4ba89b91d6c05a6ef80e144ec4f83bd https://github.com/clear-code/cutter/commit/5ac85fb6c4ba89b91d6c05a6ef80e144ec4f83bd Message: Remove a needless space Modified files: cppcutter/Makefile.am Modified: cppcutter/Makefile.am (+1 -1) =================================================================== --- cppcutter/Makefile.am 2014-01-20 17:31:29 +0900 (dede871) +++ cppcutter/Makefile.am 2014-01-20 23:09:34 +0900 (8ea5952) @@ -3,7 +3,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir) \ -I$(top_srcdir)/cutter -AM_CXXFLAGS = \ +AM_CXXFLAGS = \ -DCPPCUT_BUILDING \ $(CUTTER_CFLAGS) \ $(COVERAGE_CFLAGS) |
|
From: Kouhei S. <nul...@cl...> - 2014-01-20 14:12:06
|
Kouhei Sutou 2014-01-20 23:10:43 +0900 (Mon, 20 Jan 2014) New Revision: 75065737aba1dbd7e66c71c4825fb85fd2a65b54 https://github.com/clear-code/cutter/commit/75065737aba1dbd7e66c71c4825fb85fd2a65b54 Message: Support unhandled C++ exception handling in iterated test Added files: cppcutter/cppcut-iterated-test.h cppcutter/cppcut-test-invoke.cpp cppcutter/cppcut-test-invoke.h cppcutter/cppcut-test-iterator.cpp cppcutter/cppcut-test-iterator.h test/cppcutter/test-cppcut-iterated-test.cpp Copied files: cppcutter/cppcut-iterated-test.cpp (from cppcutter/cppcut-test.cpp) Modified files: cppcutter/Makefile.am cppcutter/cppcut-test.cpp cutter/cut-loader.c cutter/cut-loader.h cutter/cut-test-iterator.c cutter/cut-test-iterator.h module/loader-customizer/cut-exception-loader-customizer.c test/cppcutter/Makefile.am Modified: cppcutter/Makefile.am (+12 -3) =================================================================== --- cppcutter/Makefile.am 2014-01-20 23:09:34 +0900 (8ea5952) +++ cppcutter/Makefile.am 2014-01-20 23:10:43 +0900 (3842a25) @@ -16,8 +16,13 @@ cppcutter_public_headers = \ cppcut-assertions.h \ cppcut-assertions-helper.h \ cppcut-macros.h \ - cppcut-message.h \ - cppcut-test.h + cppcut-message.h + +cppcutter_private_headers = \ + cppcut-test.h \ + cppcut-test-iterator.h \ + cppcut-iterated-test.h \ + cppcut-test-invoke.h pkginclude_HEADERS = \ cppcutter.h @@ -29,10 +34,14 @@ cppcutter_include_HEADERS = \ libcppcutter_sources = \ cppcut-assertions-helper.cpp \ cppcut-message.cpp \ - cppcut-test.cpp + cppcut-test.cpp \ + cppcut-test-iterator.cpp \ + cppcut-iterated-test.cpp \ + cppcut-test-invoke.cpp libcppcutter_la_SOURCES = \ $(cppcutter_public_headers) \ + $(cppcutter_private_headers) \ $(libcppcutter_sources) libcppcutter_la_LDFLAGS = \ Copied: cppcutter/cppcut-iterated-test.cpp (+17 -31) 54% =================================================================== --- cppcutter/cppcut-test.cpp 2014-01-20 23:09:34 +0900 (866d685) +++ cppcutter/cppcut-iterated-test.cpp 2014-01-20 23:10:43 +0900 (fbcf336) @@ -1,7 +1,6 @@ /* -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2014 Kouhei Sutou <ko...@cl...> - * Copyright (C) 2014 Kazuhiro Yamato <kz...@gm...> * * 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 @@ -22,23 +21,19 @@ # include <config.h> #endif -#include <exception> -#include <typeinfo> - -#include "cppcut-test.h" - -#include <cutter.h> +#include "cppcut-iterated-test.h" +#include "cppcut-test-invoke.h" G_BEGIN_DECLS -G_DEFINE_TYPE(CppCutTest, cppcut_test, CUT_TYPE_TEST) +G_DEFINE_TYPE(CppCutIteratedTest, cppcut_iterated_test, CUT_TYPE_ITERATED_TEST) static void invoke (CutTest *test, CutTestContext *test_context, CutRunContext *run_context); static void -cppcut_test_class_init (CppCutTestClass *klass) +cppcut_iterated_test_class_init (CppCutIteratedTestClass *klass) { CutTestClass *cut_test_class; @@ -48,42 +43,33 @@ cppcut_test_class_init (CppCutTestClass *klass) } static void -cppcut_test_init (CppCutTest *test) +cppcut_iterated_test_init (CppCutIteratedTest *test) { } -CppCutTest * -cppcut_test_new (const gchar *name, CutTestFunction function) +CppCutIteratedTest * +cppcut_iterated_test_new (const gchar *name, + CutIteratedTestFunction function, + CutTestData *data) { gpointer object; - object = g_object_new(CPPCUT_TYPE_TEST, - "element-name", "test", + object = g_object_new(CPPCUT_TYPE_ITERATED_TEST, + "element-name", "iterated-test", "name", name, - "test-function", function, + "iterated-test-function", function, + "data", data, NULL); - return CPPCUT_TEST(object); + return CPPCUT_ITERATED_TEST(object); } static void invoke (CutTest *test, CutTestContext *test_context, CutRunContext *run_context) { - CutTestClass *cut_test_class = CUT_TEST_CLASS(cppcut_test_parent_class); + CutTestClass *cut_test_class; - try { - cut_test_class->invoke(test, test_context, run_context); - } catch (const std::exception &exception) { - const gchar *message; - message = cut_take_printf("Unhandled C++ standard exception is thrown: " - "<%s>: %s", - typeid(exception).name(), - exception.what()); - cut_test_terminate(ERROR, message); - } catch (...) { - const gchar *message; - message = "Unhandled C++ non-standard exception is thrown"; - cut_test_terminate(ERROR, message); - } + cut_test_class = CUT_TEST_CLASS(cppcut_iterated_test_parent_class); + cut::test::invoke(cut_test_class, test, test_context, run_context); } G_END_DECLS Added: cppcutter/cppcut-iterated-test.h (+83 -0) 100644 =================================================================== --- /dev/null +++ cppcutter/cppcut-iterated-test.h 2014-01-20 23:10:43 +0900 (06ca2c0) @@ -0,0 +1,83 @@ +/* -*- 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 __CPPCUT_ITERATED_TEST_H__ +#define __CPPCUT_ITERATED_TEST_H__ + +#include <glib-object.h> + +#include <cutter/cut-iterated-test.h> + +/** + * SECTION: cppcut-iterated-test + * @title: Iterated test class for C++. + * @short_description: Adds C++ exception support to CutIteratedTest. + * + */ + +G_BEGIN_DECLS + +#define CPPCUT_TYPE_ITERATED_TEST \ + (cppcut_iterated_test_get_type()) +#define CPPCUT_ITERATED_TEST(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj), \ + CPPCUT_TYPE_ITERATED_TEST, \ + CppCutIteratedTest)) +#define CPPCUT_ITERATED_TEST_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass), \ + CPPCUT_TYPE_ITERATED_TEST, \ + CppCutIteratedTestClass)) +#define CPPCUT_IS_ITERATED_TEST(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj), \ + CPPCUT_TYPE_ITERATED_TEST)) +#define CPPCUT_IS_ITERATED_TEST_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE((klass), \ + CPPCUT_TYPE_ITERATED_TEST)) +#define CPPCUT_ITERATED_TEST_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS((obj), \ + CPPCUT_TYPE_ITERATED_TEST, \ + CppCutIteratedTestClass)) + +typedef struct _CppCutIteratedTest CppCutIteratedTest; +typedef struct _CppCutIteratedTestClass CppCutIteratedTestClass; + +struct _CppCutIteratedTest +{ + CutIteratedTest object; +}; + +struct _CppCutIteratedTestClass +{ + CutIteratedTestClass parent_class; +}; + +GType cppcut_iterated_test_get_type (void) G_GNUC_CONST; + +CppCutIteratedTest * + cppcut_iterated_test_new (const gchar *name, + CutIteratedTestFunction function, + CutTestData *data); + +G_END_DECLS + +#endif /* __CPPCUT_ITERATED_TEST_H__ */ + +/* +vi:ts=4:nowrap:ai:expandtab:sw=4 +*/ Added: cppcutter/cppcut-test-invoke.cpp (+56 -0) 100644 =================================================================== --- /dev/null +++ cppcutter/cppcut-test-invoke.cpp 2014-01-20 23:10:43 +0900 (26ffb91) @@ -0,0 +1,56 @@ +/* -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2014 Kouhei Sutou <ko...@cl...> + * Copyright (C) 2014 Kazuhiro Yamato <kz...@gm...> + * + * 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 + +#include <exception> +#include <typeinfo> + +#include "cppcut-test-invoke.h" + +#include <cutter.h> + +void +cut::test::invoke (CutTestClass *cut_test_class, + CutTest *test, + CutTestContext *test_context, + CutRunContext *run_context) +{ + try { + cut_test_class->invoke(test, test_context, run_context); + } catch (const std::exception &exception) { + const gchar *message; + message = cut_take_printf("Unhandled C++ standard exception is thrown: " + "<%s>: %s", + typeid(exception).name(), + exception.what()); + cut_test_terminate(ERROR, message); + } catch (...) { + const gchar *message; + message = "Unhandled C++ non-standard exception is thrown"; + cut_test_terminate(ERROR, message); + } +} + +/* +vi:ts=4:nowrap:ai:expandtab:sw=4 +*/ Added: cppcutter/cppcut-test-invoke.h (+40 -0) 100644 =================================================================== --- /dev/null +++ cppcutter/cppcut-test-invoke.h 2014-01-20 23:10:43 +0900 (35d5cf0) @@ -0,0 +1,40 @@ +/* -*- 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 __CPPCUT_TEST_INVOKE_H__ +#define __CPPCUT_TEST_INVOKE_H__ + +#include <cutter/cut-test.h> + +namespace cut +{ + namespace test + { + void invoke (CutTestClass *cut_test_class, + CutTest *test, + CutTestContext *test_context, + CutRunContext *run_context); + } +} + +#endif /* __CPPCUT_TEST_INVOKE_H__ */ + +/* +vi:ts=4:nowrap:ai:expandtab:sw=4 +*/ Added: cppcutter/cppcut-test-iterator.cpp (+86 -0) 100644 =================================================================== --- /dev/null +++ cppcutter/cppcut-test-iterator.cpp 2014-01-20 23:10:43 +0900 (804d8f4) @@ -0,0 +1,86 @@ +/* -*- 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 + +#include "cppcut-test-iterator.h" +#include "cppcut-iterated-test.h" + +G_BEGIN_DECLS + +G_DEFINE_TYPE(CppCutTestIterator, cppcut_test_iterator, CUT_TYPE_TEST_ITERATOR) + +static CutIteratedTest * + create_iterated_test (CutTestIterator *test_iterator, + const gchar *name, + CutIteratedTestFunction iterated_test_function, + CutTestData *test_data); + +static void +cppcut_test_iterator_class_init (CppCutTestIteratorClass *klass) +{ + CutTestIteratorClass *cut_test_iterator_class; + + cut_test_iterator_class = CUT_TEST_ITERATOR_CLASS(klass); + + cut_test_iterator_class->create_iterated_test = create_iterated_test; +} + +static void +cppcut_test_iterator_init (CppCutTestIterator *test) +{ +} + +CppCutTestIterator * +cppcut_test_iterator_new (const gchar *name, + CutIteratedTestFunction test_function, + CutDataSetupFunction data_setup_function) +{ + gpointer object; + + object = g_object_new(CPPCUT_TYPE_TEST_ITERATOR, + "element-name", "test-iterator", + "name", name, + "iterated-test-function", test_function, + "data-setup-function", data_setup_function, + NULL); + return CPPCUT_TEST_ITERATOR(object); +} + +static CutIteratedTest * +create_iterated_test (CutTestIterator *test_iterator, + const gchar *name, + CutIteratedTestFunction iterated_test_function, + CutTestData *test_data) +{ + CppCutIteratedTest *iterated_test; + + iterated_test = cppcut_iterated_test_new(name, + iterated_test_function, + test_data); + return CUT_ITERATED_TEST(iterated_test); +} + +G_END_DECLS + +/* +vi:ts=4:nowrap:ai:expandtab:sw=4 +*/ Added: cppcutter/cppcut-test-iterator.h (+83 -0) 100644 =================================================================== --- /dev/null +++ cppcutter/cppcut-test-iterator.h 2014-01-20 23:10:43 +0900 (6e54099) @@ -0,0 +1,83 @@ +/* -*- 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 __CPPCUT_TEST_ITERATOR_H__ +#define __CPPCUT_TEST_ITERATOR_H__ + +#include <glib-object.h> + +#include <cutter/cut-test-iterator.h> + +/** + * SECTION: cppcut-test-iterator + * @title: TestIterator class for C++. + * @short_description: Creates CppCutIteratedTest. + * + */ + +G_BEGIN_DECLS + +#define CPPCUT_TYPE_TEST_ITERATOR \ + (cppcut_test_iterator_get_type()) +#define CPPCUT_TEST_ITERATOR(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj), \ + CPPCUT_TYPE_TEST_ITERATOR, \ + CppCutTestIterator)) +#define CPPCUT_TEST_ITERATOR_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass), \ + CPPCUT_TYPE_TEST_ITERATOR, \ + CppCutTestIteratorClass)) +#define CPPCUT_IS_TEST_ITERATOR(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj), \ + CPPCUT_TYPE_TEST_ITERATOR)) +#define CPPCUT_IS_TEST_ITERATOR_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE((klass), \ + CPPCUT_TYPE_TEST_ITERATOR)) +#define CPPCUT_TEST_ITERATOR_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS((obj), \ + CPPCUT_TYPE_TEST_ITERATOR, \ + CppCutTestIteratorClass)) + +typedef struct _CppCutTestIterator CppCutTestIterator; +typedef struct _CppCutTestIteratorClass CppCutTestIteratorClass; + +struct _CppCutTestIterator +{ + CutTestIterator object; +}; + +struct _CppCutTestIteratorClass +{ + CutTestIteratorClass parent_class; +}; + +GType cppcut_test_iterator_get_type (void) G_GNUC_CONST; + +CppCutTestIterator * + cppcut_test_iterator_new (const gchar *name, + CutIteratedTestFunction test_function, + CutDataSetupFunction data_setup_function); + +G_END_DECLS + +#endif /* __CPPCUT_TEST_ITERATOR_H__ */ + +/* +vi:ts=4:nowrap:ai:expandtab:sw=4 +*/ Modified: cppcutter/cppcut-test.cpp (+2 -18) =================================================================== --- cppcutter/cppcut-test.cpp 2014-01-20 23:09:34 +0900 (866d685) +++ cppcutter/cppcut-test.cpp 2014-01-20 23:10:43 +0900 (f13d33a) @@ -1,7 +1,6 @@ /* -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2014 Kouhei Sutou <ko...@cl...> - * Copyright (C) 2014 Kazuhiro Yamato <kz...@gm...> * * 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 @@ -22,10 +21,8 @@ # include <config.h> #endif -#include <exception> -#include <typeinfo> - #include "cppcut-test.h" +#include "cppcut-test-invoke.h" #include <cutter.h> @@ -70,20 +67,7 @@ invoke (CutTest *test, CutTestContext *test_context, CutRunContext *run_context) { CutTestClass *cut_test_class = CUT_TEST_CLASS(cppcut_test_parent_class); - try { - cut_test_class->invoke(test, test_context, run_context); - } catch (const std::exception &exception) { - const gchar *message; - message = cut_take_printf("Unhandled C++ standard exception is thrown: " - "<%s>: %s", - typeid(exception).name(), - exception.what()); - cut_test_terminate(ERROR, message); - } catch (...) { - const gchar *message; - message = "Unhandled C++ non-standard exception is thrown"; - cut_test_terminate(ERROR, message); - } + cut::test::invoke(cut_test_class, test, test_context, run_context); } G_END_DECLS Modified: cutter/cut-loader.c (+41 -6) =================================================================== --- cutter/cut-loader.c 2014-01-20 23:09:34 +0900 (bab89b5) +++ cutter/cut-loader.c 2014-01-20 23:10:43 +0900 (e830270) @@ -82,6 +82,8 @@ struct _CutLoaderPrivate gchar *base_directory; CutCreateTestFunction create_test_function; gpointer create_test_function_user_data; + CutCreateTestIteratorFunction create_test_iterator_function; + gpointer create_test_iterator_function_user_data; }; enum @@ -183,6 +185,8 @@ cut_loader_init (CutLoader *loader) priv->base_directory = NULL; priv->create_test_function = NULL; priv->create_test_function_user_data = NULL; + priv->create_test_iterator_function = NULL; + priv->create_test_iterator_function_user_data = NULL; } static void @@ -341,6 +345,19 @@ cut_loader_set_create_test_function (CutLoader *loader, priv->create_test_function_user_data = user_data; } +void +cut_loader_set_create_test_iterator_function ( + CutLoader *loader, + CutCreateTestIteratorFunction create_test_iterator_function, + gpointer user_data) +{ + CutLoaderPrivate *priv; + + priv = CUT_LOADER_GET_PRIVATE(loader); + priv->create_test_iterator_function = create_test_iterator_function; + priv->create_test_iterator_function_user_data = user_data; +} + static inline const gchar * skip_cpp_namespace_gcc (const gchar *name, GString *namespaces) { @@ -1046,6 +1063,25 @@ create_test (CutLoaderPrivate *priv, } } +static CutTestIterator * +create_test_iterator (CutLoaderPrivate *priv, + const gchar *name, + CutIteratedTestFunction iterated_test_function, + CutDataSetupFunction data_setup_function) +{ + if (priv->create_test_iterator_function) { + gpointer user_data = priv->create_test_iterator_function_user_data; + return priv->create_test_iterator_function(name, + iterated_test_function, + data_setup_function, + user_data); + } else { + return cut_test_iterator_new(name, + iterated_test_function, + data_setup_function); + } +} + static void register_valid_test (CutLoader *loader, CutTestCase *test_case, SymbolNames *names) @@ -1075,12 +1111,11 @@ register_valid_test (CutLoader *loader, CutTestCase *test_case, if (data_setup_function) { CutTestIterator *test_iterator; - CutIteratedTestFunction iterated_test_function; - - iterated_test_function = (CutIteratedTestFunction)test_function; - test_iterator = cut_test_iterator_new(names->test_name, - iterated_test_function, - data_setup_function); + test_iterator = + create_test_iterator(priv, + names->test_name, + (CutIteratedTestFunction)test_function, + data_setup_function); test = CUT_TEST(test_iterator); } else { test = create_test(priv, names->test_name, test_function); Modified: cutter/cut-loader.h (+14 -0) =================================================================== --- cutter/cut-loader.h 2014-01-20 23:09:34 +0900 (76ffc4d) +++ cutter/cut-loader.h 2014-01-20 23:10:43 +0900 (18be60b) @@ -41,6 +41,15 @@ typedef struct _CutLoaderClass CutLoaderClass; typedef CutTest *(*CutCreateTestFunction) (const gchar *name, CutTestFunction function, gpointer user_data); +typedef CutTestIterator * + (*CutCreateTestIteratorFunction) + (const gchar *name, + CutIteratedTestFunction + iterated_test_function, + CutDataSetupFunction + data_setup_function, + gpointer user_data); + struct _CutLoader { GObject object; @@ -69,6 +78,11 @@ void cut_loader_set_create_test_function (CutLoader *loader, CutCreateTestFunction create_test_function, gpointer user_data); +void cut_loader_set_create_test_iterator_function + (CutLoader *loader, + CutCreateTestIteratorFunction + create_test_iterator_function, + gpointer user_data); GList *cut_loader_load_test_cases (CutLoader *loader); CutTestCase *cut_loader_load_test_case (CutLoader *loader); CutTestSuite *cut_loader_load_test_suite (CutLoader *loader); Modified: cutter/cut-test-iterator.c (+26 -3) =================================================================== --- cutter/cut-test-iterator.c 2014-01-20 23:09:34 +0900 (17f141c) +++ cutter/cut-test-iterator.c 2014-01-20 23:10:43 +0900 (f1200bc) @@ -219,6 +219,27 @@ cut_test_iterator_new_empty (void) return cut_test_iterator_new(NULL, NULL, NULL); } +CutIteratedTest * +cut_test_iterator_create_iterated_test (CutTestIterator *test_iterator, + const gchar *name, + CutIteratedTestFunction iterated_test_function, + CutTestData *test_data) +{ + CutTestIteratorClass *klass; + + klass = CUT_TEST_ITERATOR_GET_CLASS(test_iterator); + if (klass->create_iterated_test) { + return klass->create_iterated_test(test_iterator, + name, + iterated_test_function, + test_data); + } else { + return cut_iterated_test_new(name, + iterated_test_function, + test_data); + } +} + void cut_test_iterator_add_test (CutTestIterator *test_iterator, CutIteratedTest *test) @@ -428,9 +449,11 @@ run_iterated_tests (CutTest *test, CutTestContext *test_context, CutTestData *test_data; test_data = cut_test_context_get_current_data(test_context); - iterated_test = cut_iterated_test_new(cut_test_get_name(test), - priv->iterated_test_function, - test_data); + iterated_test = + cut_test_iterator_create_iterated_test(test_iterator, + cut_test_get_name(test), + priv->iterated_test_function, + test_data); cut_test_iterator_add_test(test_iterator, iterated_test); g_object_unref(iterated_test); Modified: cutter/cut-test-iterator.h (+13 -1) =================================================================== --- cutter/cut-test-iterator.h 2014-01-20 23:09:34 +0900 (12b42a9) +++ cutter/cut-test-iterator.h 2014-01-20 23:10:43 +0900 (344d98a) @@ -1,6 +1,6 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* - * Copyright (C) 2008 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 @@ -47,6 +47,12 @@ struct _CutTestIteratorClass { CutTestContainerClass parent_class; + CutIteratedTest * + (*create_iterated_test) + (CutTestIterator *test_iterator, + const gchar *name, + CutIteratedTestFunction iterated_test_function, + CutTestData *test_data); void (*ready) (CutTestIterator *test_iterator, guint n_tests); void (*start_iterated_test) @@ -66,6 +72,12 @@ CutTestIterator *cut_test_iterator_new (const gchar *name, CutIteratedTestFunction function, CutDataSetupFunction data_setup_function); CutTestIterator *cut_test_iterator_new_empty (void); + +CutIteratedTest *cut_test_iterator_create_iterated_test + (CutTestIterator *test_iterator, + const gchar *name, + CutIteratedTestFunction iterated_test_function, + CutTestData *test_data); void cut_test_iterator_add_test (CutTestIterator *test_iterator, CutIteratedTest *test); Modified: module/loader-customizer/cut-exception-loader-customizer.c (+15 -0) =================================================================== --- module/loader-customizer/cut-exception-loader-customizer.c 2014-01-20 23:09:34 +0900 (77afcb0) +++ module/loader-customizer/cut-exception-loader-customizer.c 2014-01-20 23:10:43 +0900 (ed01c30) @@ -28,6 +28,7 @@ #include <cutter/cut-loader-customizer.h> #include <cppcutter/cppcut-test.h> +#include <cppcutter/cppcut-test-iterator.h> #define CUT_TYPE_EXCEPTION_LOADER_CUSTOMIZER \ cut_type_exception_loader_customizer @@ -142,10 +143,24 @@ create_test (const gchar *name, return CUT_TEST(cppcut_test_new(name, function)); } +static CutTestIterator * +create_test_iterator (const gchar *name, + CutIteratedTestFunction function, + CutDataSetupFunction data_setup_function, + gpointer user_data) +{ + return CUT_TEST_ITERATOR(cppcut_test_iterator_new(name, + function, + data_setup_function)); +} + static void customize (CutLoaderCustomizer *customizer, CutLoader *loader) { cut_loader_set_create_test_function(loader, create_test, NULL); + cut_loader_set_create_test_iterator_function(loader, + create_test_iterator, + NULL); } /* Modified: test/cppcutter/Makefile.am (+2 -1) =================================================================== --- test/cppcutter/Makefile.am 2014-01-20 23:09:34 +0900 (498f6cf) +++ test/cppcutter/Makefile.am 2014-01-20 23:10:43 +0900 (f679c92) @@ -27,4 +27,5 @@ LIBS = \ test_cppcut_la_SOURCES = \ test-cppcut-assertions.cpp \ - test-cppcut-test.cpp + test-cppcut-test.cpp \ + test-cppcut-iterated-test.cpp Added: test/cppcutter/test-cppcut-iterated-test.cpp (+159 -0) 100644 =================================================================== --- /dev/null +++ test/cppcutter/test-cppcut-iterated-test.cpp 2014-01-20 23:10:43 +0900 (0d2d687) @@ -0,0 +1,159 @@ +/* -*- 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/>. + * + */ + +#include <typeinfo> + +#include <cppcutter.h> + +#include <cppcutter/cppcut-iterated-test.h> +#include <cutter/cut-test-runner.h> + +#include "../lib/cuttest-assertions.h" + +namespace cppcut_iterated_test +{ + CppCutIteratedTest *iterated_test; + CutTestData *test_data; + CutRunContext *run_context; + CutTestContext *test_context; + CutTestResult *test_result; + + static gboolean + run (void) + { + gboolean success; + + run_context = CUT_RUN_CONTEXT(cut_test_runner_new()); + + test_context = cut_test_context_new(run_context, NULL, NULL, NULL, + CUT_TEST(iterated_test)); + cut_test_context_current_push(test_context); + success = cut_test_runner_run_test(CUT_TEST_RUNNER(run_context), + CUT_TEST(iterated_test), + test_context); + cut_test_context_current_pop(); + + return success; + } + + void + cut_setup (void) + { + iterated_test = NULL; + test_data = cut_test_data_new("NULL data", NULL, NULL); + run_context = NULL; + test_context = NULL; + test_result = NULL; + } + + void + cut_teardown (void) + { + if (iterated_test) + g_object_unref(iterated_test); + if (test_data) + g_object_unref(test_data); + if (run_context) + g_object_unref(run_context); + if (test_context) + g_object_unref(test_context); + if (test_result) + g_object_unref(test_result); + } + + class StubException : public std::exception + { + public: + StubException(const char *message) : message_(message) + { + } + + virtual const char * + what(void) const throw() + { + return message_; + } + + private: + const char *message_; + }; + + static void + stub_std_exception (gconstpointer data) + { + throw StubException("std::exception family exception"); + } + + void + test_std_exception (void) + { + iterated_test = cppcut_iterated_test_new("std::exception test", + stub_std_exception, + test_data); + cut_assert_not_null(iterated_test); + + cut_assert_false(run()); + cut_assert_test_result_summary(run_context, 1, 0, 0, 0, 1, 0, 0, 0); + const gchar *system_message = + cut_take_printf("Unhandled C++ standard exception is thrown: " + "<%s>: %s", + typeid(StubException).name(), + "std::exception family exception"); + cut_assert_test_result(run_context, 0, CUT_TEST_RESULT_ERROR, + "std::exception test (NULL data)", + NULL, + system_message, + NULL, NULL, + NULL, + "void cppcut_test::stub_standard_exception()", + NULL); + } + + static void + stub_not_std_exception (gconstpointer data) + { + throw "not std::exception"; + } + + void + test_not_std_exception (void) + { + iterated_test = cppcut_iterated_test_new("not std::exception test", + stub_not_std_exception, + test_data); + cut_assert_not_null(iterated_test); + + cut_assert_false(run()); + cut_assert_test_result_summary(run_context, 1, 0, 0, 0, 1, 0, 0, 0); + const gchar *system_message = + "Unhandled C++ non-standard exception is thrown"; + cut_assert_test_result(run_context, 0, CUT_TEST_RESULT_ERROR, + "not std::exception test (NULL data)", + NULL, + system_message, + NULL, NULL, + NULL, + "void cppcut_test::stub_not_standard_exception()", + NULL); + } +} + +/* +vi:ts=4:nowrap:ai:expandtab:sw=4:ts=4 +*/ |
|
From: Kouhei S. <nul...@cl...> - 2014-01-20 08:31:51
|
Kouhei Sutou 2014-01-20 17:31:29 +0900 (Mon, 20 Jan 2014) New Revision: b451c52b59eac2e49334586018422618bf7b92d6 https://github.com/clear-code/cutter/commit/b451c52b59eac2e49334586018422618bf7b92d6 Message: Suppress a warning from GCC 4.8.1 on Ubuntu 13.10 cut-elf-loader.c: In function 'cut_elf_loader_is_elf': cut-elf-loader.c:191:37: warning: 'ident[3]' may be used uninitialized in this function [-Wmaybe-uninitialized] (ident[EI_MAG2] == ELFMAG2) && ^ cut-elf-loader.c:190:37: warning: 'ident[2]' may be used uninitialized in this function [-Wmaybe-uninitialized] (ident[EI_MAG1] == ELFMAG1) && ^ cut-elf-loader.c:189:37: warning: 'ident[1]' may be used uninitialized in this function [-Wmaybe-uninitialized] if ((ident[EI_MAG0] == ELFMAG0) && ^ cut-elf-loader.c:189:8: warning: 'ident[0]' may be used uninitialized in this function [-Wmaybe-uninitialized] if ((ident[EI_MAG0] == ELFMAG0) && GitHub: fix #9 Reported by Kazuhiro Yamato. Thanks!!! Modified files: cutter/cut-elf-loader.c Modified: cutter/cut-elf-loader.c (+10 -3) =================================================================== --- cutter/cut-elf-loader.c 2014-01-20 00:19:41 +0900 (2bb3f38) +++ cutter/cut-elf-loader.c 2014-01-20 17:31:29 +0900 (6a34213) @@ -1,6 +1,6 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* - * Copyright (C) 2009-2013 Kouhei Sutou <ko...@co...> + * Copyright (C) 2009-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 @@ -182,8 +182,15 @@ cut_elf_loader_is_elf (CutELFLoader *loader) return FALSE; } - if (priv->length >= sizeof(ident)) - memcpy(ident, priv->content, sizeof(ident)); + if (priv->length < sizeof(ident)) { + cut_log_warning("ELF file must have at least %zd size: %" G_GSIZE_FORMAT, + sizeof(ident), priv->length); + g_free(priv->content); + priv->content = NULL; + return FALSE; + } + + memcpy(ident, priv->content, sizeof(ident)); if ((ident[EI_MAG0] == ELFMAG0) && (ident[EI_MAG1] == ELFMAG1) && |
|
From: Kouhei S. <nul...@cl...> - 2014-01-19 15:20:14
|
Kouhei Sutou 2014-01-20 00:19:41 +0900 (Mon, 20 Jan 2014) New Revision: dd5f9b674993e1a4f6b0656b475d50beeb059e4a https://github.com/clear-code/cutter/commit/dd5f9b674993e1a4f6b0656b475d50beeb059e4a Message: Fix wrong assertion macro use Modified files: cutter/cut-loader-customizer.c Modified: cutter/cut-loader-customizer.c (+1 -1) =================================================================== --- cutter/cut-loader-customizer.c 2014-01-20 00:16:44 +0900 (6aeaa65) +++ cutter/cut-loader-customizer.c 2014-01-20 00:19:41 +0900 (85ce396) @@ -69,7 +69,7 @@ cut_loader_customizer_customize (CutLoaderCustomizer *customizer, { CutLoaderCustomizerClass *klass; - g_return_val_if_fail(CUT_IS_LOADER_CUSTOMIZER(customizer), NULL); + g_return_if_fail(CUT_IS_LOADER_CUSTOMIZER(customizer)); klass = CUT_LOADER_CUSTOMIZER_GET_CLASS(customizer); if (klass->customize) { |
|
From: Kouhei S. <nul...@cl...> - 2014-01-19 15:17:02
|
Kouhei Sutou 2014-01-20 00:16:44 +0900 (Mon, 20 Jan 2014) New Revision: 5606bc4cb5b72ccface9e1d338693aed138a62a3 https://github.com/clear-code/cutter/commit/5606bc4cb5b72ccface9e1d338693aed138a62a3 Message: Remove unused header include Modified files: module/loader-customizer/cut-exception-loader-customizer.c Modified: module/loader-customizer/cut-exception-loader-customizer.c (+0 -1) =================================================================== --- module/loader-customizer/cut-exception-loader-customizer.c 2014-01-20 00:13:03 +0900 (3e9eabd) +++ module/loader-customizer/cut-exception-loader-customizer.c 2014-01-20 00:16:44 +0900 (77afcb0) @@ -28,7 +28,6 @@ #include <cutter/cut-loader-customizer.h> #include <cppcutter/cppcut-test.h> -#include <cppcutter/cppcut-iterated-test.h> #define CUT_TYPE_EXCEPTION_LOADER_CUSTOMIZER \ cut_type_exception_loader_customizer |
|
From: Kouhei S. <nul...@cl...> - 2014-01-19 15:13:32
|
Kouhei Sutou 2014-01-20 00:13:03 +0900 (Mon, 20 Jan 2014) New Revision: 5f0dc33980afd1d22700d00bd68aff58b25805c0 https://github.com/clear-code/cutter/commit/5f0dc33980afd1d22700d00bd68aff58b25805c0 Message: Handle unhandled C++ exception in test GitHub: fix #8 I use loader-customizer new module mechanism instead of changing cut-test.c. Because I want to avoid that libcutter depends on C++. TODO: Iterated test isn't supported yet. Suggested by Kazuhiro Yamato. Patch by Kazuhiro Yamato. Thanks!!! Added files: cppcutter/cppcut-test.cpp cppcutter/cppcut-test.h module/loader-customizer/Makefile.am module/loader-customizer/cut-exception-loader-customizer-factory.c module/loader-customizer/cut-exception-loader-customizer.c test/cppcutter/test-cppcut-test.cpp Modified files: configure.ac cppcutter/Makefile.am cutter/cut-loader.c cutter/cut-loader.h module/Makefile.am test/cppcutter/Makefile.am Modified: configure.ac (+1 -0) =================================================================== --- configure.ac 2014-01-19 23:41:38 +0900 (0cc44ff) +++ configure.ac 2014-01-20 00:13:03 +0900 (b2669fb) @@ -959,6 +959,7 @@ AC_CONFIG_FILES([Makefile module/ui/Makefile module/report/Makefile module/stream/Makefile + module/loader-customizer/Makefile gst-plugins/Makefile gst-plugins/test/Makefile data/Makefile Modified: cppcutter/Makefile.am (+6 -4) =================================================================== --- cppcutter/Makefile.am 2014-01-19 23:41:38 +0900 (716036d) +++ cppcutter/Makefile.am 2014-01-20 00:13:03 +0900 (dede871) @@ -16,7 +16,8 @@ cppcutter_public_headers = \ cppcut-assertions.h \ cppcut-assertions-helper.h \ cppcut-macros.h \ - cppcut-message.h + cppcut-message.h \ + cppcut-test.h pkginclude_HEADERS = \ cppcutter.h @@ -25,9 +26,10 @@ cppcutter_includedir=$(pkgincludedir)/cppcutter cppcutter_include_HEADERS = \ $(cppcutter_public_headers) -libcppcutter_sources = \ - cppcut-assertions-helper.cpp \ - cppcut-message.cpp +libcppcutter_sources = \ + cppcut-assertions-helper.cpp \ + cppcut-message.cpp \ + cppcut-test.cpp libcppcutter_la_SOURCES = \ $(cppcutter_public_headers) \ Added: cppcutter/cppcut-test.cpp (+93 -0) 100644 =================================================================== --- /dev/null +++ cppcutter/cppcut-test.cpp 2014-01-20 00:13:03 +0900 (866d685) @@ -0,0 +1,93 @@ +/* -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2014 Kouhei Sutou <ko...@cl...> + * Copyright (C) 2014 Kazuhiro Yamato <kz...@gm...> + * + * 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 + +#include <exception> +#include <typeinfo> + +#include "cppcut-test.h" + +#include <cutter.h> + +G_BEGIN_DECLS + +G_DEFINE_TYPE(CppCutTest, cppcut_test, CUT_TYPE_TEST) + +static void invoke (CutTest *test, + CutTestContext *test_context, + CutRunContext *run_context); + +static void +cppcut_test_class_init (CppCutTestClass *klass) +{ + CutTestClass *cut_test_class; + + cut_test_class = CUT_TEST_CLASS(klass); + + cut_test_class->invoke = invoke; +} + +static void +cppcut_test_init (CppCutTest *test) +{ +} + +CppCutTest * +cppcut_test_new (const gchar *name, CutTestFunction function) +{ + gpointer object; + + object = g_object_new(CPPCUT_TYPE_TEST, + "element-name", "test", + "name", name, + "test-function", function, + NULL); + return CPPCUT_TEST(object); +} + +static void +invoke (CutTest *test, CutTestContext *test_context, CutRunContext *run_context) +{ + CutTestClass *cut_test_class = CUT_TEST_CLASS(cppcut_test_parent_class); + + try { + cut_test_class->invoke(test, test_context, run_context); + } catch (const std::exception &exception) { + const gchar *message; + message = cut_take_printf("Unhandled C++ standard exception is thrown: " + "<%s>: %s", + typeid(exception).name(), + exception.what()); + cut_test_terminate(ERROR, message); + } catch (...) { + const gchar *message; + message = "Unhandled C++ non-standard exception is thrown"; + cut_test_terminate(ERROR, message); + } +} + +G_END_DECLS + +/* +vi:ts=4:nowrap:ai:expandtab:sw=4 +*/ Added: cppcutter/cppcut-test.h (+81 -0) 100644 =================================================================== --- /dev/null +++ cppcutter/cppcut-test.h 2014-01-20 00:13:03 +0900 (41a1af9) @@ -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 __CPPCUT_TEST_H__ +#define __CPPCUT_TEST_H__ + +#include <glib-object.h> + +#include <cutter/cut-test.h> + +/** + * SECTION: cppcut-test + * @title: Test class for C++. + * @short_description: Adds C++ exception support to CutTest. + * + */ + +G_BEGIN_DECLS + +#define CPPCUT_TYPE_TEST \ + (cppcut_test_get_type()) +#define CPPCUT_TEST(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj), \ + CPPCUT_TYPE_TEST, \ + CppCutTest)) +#define CPPCUT_TEST_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass), \ + CPPCUT_TYPE_TEST, \ + CppCutTestClass)) +#define CPPCUT_IS_TEST(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj), \ + CPPCUT_TYPE_TEST)) +#define CPPCUT_IS_TEST_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE((klass), \ + CPPCUT_TYPE_TEST)) +#define CPPCUT_TEST_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS((obj), \ + CPPCUT_TYPE_TEST, \ + CppCutTestClass)) + +typedef struct _CppCutTest CppCutTest; +typedef struct _CppCutTestClass CppCutTestClass; + +struct _CppCutTest +{ + CutTest object; +}; + +struct _CppCutTestClass +{ + CutTestClass parent_class; +}; + +GType cppcut_test_get_type (void) G_GNUC_CONST; + +CppCutTest *cppcut_test_new (const gchar *name, + CutTestFunction function); + +G_END_DECLS + +#endif /* __CPPCUT_TEST_H__ */ + +/* +vi:ts=4:nowrap:ai:expandtab:sw=4 +*/ Modified: cutter/cut-loader.c (+31 -2) =================================================================== --- cutter/cut-loader.c 2014-01-19 23:41:38 +0900 (2f6149f) +++ cutter/cut-loader.c 2014-01-20 00:13:03 +0900 (bab89b5) @@ -1,6 +1,6 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* - * Copyright (C) 2007-2013 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 @@ -80,6 +80,8 @@ struct _CutLoaderPrivate gboolean keep_opening; gboolean enable_convenience_attribute_definition; gchar *base_directory; + CutCreateTestFunction create_test_function; + gpointer create_test_function_user_data; }; enum @@ -179,6 +181,8 @@ cut_loader_init (CutLoader *loader) priv->keep_opening = FALSE; priv->enable_convenience_attribute_definition = FALSE; priv->base_directory = NULL; + priv->create_test_function = NULL; + priv->create_test_function_user_data = NULL; } static void @@ -325,6 +329,18 @@ cut_loader_set_base_directory (CutLoader *loader, const gchar *base_directory) priv->base_directory = g_strdup(base_directory); } +void +cut_loader_set_create_test_function (CutLoader *loader, + CutCreateTestFunction create_test_function, + gpointer user_data) +{ + CutLoaderPrivate *priv; + + priv = CUT_LOADER_GET_PRIVATE(loader); + priv->create_test_function = create_test_function; + priv->create_test_function_user_data = user_data; +} + static inline const gchar * skip_cpp_namespace_gcc (const gchar *name, GString *namespaces) { @@ -1017,6 +1033,19 @@ apply_attributes (CutLoaderPrivate *priv, CutTest *test, SymbolNames *names) } } +static CutTest * +create_test (CutLoaderPrivate *priv, + const gchar *name, + CutTestFunction test_function) +{ + if (priv->create_test_function) { + return priv->create_test_function(name, test_function, + priv->create_test_function_user_data); + } else { + return cut_test_new(name, test_function); + } +} + static void register_valid_test (CutLoader *loader, CutTestCase *test_case, SymbolNames *names) @@ -1054,7 +1083,7 @@ register_valid_test (CutLoader *loader, CutTestCase *test_case, data_setup_function); test = CUT_TEST(test_iterator); } else { - test = cut_test_new(names->test_name, test_function); + test = create_test(priv, names->test_name, test_function); } cut_test_set_base_directory(test, priv->base_directory); Modified: cutter/cut-loader.h (+8 -1) =================================================================== --- cutter/cut-loader.h 2014-01-19 23:41:38 +0900 (df35a4c) +++ cutter/cut-loader.h 2014-01-20 00:13:03 +0900 (76ffc4d) @@ -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 @@ -38,6 +38,9 @@ G_BEGIN_DECLS typedef struct _CutLoader CutLoader; typedef struct _CutLoaderClass CutLoaderClass; +typedef CutTest *(*CutCreateTestFunction) (const gchar *name, + CutTestFunction function, + gpointer user_data); struct _CutLoader { GObject object; @@ -62,6 +65,10 @@ void cut_loader_set_enable_convenience_attribute_definition const gchar *cut_loader_get_base_directory(CutLoader *loader); void cut_loader_set_base_directory(CutLoader *loader, const gchar *base_directory); +void cut_loader_set_create_test_function + (CutLoader *loader, + CutCreateTestFunction create_test_function, + gpointer user_data); GList *cut_loader_load_test_cases (CutLoader *loader); CutTestCase *cut_loader_load_test_case (CutLoader *loader); CutTestSuite *cut_loader_load_test_suite (CutLoader *loader); Modified: module/Makefile.am (+5 -1) =================================================================== --- module/Makefile.am 2014-01-19 23:41:38 +0900 (39b9c0c) +++ module/Makefile.am 2014-01-20 00:13:03 +0900 (5d85b90) @@ -1 +1,5 @@ -SUBDIRS = ui report stream +SUBDIRS = \ + ui \ + report \ + stream \ + loader-customizer Added: module/loader-customizer/Makefile.am (+32 -0) 100644 =================================================================== --- /dev/null +++ module/loader-customizer/Makefile.am 2014-01-20 00:13:03 +0900 (575e9ea) @@ -0,0 +1,32 @@ +AM_CPPFLAGS = \ + -I$(top_builddir) \ + -I$(top_srcdir) + +AM_CFLAGS = \ + $(GLIB_CFLAGS) \ + $(CUTTER_CFLAGS) \ + $(CPPCUTTER_CFLAGS) \ + $(COVERAGE_CFLAGS) + +AM_LDFLAGS = \ + -avoid-version \ + -module \ + -no-undefined \ + -export-dynamic \ + $(LIBTOOL_EXPORT_OPTIONS) + +LIBS = \ + $(GLIB_LIBS) \ + $(top_builddir)/cutter/libcutter.la \ + $(top_builddir)/cppcutter/libcppcutter.la + +loader_customizer_module_LTLIBRARIES = \ + exception.la +loader_customizer_factory_module_LTLIBRARIES = \ + exception-factory.la + +exception_la_SOURCES = \ + cut-exception-loader-customizer.c + +exception_factory_la_SOURCES = \ + cut-exception-loader-customizer-factory.c Added: module/loader-customizer/cut-exception-loader-customizer-factory.c (+145 -0) 100644 =================================================================== --- /dev/null +++ module/loader-customizer/cut-exception-loader-customizer-factory.c 2014-01-20 00:13:03 +0900 (834062b) @@ -0,0 +1,145 @@ +/* -*- 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 <glib/gi18n-lib.h> +#include <gmodule.h> + +#include <cutter/cut-module-impl.h> +#include <cutter/cut-module-factory.h> +#include <cutter/cut-loader-customizer.h> + +#define CUT_TYPE_EXCEPTION_LOADER_CUSTOMIZER_FACTORY \ + cut_type_exception_loader_customizer_factory +#define CUT_EXCEPTION_LOADER_CUSTOMIZER_FACTORY(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj), \ + CUT_TYPE_EXCEPTION_LOADER_CUSTOMIZER_FACTORY, \ + CutExceptionLoaderCustomizerFactory)) +#define CUT_EXCEPTION_LOADER_CUSTOMIZER_FACTORY_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass), \ + CUT_TYPE_EXCEPTION_LOADER_CUSTOMIZER_FACTORY, \ + CutExceptionLoaderCustomizerFactoryClass)) +#define CUT_IS_EXCEPTION_LOADER_CUSTOMIZER_FACTORY(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj), \ + CUT_TYPE_EXCEPTION_LOADER_CUSTOMIZER_FACTORY)) +#define CUT_IS_EXCEPTION_LOADER_CUSTOMIZER_FACTORY_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE((klass), \ + CUT_TYPE_EXCEPTION_LOADER_CUSTOMIZER_FACTORY)) +#define CUT_EXCEPTION_LOADER_CUSTOMIZER_FACTORY_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS((obj), \ + CUT_TYPE_EXCEPTION_LOADER_CUSTOMIZER_FACTORY, \ + CutExceptionLoaderCustomizerFactoryClass)) + +typedef struct _CutExceptionLoaderCustomizerFactory CutExceptionLoaderCustomizerFactory; +typedef struct _CutExceptionLoaderCustomizerFactoryClass CutExceptionLoaderCustomizerFactoryClass; + +struct _CutExceptionLoaderCustomizerFactory +{ + CutModuleFactory object; +}; + +struct _CutExceptionLoaderCustomizerFactoryClass +{ + CutModuleFactoryClass parent_class; +}; + +static GType cut_type_exception_loader_customizer_factory = 0; +static CutModuleFactoryClass *parent_class; + +static GObject *create (CutModuleFactory *factory); + +static void +class_init (CutModuleFactoryClass *klass) +{ + CutModuleFactoryClass *factory_class; + + parent_class = g_type_class_peek_parent(klass); + + factory_class = CUT_MODULE_FACTORY_CLASS(klass); + + factory_class->create = create; +} + +static void +init (CutExceptionLoaderCustomizerFactory *console) +{ +} + +static void +register_type (GTypeModule *type_module) +{ + static const GTypeInfo info = { + sizeof(CutExceptionLoaderCustomizerFactoryClass), + (GBaseInitFunc)NULL, + (GBaseFinalizeFunc)NULL, + (GClassInitFunc)class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof(CutExceptionLoaderCustomizerFactory), + 0, + (GInstanceInitFunc)init, + }; + + cut_type_exception_loader_customizer_factory = + g_type_module_register_type(type_module, + CUT_TYPE_MODULE_FACTORY, + "CutExceptionLoaderCustomizerFactory", + &info, 0); +} + +G_MODULE_EXPORT GList * +CUT_MODULE_IMPL_INIT (GTypeModule *type_module) +{ + GList *registered_types = NULL; + + register_type(type_module); + if (cut_type_exception_loader_customizer_factory) { + registered_types = + g_list_prepend(registered_types, + (gchar *)g_type_name(cut_type_exception_loader_customizer_factory)); + } + + return registered_types; +} + +G_MODULE_EXPORT void +CUT_MODULE_IMPL_EXIT (void) +{ +} + +G_MODULE_EXPORT GObject * +CUT_MODULE_IMPL_INSTANTIATE (const gchar *first_property, va_list var_args) +{ + return g_object_new_valist(CUT_TYPE_EXCEPTION_LOADER_CUSTOMIZER_FACTORY, first_property, var_args); +} + +GObject * +create (CutModuleFactory *factory) +{ + return G_OBJECT(cut_loader_customizer_new("exception", + NULL)); +} + +/* +vi:ts=4:nowrap:ai:expandtab:sw=4 +*/ Added: module/loader-customizer/cut-exception-loader-customizer.c (+154 -0) 100644 =================================================================== --- /dev/null +++ module/loader-customizer/cut-exception-loader-customizer.c 2014-01-20 00:13:03 +0900 (3e9eabd) @@ -0,0 +1,154 @@ +/* -*- 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 <gmodule.h> + +#include <cutter/cut-module-impl.h> +#include <cutter/cut-loader-customizer.h> + +#include <cppcutter/cppcut-test.h> +#include <cppcutter/cppcut-iterated-test.h> + +#define CUT_TYPE_EXCEPTION_LOADER_CUSTOMIZER \ + cut_type_exception_loader_customizer +#define CUT_EXCEPTION_LOADER_CUSTOMIZER(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj), \ + CUT_TYPE_EXCEPTION_LOADER_CUSTOMIZER, \ + CutExceptionLoaderCustomizer)) +#define CUT_EXCEPTION_LOADER_CUSTOMIZER_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass), \ + CUT_TYPE_EXCEPTION_LOADER_CUSTOMIZER, \ + CutExceptionLoaderCustomizerClass)) +#define CUT_IS_EXCEPTION_LOADER_CUSTOMIZER(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj), \ + CUT_TYPE_EXCEPTION_LOADER_CUSTOMIZER)) +#define CUT_IS_EXCEPTION_LOADER_CUSTOMIZER_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE((klass), \ + CUT_TYPE_EXCEPTION_LOADER_CUSTOMIZER)) +#define CUT_EXCEPTION_LOADER_CUSTOMIZER_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS((obj), \ + CUT_TYPE_EXCEPTION_LOADER_CUSTOMIZER, \ + CutExceptionLoaderCustomizerClass)) + +typedef struct _CutExceptionLoaderCustomizer CutExceptionLoaderCustomizer; +typedef struct _CutExceptionLoaderCustomizerClass CutExceptionLoaderCustomizerClass; + +struct _CutExceptionLoaderCustomizer +{ + CutLoaderCustomizer parent; +}; + +struct _CutExceptionLoaderCustomizerClass +{ + CutLoaderCustomizerClass parent_class; +}; + +static GType cut_type_exception_loader_customizer = 0; +static GObjectClass *parent_class; + +static void customize (CutLoaderCustomizer *customizer, + CutLoader *loader); + +static void +class_init (CutExceptionLoaderCustomizerClass *klass) +{ + CutLoaderCustomizerClass *loader_customizer_class; + + parent_class = g_type_class_peek_parent(klass); + + loader_customizer_class = CUT_LOADER_CUSTOMIZER_CLASS(klass); + loader_customizer_class->customize = customize; +} + +static void +init (CutExceptionLoaderCustomizer *customizer) +{ +} + +static void +register_type (GTypeModule *type_module) +{ + static const GTypeInfo info = { + sizeof(CutExceptionLoaderCustomizerClass), + (GBaseInitFunc)NULL, + (GBaseFinalizeFunc)NULL, + (GClassInitFunc)class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof(CutExceptionLoaderCustomizer), + 0, + (GInstanceInitFunc)init, + }; + + cut_type_exception_loader_customizer = + g_type_module_register_type(type_module, + CUT_TYPE_LOADER_CUSTOMIZER, + "CutExceptionLoaderCustomizer", + &info, 0); +} + +G_MODULE_EXPORT GList * +CUT_MODULE_IMPL_INIT (GTypeModule *type_module) +{ + GList *registered_types = NULL; + + register_type(type_module); + if (cut_type_exception_loader_customizer) { + registered_types = + g_list_prepend(registered_types, + (gchar *)g_type_name(cut_type_exception_loader_customizer)); + } + + return registered_types; +} + +G_MODULE_EXPORT void +CUT_MODULE_IMPL_EXIT (void) +{ +} + +G_MODULE_EXPORT GObject * +CUT_MODULE_IMPL_INSTANTIATE (const gchar *first_property, va_list var_args) +{ + return g_object_new_valist(CUT_TYPE_EXCEPTION_LOADER_CUSTOMIZER, + first_property, var_args); +} + +static CutTest * +create_test (const gchar *name, + CutTestFunction function, + gpointer user_data) +{ + return CUT_TEST(cppcut_test_new(name, function)); +} + +static void +customize (CutLoaderCustomizer *customizer, CutLoader *loader) +{ + cut_loader_set_create_test_function(loader, create_test, NULL); +} + +/* +vi:ts=4:nowrap:ai:expandtab:sw=4 +*/ Modified: test/cppcutter/Makefile.am (+6 -4) =================================================================== --- test/cppcutter/Makefile.am 2014-01-19 23:41:38 +0900 (8376641) +++ test/cppcutter/Makefile.am 2014-01-20 00:13:03 +0900 (498f6cf) @@ -1,4 +1,4 @@ -AM_CPPFLAGS = \ +AM_CPPFLAGS = \ -I$(top_builddir) \ -I$(top_srcdir) \ -I$(top_srcdir)/cutter \ @@ -10,8 +10,8 @@ AM_CXXFLAGS = $(CUTTER_CFLAGS) CLEANFILES = *.gcno *.gcda -check_LTLIBRARIES = \ - test-cppcut-assertions.la +check_LTLIBRARIES = \ + test-cppcut.la AM_LDFLAGS = \ -module \ @@ -25,4 +25,6 @@ LIBS = \ $(top_builddir)/test/lib/libcuttest-utils.la \ $(GLIB_LIBS) -test_cppcut_assertions_la_SOURCES = test-cppcut-assertions.cpp +test_cppcut_la_SOURCES = \ + test-cppcut-assertions.cpp \ + test-cppcut-test.cpp Added: test/cppcutter/test-cppcut-test.cpp (+164 -0) 100644 =================================================================== --- /dev/null +++ test/cppcutter/test-cppcut-test.cpp 2014-01-20 00:13:03 +0900 (22a984d) @@ -0,0 +1,164 @@ +/* -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Copyright (C) 2014 Kouhei Sutou <ko...@cl...> + * Copyright (C) 2014 Kazuhiro Yamato <kz...@gm...> + * + * 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/>. + * + */ + +#include <typeinfo> + +#include <cppcutter.h> + +#include <cppcutter/cppcut-test.h> +#include <cutter/cut-test-runner.h> + +#include "../lib/cuttest-assertions.h" + +#define MARK_FAIL(assertion) do \ +{ \ + fail_line = __LINE__; \ + assertion; \ +} while (0) + +#define FAIL_LOCATION (cut_take_printf("%s:%d", __FILE__, fail_line)) + +namespace cppcut_test +{ + CppCutTest *test; + CutRunContext *run_context; + CutTestContext *test_context; + CutTestResult *test_result; + + gint fail_line; + + static gboolean + run (void) + { + gboolean success; + + run_context = CUT_RUN_CONTEXT(cut_test_runner_new()); + + test_context = cut_test_context_new(run_context, NULL, NULL, NULL, + CUT_TEST(test)); + cut_test_context_current_push(test_context); + success = cut_test_runner_run_test(CUT_TEST_RUNNER(run_context), + CUT_TEST(test), test_context); + cut_test_context_current_pop(); + + return success; + } + + void + cut_setup (void) + { + test = NULL; + run_context = NULL; + test_context = NULL; + test_result = NULL; + + fail_line = 0; + } + + void + cut_teardown (void) + { + if (test) + g_object_unref(test); + if (run_context) + g_object_unref(run_context); + if (test_context) + g_object_unref(test_context); + if (test_result) + g_object_unref(test_result); + } + + class StubException : public std::exception + { + public: + StubException(const char *message) : message_(message) + { + } + + virtual const char * + what(void) const throw() + { + return message_; + } + + private: + const char *message_; + }; + + static void + stub_std_exception (void) + { + throw StubException("std::exception family exception"); + } + + void + test_std_exception (void) + { + test = cppcut_test_new("std::exception test", stub_std_exception); + cut_assert_not_null(test); + + cut_assert_false(run()); + cut_assert_test_result_summary(run_context, 1, 0, 0, 0, 1, 0, 0, 0); + const gchar *system_message = + cut_take_printf("Unhandled C++ standard exception is thrown: " + "<%s>: %s", + typeid(StubException).name(), + "std::exception family exception"); + cut_assert_test_result(run_context, 0, CUT_TEST_RESULT_ERROR, + "std::exception test", + NULL, + system_message, + NULL, NULL, + NULL, + "void cppcut_test::stub_standard_exception()", + NULL); + } + + static void + stub_not_std_exception (void) + { + throw "not std::exception"; + } + + void + test_not_std_exception (void) + { + test = cppcut_test_new("not std::exception test", + stub_not_std_exception); + cut_assert_not_null(test); + + cut_assert_false(run()); + cut_assert_test_result_summary(run_context, 1, 0, 0, 0, 1, 0, 0, 0); + const gchar *system_message = + "Unhandled C++ non-standard exception is thrown"; + cut_assert_test_result(run_context, 0, CUT_TEST_RESULT_ERROR, + "not std::exception test", + NULL, + system_message, + NULL, NULL, + NULL, + "void cppcut_test::stub_not_standard_exception()", + NULL); + } +} + +/* +vi:ts=4:nowrap:ai:expandtab:sw=4:ts=4 +*/ |
|
From: Kouhei S. <nul...@cl...> - 2014-01-19 14:42:05
|
Kouhei Sutou 2014-01-19 23:41:38 +0900 (Sun, 19 Jan 2014) New Revision: a2e6bbbcc24a80308ef74c470226410514e59070 https://github.com/clear-code/cutter/commit/a2e6bbbcc24a80308ef74c470226410514e59070 Message: Add --enable-debug configure option Modified files: configure.ac Modified: configure.ac (+17 -0) =================================================================== --- configure.ac 2014-01-19 19:30:54 +0900 (a616d13) +++ configure.ac 2014-01-19 23:41:38 +0900 (0cc44ff) @@ -87,6 +87,23 @@ AC_PROG_INSTALL AC_PROG_LN_S AC_PROG_MAKE_SET +# For debug +AC_ARG_ENABLE(debug, + [AS_HELP_STRING([--enable-debug], + [use debug flags (default=no)])], + [cutter_debug="$enableval"], + [cutter_debug="no"]) +if test "x$cutter_debug" != "xno"; then + cutter_debug="yes" + if test "$CLANG" = "yes"; then + CFLAGS="$CFLAGS -O0 -g" + CXXFLAGS="$CXXFLAGS -O0 -g" + elif test "$GCC" = "yes"; then + CFLAGS="$CFLAGS -O0 -g3" + CXXFLAGS="$CXXFLAGS -O0 -g3" + fi +fi + if test "x$GCC" = "xyes"; then case " $CFLAGS " in *[\ \ ]-Wall[\ \ ]*) ;; |
|
From: Kouhei S. <nul...@cl...> - 2014-01-19 10:31:14
|
Kouhei Sutou 2014-01-19 19:30:54 +0900 (Sun, 19 Jan 2014) New Revision: 4ce49ba82b379d3a38ce48b5544090e1a237cc75 https://github.com/clear-code/cutter/commit/4ce49ba82b379d3a38ce48b5544090e1a237cc75 Message: Remove needless spaces Modified files: cppcutter/Makefile.am Modified: cppcutter/Makefile.am (+2 -2) =================================================================== --- cppcutter/Makefile.am 2014-01-19 19:12:57 +0900 (6f3731e) +++ cppcutter/Makefile.am 2014-01-19 19:30:54 +0900 (716036d) @@ -18,11 +18,11 @@ cppcutter_public_headers = \ cppcut-macros.h \ cppcut-message.h -pkginclude_HEADERS = \ +pkginclude_HEADERS = \ cppcutter.h cppcutter_includedir=$(pkgincludedir)/cppcutter -cppcutter_include_HEADERS = \ +cppcutter_include_HEADERS = \ $(cppcutter_public_headers) libcppcutter_sources = \ |
|
From: Kouhei S. <nul...@cl...> - 2014-01-19 10:13:19
|
Kouhei Sutou 2014-01-19 19:12:57 +0900 (Sun, 19 Jan 2014) New Revision: bc60c0fd0b705fa2b3eb8fdfb6bf4ffe66f90476 https://github.com/clear-code/cutter/commit/bc60c0fd0b705fa2b3eb8fdfb6bf4ffe66f90476 Message: Use loaded loader customizers Modified files: cutter/cut-contractor.c cutter/cut-contractor.h cutter/cut-main.c Modified: cutter/cut-contractor.c (+10 -0) =================================================================== --- cutter/cut-contractor.c 2014-01-19 18:20:25 +0900 (1c3b8e6) +++ cutter/cut-contractor.c 2014-01-19 19:12:57 +0900 (07efb71) @@ -189,6 +189,16 @@ cut_contractor_build_all_listener_factories (CutContractor *contractor) return factories; } +GList * +cut_contractor_build_all_loader_customizer_factories (CutContractor *contractor) +{ + CutContractorPrivate *priv = CUT_CONTRACTOR_GET_PRIVATE(contractor); + CutFactoryBuilder *builder; + + builder = CUT_FACTORY_BUILDER(priv->loader_customizer_factory_builder); + return cut_factory_builder_build_all(builder); +} + void cut_contractor_set_option_context (CutContractor *contractor, GOptionContext *context) { Modified: cutter/cut-contractor.h (+2 -0) =================================================================== --- cutter/cut-contractor.h 2014-01-19 18:20:25 +0900 (158c6e3) +++ cutter/cut-contractor.h 2014-01-19 19:12:57 +0900 (9705573) @@ -52,6 +52,8 @@ GList *cut_contractor_build_listener_factories (CutContractor *contractor); GList *cut_contractor_build_all_listener_factories (CutContractor *contractor); +GList *cut_contractor_build_all_loader_customizer_factories + (CutContractor *contractor); gboolean cut_contractor_has_listener_builder (CutContractor *contractor, const gchar *type_name); Modified: cutter/cut-main.c (+32 -0) =================================================================== --- cutter/cut-main.c 2014-01-19 18:20:25 +0900 (c3b96df) +++ cutter/cut-main.c 2014-01-19 19:12:57 +0900 (7b64f4d) @@ -86,6 +86,7 @@ static gboolean use_multi_thread = FALSE; static gint max_threads = 10; static gboolean disable_signal_handling = FALSE; static GList *listener_factories = NULL; +static GList *loader_customizer_factories = NULL; static CutContractor *contractor = NULL; static gchar **original_argv = NULL; static gchar *cutter_command_path = NULL; @@ -311,6 +312,9 @@ cut_init (int *argc, char ***argv) if (!listener_factories) listener_factories = cut_contractor_build_listener_factories(contractor); + loader_customizer_factories = + cut_contractor_build_all_loader_customizer_factories(contractor); + g_option_context_set_help_enabled(option_context, TRUE); g_option_context_set_ignore_unknown_options(option_context, FALSE); if (!g_option_context_parse(option_context, argc, argv, &error)) { @@ -392,6 +396,19 @@ cut_quit (void) cut_ui_quit(); + if (listener_factories) { + g_list_foreach(listener_factories, (GFunc)g_object_unref, NULL); + g_list_free(listener_factories); + listener_factories = NULL; + } + + if (loader_customizer_factories) { + g_list_foreach(loader_customizer_factories, + (GFunc)g_object_unref, NULL); + g_list_free(loader_customizer_factories); + loader_customizer_factories = NULL; + } + if (contractor) { g_object_unref(contractor); contractor = NULL; @@ -418,6 +435,20 @@ cut_quit (void) initialized = FALSE; } +static void +set_loader_customizers (CutRunContext *run_context) +{ + GList *node; + + for (node = loader_customizer_factories; node; node = g_list_next(node)) { + GObject *customizer; + customizer = cut_module_factory_create(CUT_MODULE_FACTORY(node->data)); + cut_run_context_add_loader_customizer(run_context, + CUT_LOADER_CUSTOMIZER(customizer)); + g_object_unref(customizer); + } +} + void cut_setup_run_context (CutRunContext *run_context) { @@ -443,6 +474,7 @@ cut_setup_run_context (CutRunContext *run_context) enable_convenience_attribute_definition); cut_run_context_set_stop_before_test(run_context, stop_before_test); cut_run_context_set_command_line_args(run_context, original_argv); + set_loader_customizers(run_context); } CutRunContext * |
|
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" |
|
From: Kouhei S. <nul...@cl...> - 2014-01-19 08:53:14
|
Kouhei Sutou 2014-01-19 17:52:52 +0900 (Sun, 19 Jan 2014) New Revision: df781afc690ccc1aedabadc72c5f856a24fe4e00 https://github.com/clear-code/cutter/commit/df781afc690ccc1aedabadc72c5f856a24fe4e00 Message: Add missing "listener_" prefix Modified files: cutter/cut-contractor.c cutter/cut-contractor.h cutter/cut-main.c test/cutter/test-cut-contractor.c Modified: cutter/cut-contractor.c (+21 -15) =================================================================== --- cutter/cut-contractor.c 2014-01-19 16:23:55 +0900 (758336e) +++ cutter/cut-contractor.c 2014-01-19 17:52:52 +0900 (af304b8) @@ -37,7 +37,7 @@ typedef struct _CutContractorPrivate CutContractorPrivate; struct _CutContractorPrivate { - GList *builders; + GList *listener_builders; }; G_DEFINE_TYPE(CutContractor, cut_contractor, G_TYPE_OBJECT) @@ -57,7 +57,7 @@ cut_contractor_class_init (CutContractorClass *klass) } static GList * -create_default_builders (void) +create_default_listener_builders (void) { GList *list = NULL; @@ -74,7 +74,7 @@ load_ui_factory (CutContractor *contractor) GList *node; CutContractorPrivate *priv = CUT_CONTRACTOR_GET_PRIVATE(contractor); - for (node = priv->builders; node; node = g_list_next(node)) { + for (node = priv->listener_builders; node; node = g_list_next(node)) { const gchar *module_dir, *type_name; CutFactoryBuilder *builder = CUT_FACTORY_BUILDER(node->data); @@ -94,7 +94,7 @@ cut_contractor_init (CutContractor *contractor) CutContractorPrivate *priv = CUT_CONTRACTOR_GET_PRIVATE(contractor); cut_module_factory_init(); - priv->builders = create_default_builders(); + priv->listener_builders = create_default_listener_builders(); load_ui_factory(contractor); } @@ -104,10 +104,15 @@ dispose (GObject *object) { CutContractorPrivate *priv = CUT_CONTRACTOR_GET_PRIVATE(object); - if (priv->builders) { - g_list_foreach(priv->builders, (GFunc)g_object_unref, NULL); - g_list_free(priv->builders); - priv->builders = NULL; + if (priv->listener_builders) { + g_list_foreach(priv->listener_builders, (GFunc)g_object_unref, NULL); + g_list_free(priv->listener_builders); + priv->listener_builders = NULL; + } + + if (priv->loader_customizer_factory_builder) { + g_object_unref(priv->loader_customizer_factory_builder); + priv->loader_customizer_factory_builder = NULL; } cut_module_factory_quit(); @@ -122,12 +127,13 @@ cut_contractor_new (void) } gboolean -cut_contractor_has_builder (CutContractor *contractor, const gchar *type_name) +cut_contractor_has_listener_builder (CutContractor *contractor, + const gchar *type_name) { GList *node; CutContractorPrivate *priv = CUT_CONTRACTOR_GET_PRIVATE(contractor); - for (node = priv->builders; node; node = g_list_next(node)) { + for (node = priv->listener_builders; node; node = g_list_next(node)) { CutFactoryBuilder *builder = CUT_FACTORY_BUILDER(node->data); const gchar *name; name = cut_factory_builder_get_type_name(builder); @@ -139,12 +145,12 @@ cut_contractor_has_builder (CutContractor *contractor, const gchar *type_name) } GList * -cut_contractor_build_factories (CutContractor *contractor) +cut_contractor_build_listener_factories (CutContractor *contractor) { GList *factories = NULL, *node; CutContractorPrivate *priv = CUT_CONTRACTOR_GET_PRIVATE(contractor); - for (node = priv->builders; node; node = g_list_next(node)) { + for (node = priv->listener_builders; node; node = g_list_next(node)) { CutFactoryBuilder *builder = CUT_FACTORY_BUILDER(node->data); factories = g_list_concat(cut_factory_builder_build(builder), factories); } @@ -152,12 +158,12 @@ cut_contractor_build_factories (CutContractor *contractor) } GList * -cut_contractor_build_all_factories (CutContractor *contractor) +cut_contractor_build_all_listener_factories (CutContractor *contractor) { GList *factories = NULL, *node; CutContractorPrivate *priv = CUT_CONTRACTOR_GET_PRIVATE(contractor); - for (node = priv->builders; node; node = g_list_next(node)) { + for (node = priv->listener_builders; node; node = g_list_next(node)) { CutFactoryBuilder *builder = CUT_FACTORY_BUILDER(node->data); factories = g_list_concat(cut_factory_builder_build_all(builder), factories); } @@ -170,7 +176,7 @@ cut_contractor_set_option_context (CutContractor *contractor, GOptionContext *co GList *node; CutContractorPrivate *priv = CUT_CONTRACTOR_GET_PRIVATE(contractor); - for (node = priv->builders; node; node = g_list_next(node)) { + for (node = priv->listener_builders; node; node = g_list_next(node)) { CutFactoryBuilder *builder = CUT_FACTORY_BUILDER(node->data); cut_factory_builder_set_option_context(builder, context); } Modified: cutter/cut-contractor.h (+7 -4) =================================================================== --- cutter/cut-contractor.h 2014-01-19 16:23:55 +0900 (b97d925) +++ cutter/cut-contractor.h 2014-01-19 17:52:52 +0900 (158c6e3) @@ -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 @@ -48,9 +48,12 @@ GType cut_contractor_get_type (void) G_GNUC_CONST; CutContractor *cut_contractor_new (void); -GList *cut_contractor_build_factories (CutContractor *contractor); -GList *cut_contractor_build_all_factories(CutContractor *contractor); -gboolean cut_contractor_has_builder (CutContractor *contractor, +GList *cut_contractor_build_listener_factories + (CutContractor *contractor); +GList *cut_contractor_build_all_listener_factories + (CutContractor *contractor); +gboolean cut_contractor_has_listener_builder + (CutContractor *contractor, const gchar *type_name); void cut_contractor_set_option_context (CutContractor *contractor, GOptionContext *context); Modified: cutter/cut-main.c (+7 -6) =================================================================== --- cutter/cut-main.c 2014-01-19 16:23:55 +0900 (eede8fb) +++ cutter/cut-main.c 2014-01-19 17:52:52 +0900 (c3b96df) @@ -1,6 +1,6 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* - * Copyright (C) 2007-2013 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 @@ -85,7 +85,7 @@ static CutOrder test_case_order = CUT_ORDER_NONE_SPECIFIED; static gboolean use_multi_thread = FALSE; static gint max_threads = 10; static gboolean disable_signal_handling = FALSE; -static GList *factories = NULL; +static GList *listener_factories = NULL; static CutContractor *contractor = NULL; static gchar **original_argv = NULL; static gchar *cutter_command_path = NULL; @@ -302,13 +302,14 @@ cut_init (int *argc, char ***argv) for (i = 1; i < *argc; i++) { if (g_str_has_prefix((*argv)[i], "--help-")) { - factories = cut_contractor_build_all_factories(contractor); + listener_factories = + cut_contractor_build_all_listener_factories(contractor); break; } } - if (!factories) - factories = cut_contractor_build_factories(contractor); + if (!listener_factories) + listener_factories = cut_contractor_build_listener_factories(contractor); g_option_context_set_help_enabled(option_context, TRUE); g_option_context_set_ignore_unknown_options(option_context, FALSE); @@ -459,7 +460,7 @@ create_listeners (void) { GList *listeners = NULL, *node; - for (node = factories; node; node = g_list_next(node)) { + for (node = listener_factories; node; node = g_list_next(node)) { GObject *listener; listener = cut_module_factory_create(CUT_MODULE_FACTORY(node->data)); listeners = g_list_prepend(listeners, listener); Modified: test/cutter/test-cut-contractor.c (+5 -5) =================================================================== --- test/cutter/test-cut-contractor.c 2014-01-19 16:23:55 +0900 (6f310bd) +++ test/cutter/test-cut-contractor.c 2014-01-19 17:52:52 +0900 (fda718d) @@ -1,7 +1,7 @@ #include "cutter.h" #include "cut-contractor.h" -void test_has_builder (void); +void test_has_listener_builder (void); static CutContractor *contractor; @@ -19,13 +19,13 @@ cut_teardown (void) } void -test_has_builder (void) +test_has_listener_builder (void) { contractor = cut_contractor_new(); cut_assert(contractor); - cut_assert(cut_contractor_has_builder(contractor, "ui")); - cut_assert(cut_contractor_has_builder(contractor, "report")); - cut_assert(!cut_contractor_has_builder(contractor, "XXX")); + cut_assert(cut_contractor_has_listener_builder(contractor, "ui")); + cut_assert(cut_contractor_has_listener_builder(contractor, "report")); + cut_assert(!cut_contractor_has_listener_builder(contractor, "XXX")); } /* |
|
From: Kouhei S. <nul...@cl...> - 2014-01-19 07:24:16
|
Kouhei Sutou 2014-01-19 16:23:55 +0900 (Sun, 19 Jan 2014) New Revision: b059a230e0dce72b8f5d6357c844a9e2f8ce47d9 https://github.com/clear-code/cutter/commit/b059a230e0dce72b8f5d6357c844a9e2f8ce47d9 Message: Fix wrong macro names These macros can be used with not only listener but also general modules. Removed files: cutter/cut-listener-utils.h Modified files: cutter/Makefile.am cutter/cut-module.h cutter/cut-report.c cutter/cut-stream.c cutter/cut-ui.c Modified: cutter/Makefile.am (+0 -1) =================================================================== --- cutter/Makefile.am 2014-01-19 16:02:10 +0900 (5e29785) +++ cutter/Makefile.am 2014-01-19 16:23:55 +0900 (40178fa) @@ -39,7 +39,6 @@ libcutter_public_headers = \ cut-factory-builder.h \ cut-file-stream-reader.h \ cut-iterated-test.h \ - cut-listener-utils.h \ cut-listener.h \ cut-main.h \ cut-module-factory-utils.h \ Deleted: cutter/cut-listener-utils.h (+0 -93) 100644 =================================================================== --- cutter/cut-listener-utils.h 2014-01-19 16:02:10 +0900 (527f384) +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * Copyright (C) 2007 Kouhei Sutou <ko...@co...> - * - * 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_LISTENER_UTILS_H__ -#define __CUT_LISTENER_UTILS_H__ - -#include <glib-object.h> -#include "cut-utils.h" - -G_BEGIN_DECLS - -#ifdef G_OS_WIN32 -# define CUT_DEFINE_ADDITIONAL_LISTENER_VARIABLES(name) \ - static gchar *win32_ ## name ## _module_dir = NULL; -# define CUT_LISTENER_RETURN_DEFAULT_MODULE_DIR(name, NAME) do \ - { \ - if (!win32_ ## name ## _module_dir) \ - win32_ ## name ## _module_dir = \ - cut_win32_build_module_dir_name(#name); \ - return win32_ ## name ## _module_dir; \ - } while (0) -#else -# define CUT_DEFINE_ADDITIONAL_LISTENER_VARIABLES(name) -# define CUT_LISTENER_RETURN_DEFAULT_MODULE_DIR(name, NAME) \ - return NAME ## _MODULE_DIR -#endif - - -#define CUT_DEFINE_LISTENER_MODULE(name, NAME) \ -static GList *name ## s = NULL; \ -static gchar *name ## _module_dir = NULL; \ -CUT_DEFINE_ADDITIONAL_LISTENER_VARIABLES(name) \ - \ -static const gchar * \ -_cut_ ## name ## _module_dir (void) \ -{ \ - const gchar *dir; \ - \ - if (name ## _module_dir) \ - return name ## _module_dir; \ - \ - dir = g_getenv("CUT_" #NAME "_MODULE_DIR"); \ - if (dir) \ - return dir; \ - \ - CUT_LISTENER_RETURN_DEFAULT_MODULE_DIR(name, NAME); \ -} \ - \ -static CutModule * \ -cut_ ## name ## _load_module (const gchar *name) \ -{ \ - CutModule *module; \ - \ - module = cut_module_find(name ## s, name); \ - if (module) \ - return module; \ - \ - module = cut_module_load_module(_cut_ ## name ## _module_dir(), \ - name); \ - if (module) { \ - if (g_type_module_use(G_TYPE_MODULE(module))) { \ - name ## s = g_list_prepend(name ## s, module); \ - g_type_module_unuse(G_TYPE_MODULE(module)); \ - } \ - } \ - \ - return module; \ -} - - -G_END_DECLS - -#endif /* __CUT_LISTENER_UTILS_H__ */ - -/* -vi:ts=4:nowrap:ai:expandtab:sw=4 -*/ Modified: cutter/cut-module.h (+59 -0) =================================================================== --- cutter/cut-module.h 2014-01-19 16:02:10 +0900 (c2d67b2) +++ cutter/cut-module.h 2014-01-19 16:23:55 +0900 (40a3cdd) @@ -24,6 +24,65 @@ G_BEGIN_DECLS +#ifdef G_OS_WIN32 +# define CUT_MODULE_DEFINE_ADDITIONAL_VARIABLES(name) \ + static gchar *win32_ ## name ## _module_dir = NULL; +# define CUT_MODULE_RETURN_DEFAULT_MODULE_DIR(name, NAME) do \ + { \ + if (!win32_ ## name ## _module_dir) \ + win32_ ## name ## _module_dir = \ + cut_win32_build_module_dir_name(#name); \ + return win32_ ## name ## _module_dir; \ + } while (0) +#else +# define CUT_MODULE_DEFINE_ADDITIONAL_VARIABLES(name) +# define CUT_MODULE_RETURN_DEFAULT_MODULE_DIR(name, NAME) \ + return NAME ## _MODULE_DIR +#endif + + +#define CUT_MODULE_DEFINE_INTERNAL_DEFINITIONS(name, NAME) \ +static GList *name ## s = NULL; \ +static gchar *name ## _module_dir = NULL; \ +CUT_MODULE_DEFINE_ADDITIONAL_VARIABLES(name) \ + \ +static const gchar * \ +_cut_ ## name ## _module_dir (void) \ +{ \ + const gchar *dir; \ + \ + if (name ## _module_dir) \ + return name ## _module_dir; \ + \ + dir = g_getenv("CUT_" #NAME "_MODULE_DIR"); \ + if (dir) \ + return dir; \ + \ + CUT_MODULE_RETURN_DEFAULT_MODULE_DIR(name, NAME); \ +} \ + \ +static CutModule * \ +cut_ ## name ## _load_module (const gchar *name) \ +{ \ + CutModule *module; \ + \ + module = cut_module_find(name ## s, name); \ + if (module) \ + return module; \ + \ + module = cut_module_load_module(_cut_ ## name ## _module_dir(), \ + name); \ + if (module) { \ + if (g_type_module_use(G_TYPE_MODULE(module))) { \ + name ## s = g_list_prepend(name ## s, module); \ + g_type_module_unuse(G_TYPE_MODULE(module)); \ + } \ + } \ + \ + return module; \ +} + + #define CUT_TYPE_MODULE (cut_module_get_type ()) #define CUT_MODULE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CUT_TYPE_MODULE, CutModule)) #define CUT_MODULE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CUT_TYPE_MODULE, CutModuleClass)) Modified: cutter/cut-report.c (+2 -3) =================================================================== --- cutter/cut-report.c 2014-01-19 16:02:10 +0900 (fe015cf) +++ cutter/cut-report.c 2014-01-19 16:23:55 +0900 (9c6f89e) @@ -1,7 +1,7 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * Copyright (C) 2008 g新部 Hiroyuki Ikezoe <poi...@ik...> - * Copyright (C) 2009 Kouhei Sutou <ko...@co...> + * Copyright (C) 2009-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 @@ -26,7 +26,6 @@ #include "cut-report.h" #include "cut-module.h" -#include "cut-listener-utils.h" #define CUT_REPORT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), CUT_TYPE_REPORT, CutReportPrivate)) @@ -53,7 +52,7 @@ static void get_property (GObject *object, GParamSpec *pspec); G_DEFINE_ABSTRACT_TYPE (CutReport, cut_report, G_TYPE_OBJECT) -CUT_DEFINE_LISTENER_MODULE(report, REPORT) +CUT_MODULE_DEFINE_INTERNAL_DEFINITIONS(report, REPORT) static void cut_report_class_init (CutReportClass *klass) Modified: cutter/cut-stream.c (+1 -2) =================================================================== --- cutter/cut-stream.c 2014-01-19 16:02:10 +0900 (7a74d2e) +++ cutter/cut-stream.c 2014-01-19 16:23:55 +0900 (345b295) @@ -25,10 +25,9 @@ #include "cut-stream.h" #include "cut-module.h" -#include "cut-listener-utils.h" G_DEFINE_ABSTRACT_TYPE (CutStream, cut_stream, G_TYPE_OBJECT) -CUT_DEFINE_LISTENER_MODULE(stream, STREAM) +CUT_MODULE_DEFINE_INTERNAL_DEFINITIONS(stream, STREAM) static void cut_stream_class_init (CutStreamClass *klass) Modified: cutter/cut-ui.c (+1 -2) =================================================================== --- cutter/cut-ui.c 2014-01-19 16:02:10 +0900 (9eca315) +++ cutter/cut-ui.c 2014-01-19 16:23:55 +0900 (55f0884) @@ -25,9 +25,8 @@ #include "cut-ui.h" #include "cut-module.h" -#include "cut-listener-utils.h" -CUT_DEFINE_LISTENER_MODULE(ui, UI) +CUT_MODULE_DEFINE_INTERNAL_DEFINITIONS(ui, UI) void cut_ui_init (void) |
|
From: Kouhei S. <nul...@cl...> - 2014-01-19 07:02:46
|
Kouhei Sutou 2014-01-19 16:02:10 +0900 (Sun, 19 Jan 2014) New Revision: 2b665870b8ddc5dcd6f7b2cbce956bf9ae450957 https://github.com/clear-code/cutter/commit/2b665870b8ddc5dcd6f7b2cbce956bf9ae450957 Message: Plug memory leaks on loading all modules Modified files: cutter/cut-report-factory-builder.c cutter/cut-stream-factory-builder.c cutter/cut-ui-factory-builder.c Modified: cutter/cut-report-factory-builder.c (+3 -0) =================================================================== --- cutter/cut-report-factory-builder.c 2013-12-26 10:42:39 +0900 (51a4508) +++ cutter/cut-report-factory-builder.c 2014-01-19 16:02:10 +0900 (43d3490) @@ -294,6 +294,9 @@ build_all (CutFactoryBuilder *builder) 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); } Modified: cutter/cut-stream-factory-builder.c (+3 -0) =================================================================== --- cutter/cut-stream-factory-builder.c 2013-12-26 10:42:39 +0900 (8871372) +++ cutter/cut-stream-factory-builder.c 2014-01-19 16:02:10 +0900 (5b481a8) @@ -248,6 +248,9 @@ build_all (CutFactoryBuilder *builder) 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); } Modified: cutter/cut-ui-factory-builder.c (+3 -0) =================================================================== --- cutter/cut-ui-factory-builder.c 2013-12-26 10:42:39 +0900 (e4c7f5c) +++ cutter/cut-ui-factory-builder.c 2014-01-19 16:02:10 +0900 (e170107) @@ -188,6 +188,9 @@ build_all (CutFactoryBuilder *builder) 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); } |
|
From: Kenji O. <nul...@cl...> - 2013-12-26 01:43:07
|
Kenji Okimoto 2013-12-26 10:42:39 +0900 (Thu, 26 Dec 2013) New Revision: e8fe55061754ce439deef0a3cffb064ce457c66a https://github.com/clear-code/cutter/commit/e8fe55061754ce439deef0a3cffb064ce457c66a Message: configure: Add --with-ruby and --with-rd2 option to specify command path. These options are useful for rbenv user. Modified files: configure.ac Modified: configure.ac (+34 -7) =================================================================== --- configure.ac 2013-12-25 13:02:29 +0900 (1f0f919) +++ configure.ac 2013-12-26 10:42:39 +0900 (178d072) @@ -523,17 +523,44 @@ m4_ifdef([GTK_DOC_CHECK], AM_CONDITIONAL([ENABLE_GTK_DOC], [false])]) dnl ************************************************************** -dnl Checks for RD2 +dnl Checks for Ruby dnl ************************************************************** +ruby_available="no" +AC_ARG_WITH([ruby], + AS_HELP_STRING([--with-ruby=PATH], + [Ruby interpreter path (default: auto-detect)]), + [RUBY="$withval"]) + +if test "$RUBY" = "no"; then + : # ignore +elif test "$RUBY" = ""; then + AC_PATH_PROG(RUBY, ruby, ruby-not-found) +else + AC_CHECK_FILE([$RUBY], + [ruby_available="yes"], + [AC_MSG_ERROR([$RUBY is not found.])]) +fi -AC_PATH_PROG(RUBY, ruby, ruby-not-found) -AC_PATH_PROG(RD2, rd2, rd2-not-found) -if test x"$RD2" != x"rd2-not-found"; then - rd2_available=yes +dnl ************************************************************** +dnl Checks for RD2 +dnl ************************************************************** +rd2_available="no" +AC_ARG_WITH([rd2], + AS_HELP_STRING([--with-rd2=PATH], + [rd2 command path. (default: auto-detect)]), + [RD2="$withval"]) +if test "$RD2" = "no"; then + : # ignore +elif test "$RD2" = ""; then + AC_PATH_PROG(RD2, rd2, rd2-not-found) + if test x"$RD2" != x"rd2-not-found"; then + rd2_available=yes + fi else - rd2_available=no + AC_CHECK_FILE([$RD2], + [rd2_available="yes"], + [AC_MSG_ERROR([$RD2 is not found.])]) fi -AM_CONDITIONAL([HAVE_RD2], [test "$rd2_available" = "yes"]) if test "$rd2_available" = "yes" -o -f "$srcdir/doc/man-build.stamp"; then man_available=yes |
|
From: Kouhei S. <nul...@cl...> - 2013-12-25 04:03:06
|
Kouhei Sutou 2013-12-25 13:02:29 +0900 (Wed, 25 Dec 2013) New Revision: 6ec242886fea31f34ea576a165548e15660aa5d0 https://github.com/clear-code/cutter/commit/6ec242886fea31f34ea576a165548e15660aa5d0 Message: Fix a typo rd2_avialable -> rd2_available ^^ Modified files: configure.ac Modified: configure.ac (+3 -3) =================================================================== --- configure.ac 2013-11-17 23:37:10 +0900 (6451084) +++ configure.ac 2013-12-25 13:02:29 +0900 (1f0f919) @@ -529,13 +529,13 @@ dnl ************************************************************** AC_PATH_PROG(RUBY, ruby, ruby-not-found) AC_PATH_PROG(RD2, rd2, rd2-not-found) if test x"$RD2" != x"rd2-not-found"; then - rd2_avialable=yes + rd2_available=yes else - rd2_avialable=no + rd2_available=no fi AM_CONDITIONAL([HAVE_RD2], [test "$rd2_available" = "yes"]) -if test "$rd2_avialable" = "yes" -o -f "$srcdir/doc/man-build.stamp"; then +if test "$rd2_available" = "yes" -o -f "$srcdir/doc/man-build.stamp"; then man_available=yes else man_available=no |
|
From: Kouhei S. <nul...@cl...> - 2013-11-17 14:37:32
|
Kouhei Sutou 2013-11-17 23:37:10 +0900 (Sun, 17 Nov 2013) New Revision: a7cf856d10e328372dee120afcf888c01f253bde https://github.com/clear-code/cutter/commit/a7cf856d10e328372dee120afcf888c01f253bde Message: Document message level log Modified files: cutter/cut-main.c doc/cutter.rd doc/cutter.rd.ja test/cutter/test-cutter.c Modified: cutter/cut-main.c (+2 -2) =================================================================== --- cutter/cut-main.c 2013-11-17 23:35:12 +0900 (b090998) +++ cutter/cut-main.c 2013-11-17 23:37:10 +0900 (eede8fb) @@ -176,8 +176,8 @@ static const GOptionEntry option_entries[] = N_("Show version"), NULL}, {"log-level", 0, 0, G_OPTION_ARG_CALLBACK, parse_log_level, N_("Set log level to LEVEL. LEVEL can be combined them with '|': " - "(all|default|none|critical|error|warning|info|debug|trace) " - "(default: critical|error|warning)"), + "(all|default|none|critical|error|warning|message|info|debug|trace) " + "(default: critical|error|warning|message)"), "LEVEL"}, {"mode", 0, 0, G_OPTION_ARG_CALLBACK, parse_mode, N_("Set run mode (default: test)"), "[test|analyze|play]"}, Modified: doc/cutter.rd (+2 -1) =================================================================== --- doc/cutter.rd 2013-11-17 23:35:12 +0900 (c1185f0) +++ doc/cutter.rd 2013-11-17 23:37:10 +0900 (3a12bc0) @@ -49,11 +49,12 @@ option is specified. Here are available levels: - * default: equals to "critical|error|warning". + * default: equals to "critical|error|warning|message". * none: logs nothing. * critical: logs only critial information. * error: logs only error information. * warning: logs only warning information. + * message: logs only normal messages. * info: logs only additional information. * debug: logs only debug information. * traces: logs only trace information. Modified: doc/cutter.rd.ja (+2 -1) =================================================================== --- doc/cutter.rd.ja 2013-11-17 23:35:12 +0900 (001294b) +++ doc/cutter.rd.ja 2013-11-17 23:37:10 +0900 (bebcb53) @@ -50,11 +50,12 @@ Cutterはプログラマが新しいテストを書くこと、すでにある 指定できるレベルは以下の通りです。 - * default: 「critical|error|warning」と同じ。 + * default: 「critical|error|warning|message」と同じ。 * none: なにも出力しない。 * critical: 致命的な問題のみ出力。 * error: エラーのみ出力。 * warning: 警告のみ出力。 + * message: 通常のメッセージのみ出力。 * info: 付加情報のみ出力。 * debug: デバッグ情報のみ出力。 * traces: トレース情報のみ出力。 Modified: test/cutter/test-cutter.c (+4 -4) =================================================================== --- test/cutter/test-cutter.c 2013-11-17 23:35:12 +0900 (99fbbdb) +++ test/cutter/test-cutter.c 2013-11-17 23:37:10 +0900 (46304bc) @@ -105,8 +105,8 @@ cut_setup (void) " --version Show version" LINE_FEED_CODE " --log-level=LEVEL " "Set log level to LEVEL. LEVEL can be combined them with '|': " - "(all|default|none|critical|error|warning|info|debug|trace) " - "(default: critical|error|warning)" LINE_FEED_CODE + "(all|default|none|critical|error|warning|message|info|debug|trace) " + "(default: critical|error|warning|message)" LINE_FEED_CODE " --mode=[test|analyze|play] Set run mode (default: test)" LINE_FEED_CODE " -s, --source-directory=DIRECTORY Set directory of source code" LINE_FEED_CODE " -n, --name=TEST_NAME Specify tests" LINE_FEED_CODE @@ -287,8 +287,8 @@ test_help_all (void) " --version Show version" LINE_FEED_CODE " --log-level=LEVEL " "Set log level to LEVEL. LEVEL can be combined them with '|': " - "(all|default|none|critical|error|warning|info|debug|trace) " - "(default: critical|error|warning)" LINE_FEED_CODE + "(all|default|none|critical|error|warning|message|info|debug|trace) " + "(default: critical|error|warning|message)" LINE_FEED_CODE " --mode=[test|analyze|play] Set run mode (default: test)" LINE_FEED_CODE " -s, --source-directory=DIRECTORY Set directory of source code" LINE_FEED_CODE " -n, --name=TEST_NAME Specify tests" LINE_FEED_CODE |
|
From: Kouhei S. <nul...@cl...> - 2013-11-17 14:35:33
|
Kouhei Sutou 2013-11-17 23:26:06 +0900 (Sun, 17 Nov 2013) New Revision: fe0544f09895f3cce1e449991155e6b22724dd32 https://github.com/clear-code/cutter/commit/fe0544f09895f3cce1e449991155e6b22724dd32 Message: Add --log-level option Modified files: cutter/cut-main.c doc/cutter.rd doc/cutter.rd.ja test/cutter/test-cutter.c Modified: cutter/cut-main.c (+32 -1) =================================================================== --- cutter/cut-main.c 2013-11-17 21:57:29 +0900 (c4e0a5a) +++ cutter/cut-main.c 2013-11-17 23:26:06 +0900 (b090998) @@ -1,6 +1,6 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* - * Copyright (C) 2007-2011 Kouhei Sutou <ko...@cl...> + * Copyright (C) 2007-2013 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 @@ -45,6 +45,7 @@ char **environ = NULL; #include "cut-module-factory.h" #include "cut-contractor.h" #include "cut-utils.h" +#include "cut-logger.h" #include "../gcutter/gcut-main.h" #include "../gcutter/gcut-error.h" @@ -103,6 +104,31 @@ print_version (const gchar *option_name, const gchar *value, } static gboolean +parse_log_level (const gchar *option_name, + const gchar *value, + gpointer data, + GError **error) +{ + GError *log_level_error = NULL; + gboolean success; + + success = cut_logger_set_target_level_by_string(cut_logger(), + value, + &log_level_error); + if (!success) { + g_set_error(error, + G_OPTION_ERROR, + G_OPTION_ERROR_BAD_VALUE, + "%s: %s", + option_name, + log_level_error->message); + g_error_free(log_level_error); + } + + return success; +} + +static gboolean parse_mode (const gchar *option_name, const gchar *value, gpointer data, GError **error) { @@ -148,6 +174,11 @@ static const GOptionEntry option_entries[] = { {"version", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, print_version, N_("Show version"), NULL}, + {"log-level", 0, 0, G_OPTION_ARG_CALLBACK, parse_log_level, + N_("Set log level to LEVEL. LEVEL can be combined them with '|': " + "(all|default|none|critical|error|warning|info|debug|trace) " + "(default: critical|error|warning)"), + "LEVEL"}, {"mode", 0, 0, G_OPTION_ARG_CALLBACK, parse_mode, N_("Set run mode (default: test)"), "[test|analyze|play]"}, {"source-directory", 's', 0, G_OPTION_ARG_STRING, &source_directory, Modified: doc/cutter.rd (+26 -0) =================================================================== --- doc/cutter.rd 2013-11-17 21:57:29 +0900 (5cfa1a7) +++ doc/cutter.rd 2013-11-17 23:26:06 +0900 (c1185f0) @@ -35,6 +35,32 @@ option is specified. Cutter shows its own version and exits. +: --log-level=LEVEL + + It sets log level to LEVEL. + + LEVEL can be combined them with '|' like "error|warning". + + You can add a level to the default level by prepending "+" to level + like "+trace|+info". + + You can remove a level from the default level by prepending "-" to level + like "-error|-warning". + + Here are available levels: + + * default: equals to "critical|error|warning". + * none: logs nothing. + * critical: logs only critial information. + * error: logs only error information. + * warning: logs only warning information. + * info: logs only additional information. + * debug: logs only debug information. + * traces: logs only trace information. + * all: logs all log information. + + The default is "default". + : --mode=[test|analyze] It specifies run mode. Cutter runs tests when run mode is Modified: doc/cutter.rd.ja (+26 -0) =================================================================== --- doc/cutter.rd.ja 2013-11-17 21:57:29 +0900 (e0810cc) +++ doc/cutter.rd.ja 2013-11-17 23:26:06 +0900 (001294b) @@ -36,6 +36,32 @@ Cutterはプログラマが新しいテストを書くこと、すでにある バージョンを表示して終了します。 +: --log-level=LEVEL + + ログレベルをLEVELに設定します。 + + LEVELは「error|warning」というように「|」で区切って指定できます。 + + 「+trace|+info」というようにレベルの前に「+」をつけるとデフォルトのレベルに + 指定したレベルを追加できます。 + + 「-error|-warning」というようにレベルの前に「-」をつけるとデフォルト + のレベルから指定したレベルを取り除けます。 + + 指定できるレベルは以下の通りです。 + + * default: 「critical|error|warning」と同じ。 + * none: なにも出力しない。 + * critical: 致命的な問題のみ出力。 + * error: エラーのみ出力。 + * warning: 警告のみ出力。 + * info: 付加情報のみ出力。 + * debug: デバッグ情報のみ出力。 + * traces: トレース情報のみ出力。 + * all: すべての情報を出力。 + + デフォルトは「default」です。 + : --mode=[test|analyze] 実行モードを指定します。testモードのときはテストを実行し Modified: test/cutter/test-cutter.c (+9 -1) =================================================================== --- test/cutter/test-cutter.c 2013-11-17 21:57:29 +0900 (d62206f) +++ test/cutter/test-cutter.c 2013-11-17 23:26:06 +0900 (99fbbdb) @@ -1,6 +1,6 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* - * Copyright (C) 2008-2010 Kouhei Sutou <ko...@cl...> + * Copyright (C) 2008-2013 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 @@ -103,6 +103,10 @@ cut_setup (void) "" LINE_FEED_CODE "Application Options:" LINE_FEED_CODE " --version Show version" LINE_FEED_CODE + " --log-level=LEVEL " + "Set log level to LEVEL. LEVEL can be combined them with '|': " + "(all|default|none|critical|error|warning|info|debug|trace) " + "(default: critical|error|warning)" LINE_FEED_CODE " --mode=[test|analyze|play] Set run mode (default: test)" LINE_FEED_CODE " -s, --source-directory=DIRECTORY Set directory of source code" LINE_FEED_CODE " -n, --name=TEST_NAME Specify tests" LINE_FEED_CODE @@ -281,6 +285,10 @@ test_help_all (void) #endif "Application Options:" LINE_FEED_CODE " --version Show version" LINE_FEED_CODE + " --log-level=LEVEL " + "Set log level to LEVEL. LEVEL can be combined them with '|': " + "(all|default|none|critical|error|warning|info|debug|trace) " + "(default: critical|error|warning)" LINE_FEED_CODE " --mode=[test|analyze|play] Set run mode (default: test)" LINE_FEED_CODE " -s, --source-directory=DIRECTORY Set directory of source code" LINE_FEED_CODE " -n, --name=TEST_NAME Specify tests" LINE_FEED_CODE |
|
From: Kouhei S. <nul...@cl...> - 2013-11-17 14:35:33
|
Kouhei Sutou 2013-11-17 23:35:12 +0900 (Sun, 17 Nov 2013) New Revision: 0443b9eaddf2801c1bd3bdce2370c509de77e6e3 https://github.com/clear-code/cutter/commit/0443b9eaddf2801c1bd3bdce2370c509de77e6e3 Message: logger: remove unused log levels Modified files: cutter/cut-logger.c cutter/cut-logger.h test/cutter/test-cut-logger.c Modified: cutter/cut-logger.c (+2 -9) =================================================================== --- cutter/cut-logger.c 2013-11-17 23:26:06 +0900 (99feaf6) +++ cutter/cut-logger.c 2013-11-17 23:35:12 +0900 (7762cae) @@ -1,6 +1,6 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* - * Copyright (C) 2012 Kouhei Sutou <ko...@cl...> + * Copyright (C) 2012-2013 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 @@ -39,8 +39,7 @@ (CUT_LOG_LEVEL_CRITICAL | \ CUT_LOG_LEVEL_ERROR | \ CUT_LOG_LEVEL_WARNING | \ - CUT_LOG_LEVEL_MESSAGE | \ - CUT_LOG_LEVEL_STATISTICS) + CUT_LOG_LEVEL_MESSAGE) #define DEFAULT_ITEM \ (CUT_LOG_ITEM_TIME) @@ -457,12 +456,6 @@ log_message_colorize_console (GString *log, case CUT_LOG_LEVEL_TRACE: color = WHITE_COLOR MAGENTA_BACK_COLOR; break; - case CUT_LOG_LEVEL_STATISTICS: - color = BLUE_COLOR WHITE_BACK_COLOR; - break; - case CUT_LOG_LEVEL_PROFILE: - color = GREEN_COLOR BLACK_BACK_COLOR; - break; default: color = NULL; break; Modified: cutter/cut-logger.h (+3 -15) =================================================================== --- cutter/cut-logger.h 2013-11-17 23:26:06 +0900 (814ee9b) +++ cutter/cut-logger.h 2013-11-17 23:35:12 +0900 (ff772cc) @@ -1,6 +1,6 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* - * Copyright (C) 2012 Kouhei Sutou <ko...@cl...> + * Copyright (C) 2012-2013 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 @@ -51,10 +51,6 @@ do { \ cut_log(CUT_LOG_LEVEL_DEBUG, format, ## __VA_ARGS__) #define cut_log_trace(format, ...) \ cut_log(CUT_LOG_LEVEL_TRACE, format, ## __VA_ARGS__) -#define cut_log_statistics(format, ...) \ - cut_log(CUT_LOG_LEVEL_STATISTICS, format, ## __VA_ARGS__) -#define cut_log_profile(format, ...) \ - cut_log(CUT_LOG_LEVEL_PROFILE, format, ## __VA_ARGS__) #define cut_set_log_level(level) \ cut_logger_set_target_level(cut_logger(), (level)) @@ -79,10 +75,6 @@ do { \ (cut_need_log(CUT_LOG_LEVEL_DEBUG)) #define cut_need_trace_log() \ (cut_need_log(CUT_LOG_LEVEL_TRACE)) -#define cut_need_statistics_log() \ - (cut_need_log(CUT_LOG_LEVEL_STATISTICS)) -#define cut_need_profile_log() \ - (cut_need_log(CUT_LOG_LEVEL_PROFILE)) #define CUT_TYPE_LOGGER (cut_logger_get_type()) #define CUT_LOGGER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), CUT_TYPE_LOGGER, CutLogger)) @@ -101,9 +93,7 @@ typedef enum CUT_LOG_LEVEL_MESSAGE = 1 << 4, CUT_LOG_LEVEL_INFO = 1 << 5, CUT_LOG_LEVEL_DEBUG = 1 << 6, - CUT_LOG_LEVEL_TRACE = 1 << 7, - CUT_LOG_LEVEL_STATISTICS = 1 << 8, - CUT_LOG_LEVEL_PROFILE = 1 << 9 + CUT_LOG_LEVEL_TRACE = 1 << 7 } CutLogLevelFlags; #define CUT_LOG_LEVEL_ALL (CUT_LOG_LEVEL_CRITICAL | \ @@ -112,9 +102,7 @@ typedef enum CUT_LOG_LEVEL_MESSAGE | \ CUT_LOG_LEVEL_INFO | \ CUT_LOG_LEVEL_DEBUG | \ - CUT_LOG_LEVEL_TRACE | \ - CUT_LOG_LEVEL_STATISTICS | \ - CUT_LOG_LEVEL_PROFILE) + CUT_LOG_LEVEL_TRACE) #define CUT_LOG_NULL_SAFE_STRING(string) ((string) ? (string) : "(null)") Modified: test/cutter/test-cut-logger.c (+7 -11) =================================================================== --- test/cutter/test-cut-logger.c 2013-11-17 23:26:06 +0900 (b5dc34a) +++ test/cutter/test-cut-logger.c 2013-11-17 23:35:12 +0900 (4f8ebef) @@ -1,6 +1,6 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* - * Copyright (C) 2012 Kouhei Sutou <ko...@cl...> + * Copyright (C) 2012-2013 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 @@ -128,13 +128,11 @@ data_level_from_string (void) CUT_LOG_LEVEL_WARNING | CUT_LOG_LEVEL_MESSAGE | CUT_LOG_LEVEL_INFO | - CUT_LOG_LEVEL_DEBUG | - CUT_LOG_LEVEL_STATISTICS, + CUT_LOG_LEVEL_DEBUG, "+info|debug"); ADD("remove", CUT_LOG_LEVEL_CRITICAL | - CUT_LOG_LEVEL_MESSAGE | - CUT_LOG_LEVEL_STATISTICS, + CUT_LOG_LEVEL_MESSAGE, "-error|warning"); #undef ADD @@ -291,15 +289,13 @@ test_interesting_level (void) CUT_LOG_LEVEL_MESSAGE | CUT_LOG_LEVEL_WARNING | CUT_LOG_LEVEL_ERROR | - CUT_LOG_LEVEL_CRITICAL | - CUT_LOG_LEVEL_STATISTICS, + CUT_LOG_LEVEL_CRITICAL, cut_logger_get_interesting_level(logger)); cut_logger_set_target_level(logger, - CUT_LOG_LEVEL_INFO | - CUT_LOG_LEVEL_STATISTICS); + CUT_LOG_LEVEL_INFO | CUT_LOG_LEVEL_TRACE); gcut_assert_equal_flags(CUT_TYPE_LOG_LEVEL_FLAGS, - CUT_LOG_LEVEL_INFO | CUT_LOG_LEVEL_STATISTICS, + CUT_LOG_LEVEL_INFO | CUT_LOG_LEVEL_TRACE, cut_logger_get_interesting_level(logger)); cut_logger_set_interesting_level(logger, @@ -308,7 +304,7 @@ test_interesting_level (void) gcut_assert_equal_flags(CUT_TYPE_LOG_LEVEL_FLAGS, CUT_LOG_LEVEL_INFO | CUT_LOG_LEVEL_DEBUG | - CUT_LOG_LEVEL_STATISTICS, + CUT_LOG_LEVEL_TRACE, cut_logger_get_interesting_level(logger)); } |
|
From: Kouhei S. <nul...@cl...> - 2013-11-17 12:57:49
|
Kouhei Sutou 2013-11-17 21:57:29 +0900 (Sun, 17 Nov 2013) New Revision: 06082c2cf98396c218e879bab50b036bcf7e6c27 https://github.com/clear-code/cutter/commit/06082c2cf98396c218e879bab50b036bcf7e6c27 Message: loader pe: add trace logs We need to add trace logs to Mach-O loader but we don't have OS X environment for now. :< Modified files: cutter/cut-pe-loader.c Modified: cutter/cut-pe-loader.c (+19 -2) =================================================================== --- cutter/cut-pe-loader.c 2013-11-17 21:56:23 +0900 (a578154) +++ cutter/cut-pe-loader.c 2013-11-17 21:57:29 +0900 (bd52655) @@ -1,6 +1,6 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* - * Copyright (C) 2009 Kouhei Sutou <ko...@cl...> + * Copyright (C) 2009-2013 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 <glib/gstdio.h> #include "cut-pe-loader.h" +#include "cut-logger.h" #define CUT_PE_LOADER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), CUT_TYPE_PE_LOADER, CutPELoaderPrivate)) @@ -171,6 +172,7 @@ cut_pe_loader_is_dll (CutPELoader *loader) IMAGE_DOS_HEADER *dos_header; priv = CUT_PE_LOADER_GET_PRIVATE(loader); + cut_log_trace("[loader][pe][open] <%s>", priv->so_filename); if (!g_file_get_contents(priv->so_filename, &priv->content, &priv->length, &error)) { g_warning("can't read shared library file: %s", error->message); @@ -187,9 +189,13 @@ cut_pe_loader_is_dll (CutPELoader *loader) priv->nt_headers = (IMAGE_NT_HEADERS *)(priv->content + dos_header->e_lfanew); + cut_log_trace("[loader][pe][header][signature] <%#lx>", + priv->nt_headers->Signature); if (priv->nt_headers->Signature != IMAGE_NT_SIGNATURE) return FALSE; + cut_log_trace("[loader][pe][header][characteristics] <%#x>", + priv->nt_headers->FileHeader.Characteristics); return priv->nt_headers->FileHeader.Characteristics & IMAGE_FILE_DLL; #else return FALSE; @@ -225,10 +231,14 @@ cut_pe_loader_collect_symbols (CutPELoader *loader) priv = CUT_PE_LOADER_GET_PRIVATE(loader); first_section = IMAGE_FIRST_SECTION(priv->nt_headers); + cut_log_trace("[loader][pe][collect-symbols][n-sections] <%d>", + priv->nt_headers->FileHeader.NumberOfSections); for (i = 0; i < priv->nt_headers->FileHeader.NumberOfSections; i++) { const gchar *section_name; section_name = (const gchar *)((first_section + i)->Name); + cut_log_trace("[loader][pe][collect-symbols][section] <%s>", + section_name); if (g_str_equal(".text", section_name)) { text_section = first_section + i; } else if (g_str_equal(".edata", section_name)) { @@ -276,15 +286,22 @@ cut_pe_loader_collect_symbols (CutPELoader *loader) min_text_section_address = text_section->VirtualAddress; max_text_section_address = min_text_section_address + text_section->SizeOfRawData; + cut_log_trace("[loader][pe][collect-symbols][n-symbols] <%ld>", + export_directory->NumberOfNames); for (i = 0; i < export_directory->NumberOfNames; i++) { const gchar *name; DWORD function_address; name = base_address + name_addresses[i]; function_address = function_addresses[i]; + cut_log_trace("[loader][pe][collect-symbols][symbol] <%s>:<%#lx>", + name, function_address); if (min_text_section_address < function_address && - function_address < max_text_section_address) + function_address < max_text_section_address) { + cut_log_trace("[loader][pe][collect-symbols][symbol][collect] <%s>", + name); symbols = g_list_prepend(symbols, g_strdup(name)); + } } return symbols; |
|
From: Kouhei S. <nul...@cl...> - 2013-11-17 12:56:42
|
Kouhei Sutou 2013-11-17 21:56:23 +0900 (Sun, 17 Nov 2013) New Revision: 47fdbf65ab42b0c18069d4e8bf7ff6b65a2d7c8c https://github.com/clear-code/cutter/commit/47fdbf65ab42b0c18069d4e8bf7ff6b65a2d7c8c Message: loader pe: fix indent Modified files: cutter/cut-pe-loader.c Modified: cutter/cut-pe-loader.c (+1 -1) =================================================================== --- cutter/cut-pe-loader.c 2013-11-17 19:21:49 +0900 (cb06b7a) +++ cutter/cut-pe-loader.c 2013-11-17 21:56:23 +0900 (a578154) @@ -246,7 +246,7 @@ cut_pe_loader_collect_symbols (CutPELoader *loader) if (edata_section) { export_directory = (IMAGE_EXPORT_DIRECTORY *)(priv->content + - edata_section->PointerToRawData); + edata_section->PointerToRawData); base_address = priv->content + edata_section->PointerToRawData - |
|
From: Kouhei S. <nul...@cl...> - 2013-11-17 10:22:06
|
Kouhei Sutou 2013-11-17 19:21:49 +0900 (Sun, 17 Nov 2013) New Revision: 946c785ef08041c7d53404ca5000ba11e4b80ed1 https://github.com/clear-code/cutter/commit/946c785ef08041c7d53404ca5000ba11e4b80ed1 Message: Remove a garbage space Modified files: cutter/Makefile.am Modified: cutter/Makefile.am (+1 -1) =================================================================== --- cutter/Makefile.am 2013-11-17 19:06:01 +0900 (92a58d6) +++ cutter/Makefile.am 2013-11-17 19:21:49 +0900 (5e29785) @@ -244,7 +244,7 @@ stamp-$(enum_source_prefix)-h: $(enum_sources_h) Makefile $(GLIB_MKENUMS) \ --fhead "#ifndef $${mark}\n#define $${mark}\n\n#include <glib-object.h>\n\nG_BEGIN_DECLS\n" \ --fprod "/* enumerations from \"@filename@\" */\n" \ - --vhead "GType @enum_name@_get_type (void);\n#define CUT_TYPE_@ENUMSHORT@ (@enum_name@_get_type())\n" \ + --vhead "GType @enum_name@_get_type (void);\n#define CUT_TYPE_@ENUMSHORT@ (@enum_name@_get_type())\n" \ --ftail "G_END_DECLS\n\n#endif /* $${mark} */" \ $(enum_sources_h)) > tmp-$(enum_source_prefix).h && \ (cmp -s tmp-$(enum_source_prefix).h $(enum_source_prefix).h || \ |
|
From: Kouhei S. <nul...@cl...> - 2013-11-17 10:06:22
|
Kouhei Sutou 2013-11-17 19:06:01 +0900 (Sun, 17 Nov 2013) New Revision: bcb8ea232daccc3ce79326fce4f2de71ac717036 https://github.com/clear-code/cutter/commit/bcb8ea232daccc3ce79326fce4f2de71ac717036 Message: doc cygwin: use "you" as person instead of "we" Modified files: doc/install-to-cygwin.rd Modified: doc/install-to-cygwin.rd (+6 -6) =================================================================== --- doc/install-to-cygwin.rd 2013-11-17 19:04:12 +0900 (c78a350) +++ doc/install-to-cygwin.rd 2013-11-17 19:06:01 +0900 (52a8316) @@ -6,16 +6,16 @@ This document explains how to install Cutter to Cygwin. -We can install Cutter to Cygwin 1.7. +You can install Cutter to Cygwin 1.7. == Install Cygwin -First, we download Cygwin 1.7 installer: +First, download Cygwin 1.7 installer: * ((<Installer for 32-bit environment|URL:http://cygwin.com/setup-x86.exe>)) * ((<Installer for 64-bit environment|URL:http://cygwin.com/setup-x86_64.exe>)) -Next, we install the following packages with the downloaded +Next, install the following packages with the downloaded installer: * gcc4 @@ -29,11 +29,11 @@ installer: * pkg-config * wget -We enter into Cygwin. We run Cygwin. +Enter into Cygwin. Now, you can run Cygwin. == Install Cutter -We install Cutter. +Install Cutter: % cd % wget http://downloads.sourceforge.net/cutter/cutter-1.2.2.tar.gz @@ -45,5 +45,5 @@ We install Cutter. == The next step -Installation is completed. We should try +Installation is completed. You should try ((<tutorial|TUTORIAL>)) with the installed Cutter. |
|
From: Kouhei S. <nul...@cl...> - 2013-11-17 10:04:29
|
Kouhei Sutou 2013-11-17 19:04:12 +0900 (Sun, 17 Nov 2013) New Revision: 22bfa48cc7fb1eabc43fe95a62d8fef46aa5c6d9 https://github.com/clear-code/cutter/commit/22bfa48cc7fb1eabc43fe95a62d8fef46aa5c6d9 Message: doc cygwin: remove needless note It will be solved. Modified files: doc/install-to-cygwin.rd Modified: doc/install-to-cygwin.rd (+1 -2) =================================================================== --- doc/install-to-cygwin.rd 2013-11-17 19:02:40 +0900 (899c610) +++ doc/install-to-cygwin.rd 2013-11-17 19:04:12 +0900 (c78a350) @@ -6,8 +6,7 @@ This document explains how to install Cutter to Cygwin. -We can install Cutter to Cygwin 1.7 (should be confirmed: -but we need to apply a patch to GLib). +We can install Cutter to Cygwin 1.7. == Install Cygwin |