From 435bd3b5e91e4e556624ac8b402b551e72ed376d Mon Sep 17 00:00:00 2001 From: Allan LeSage Date: Thu, 8 Mar 2012 15:50:50 -0600 Subject: Moved coverage tooling to own Makefile; gcovr now optional. --- Makefile.am | 35 +---------------------------------- m4/gcov.m4 | 23 +++++++++++++---------- 2 files changed, 14 insertions(+), 44 deletions(-) diff --git a/Makefile.am b/Makefile.am index e31937a..6d4e4ee 100644 --- a/Makefile.am +++ b/Makefile.am @@ -33,37 +33,4 @@ dist-hook: fi -# Coverage targets - -.PHONY: clean-gcda -clean-gcda: - @echo Removing old coverage results - -find -name '*.gcda' -print | xargs -r rm - -.PHONY: coverage-html generate-coverage-html clean-coverage-html -coverage-html: clean-gcda - -$(MAKE) $(AM_MAKEFLAGS) -k check - $(MAKE) $(AM_MAKEFLAGS) generate-coverage-html - -generate-coverage-html: - @echo Collecting coverage data - $(LCOV) --directory $(top_builddir) --capture --output-file coverage.info --no-checksum --compat-libtool - LANG=C $(GENHTML) --prefix $(top_builddir) --output-directory coveragereport --title "Code Coverage" --legend --show-details coverage.info - -clean-coverage-html: clean-gcda - -$(LCOV) --directory $(top_builddir) -z - -rm -rf coverage.info coveragereport - -.PHONY: coverage-xml generate-coverage-xml clean-coverage-xml -coverage-xml: clean-gcda - -$(MAKE) $(AM_MAKEFLAGS) -k check - $(MAKE) $(AM_MAKEFLAGS) generate-coverage-xml - -generate-coverage-xml: - @echo Generating coverage XML report - $(GCOVR) -x -r $(top_builddir) -o $(top_builddir)/coverage.xml - -clean-coverage-xml: clean-gcda - -rm -rf $(top_builddir)/coverage.xml - -clean-local: clean-coverage-html clean-coverage-xml +include $(top_srcdir)/Makefile.am.coverage diff --git a/m4/gcov.m4 b/m4/gcov.m4 index 1169573..3163584 100644 --- a/m4/gcov.m4 +++ b/m4/gcov.m4 @@ -5,11 +5,10 @@ # * gcovr # # Sets ac_cv_check_gcov to yes if tooling is present -# and reports the executables to the variables LCOV, GCOVR and GENHTML. +# and reports the executables to the variables LCOV, GCOVR and GENHTML. AC_DEFUN([AC_TDD_GCOV], -[AC_CACHE_CHECK([whether code coverage tools are available], ac_cv_check_gcov, [ -AC_ARG_ENABLE(gcov, + AC_ARG_ENABLE(gcov, AS_HELP_STRING([--enable-gcov], [enable coverage testing with gcov]), [use_gcov=$enableval], [use_gcov=no]) @@ -34,7 +33,6 @@ AC_ARG_ENABLE(gcov, lcov_version_list="1.6 1.7 1.8 1.9" AC_CHECK_PROG(LCOV, lcov, lcov) AC_CHECK_PROG(GENHTML, genhtml, genhtml) - AC_CHECK_PROG(GCOVR, gcovr, gcovr) if test "$LCOV"; then AC_CACHE_CHECK([for lcov version], glib_cv_lcov_version, [ @@ -63,10 +61,8 @@ AC_ARG_ENABLE(gcov, AC_MSG_ERROR([Could not find genhtml from the lcov package]) fi - if test -z "$GCOVR"; then - AC_MSG_ERROR([Could not find gcovr; easy_install (or pip) gcovr]) - fi - + ac_cv_check_gcov=yes + ac_cv_check_lcov=yes # Remove all optimization flags from CFLAGS changequote({,}) @@ -78,6 +74,13 @@ AC_ARG_ENABLE(gcov, COVERAGE_CXXFLAGS="-O0 -fprofile-arcs -ftest-coverage" COVERAGE_LDFLAGS="-lgcov" -fi -])]) # AC_TDD_GCOV + # Check availability of gcovr + AC_CHECK_PROG(GCOVR, gcovr, gcovr) + if test -z "$GCOVR"; then + ac_cv_check_gcovr=no + else + ac_cv_check_gcovr=yes + fi +fi +]) # AC_TDD_GCOV -- cgit v1.2.3 From a2fc906f1618df091d92dcf060b2622f7881d249 Mon Sep 17 00:00:00 2001 From: Allan LeSage Date: Tue, 13 Mar 2012 20:32:26 -0500 Subject: Made gcovr optional. --- Makefile.am | 36 +----------------------------------- Makefile.am.coverage | 41 +++++++++++++++++++++++++++++++++++++++++ configure.ac | 3 +++ m4/gcov.m4 | 23 +++++++++++++---------- 4 files changed, 58 insertions(+), 45 deletions(-) create mode 100644 Makefile.am.coverage diff --git a/Makefile.am b/Makefile.am index e31937a..45c511a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -32,38 +32,4 @@ dist-hook: echo Failed to generate AUTHORS: not a branch >&2; \ fi - -# Coverage targets - -.PHONY: clean-gcda -clean-gcda: - @echo Removing old coverage results - -find -name '*.gcda' -print | xargs -r rm - -.PHONY: coverage-html generate-coverage-html clean-coverage-html -coverage-html: clean-gcda - -$(MAKE) $(AM_MAKEFLAGS) -k check - $(MAKE) $(AM_MAKEFLAGS) generate-coverage-html - -generate-coverage-html: - @echo Collecting coverage data - $(LCOV) --directory $(top_builddir) --capture --output-file coverage.info --no-checksum --compat-libtool - LANG=C $(GENHTML) --prefix $(top_builddir) --output-directory coveragereport --title "Code Coverage" --legend --show-details coverage.info - -clean-coverage-html: clean-gcda - -$(LCOV) --directory $(top_builddir) -z - -rm -rf coverage.info coveragereport - -.PHONY: coverage-xml generate-coverage-xml clean-coverage-xml -coverage-xml: clean-gcda - -$(MAKE) $(AM_MAKEFLAGS) -k check - $(MAKE) $(AM_MAKEFLAGS) generate-coverage-xml - -generate-coverage-xml: - @echo Generating coverage XML report - $(GCOVR) -x -r $(top_builddir) -o $(top_builddir)/coverage.xml - -clean-coverage-xml: clean-gcda - -rm -rf $(top_builddir)/coverage.xml - -clean-local: clean-coverage-html clean-coverage-xml +include $(top_srcdir)/Makefile.am.coverage diff --git a/Makefile.am.coverage b/Makefile.am.coverage new file mode 100644 index 0000000..b0a2f8c --- /dev/null +++ b/Makefile.am.coverage @@ -0,0 +1,41 @@ + +# Coverage targets + +if HAVE_GCOV + + .PHONY: clean-gcda + clean-gcda: + @echo Removing old coverage results + -find -name '*.gcda' -print | xargs -r rm + + .PHONY: coverage-html generate-coverage-html clean-coverage-html + coverage-html: clean-gcda + -$(MAKE) $(AM_MAKEFLAGS) -k check + $(MAKE) $(AM_MAKEFLAGS) generate-coverage-html + + generate-coverage-html: + @echo Collecting coverage data + $(LCOV) --directory $(top_builddir) --capture --output-file coverage.info --no-checksum --compat-libtool + LANG=C $(GENHTML) --prefix $(top_builddir) --output-directory coveragereport --title "Code Coverage" --legend --show-details coverage.info + + clean-coverage-html: clean-gcda + -$(LCOV) --directory $(top_builddir) -z + -rm -rf coverage.info coveragereport + +if HAVE_GCOVR + + .PHONY: coverage-gcovr generate-coverage-gcovr clean-coverage-gcovr + coverage-gcovr: clean-gcda + -$(MAKE) $(AM_MAKEFLAGS) -k check + $(MAKE) $(AM_MAKEFLAGS) generate-coverage-gcovr + + generate-coverage-gcovr: + @echo Generating coverage GCOVR report + $(GCOVR) -x -r $(top_builddir) -o $(top_builddir)/coverage.gcovr + + clean-coverage-gcovr: clean-gcda + -rm -rf $(top_builddir)/coverage.gcovr + +endif # HAVE_GCOVR + +endif # HAVE_GCOV diff --git a/configure.ac b/configure.ac index 28f9091..159c740 100644 --- a/configure.ac +++ b/configure.ac @@ -96,6 +96,9 @@ AC_SUBST(STATUS_PROVIDER_EMESENE_LIBS) m4_include([m4/gcov.m4]) AC_TDD_GCOV +AM_CONDITIONAL([HAVE_GCOV], [test "x$ac_cv_check_gcov" = xyes]) +AM_CONDITIONAL([HAVE_LCOV], [test "x$ac_cv_check_lcov" = xyes]) +AM_CONDITIONAL([HAVE_GCOVR], [test "x$ac_cv_check_gcovr" = xyes]) AC_SUBST(COVERAGE_CFLAGS) AC_SUBST(COVERAGE_CXXFLAGS) AC_SUBST(COVERAGE_LDFLAGS) diff --git a/m4/gcov.m4 b/m4/gcov.m4 index 1169573..3163584 100644 --- a/m4/gcov.m4 +++ b/m4/gcov.m4 @@ -5,11 +5,10 @@ # * gcovr # # Sets ac_cv_check_gcov to yes if tooling is present -# and reports the executables to the variables LCOV, GCOVR and GENHTML. +# and reports the executables to the variables LCOV, GCOVR and GENHTML. AC_DEFUN([AC_TDD_GCOV], -[AC_CACHE_CHECK([whether code coverage tools are available], ac_cv_check_gcov, [ -AC_ARG_ENABLE(gcov, + AC_ARG_ENABLE(gcov, AS_HELP_STRING([--enable-gcov], [enable coverage testing with gcov]), [use_gcov=$enableval], [use_gcov=no]) @@ -34,7 +33,6 @@ AC_ARG_ENABLE(gcov, lcov_version_list="1.6 1.7 1.8 1.9" AC_CHECK_PROG(LCOV, lcov, lcov) AC_CHECK_PROG(GENHTML, genhtml, genhtml) - AC_CHECK_PROG(GCOVR, gcovr, gcovr) if test "$LCOV"; then AC_CACHE_CHECK([for lcov version], glib_cv_lcov_version, [ @@ -63,10 +61,8 @@ AC_ARG_ENABLE(gcov, AC_MSG_ERROR([Could not find genhtml from the lcov package]) fi - if test -z "$GCOVR"; then - AC_MSG_ERROR([Could not find gcovr; easy_install (or pip) gcovr]) - fi - + ac_cv_check_gcov=yes + ac_cv_check_lcov=yes # Remove all optimization flags from CFLAGS changequote({,}) @@ -78,6 +74,13 @@ AC_ARG_ENABLE(gcov, COVERAGE_CXXFLAGS="-O0 -fprofile-arcs -ftest-coverage" COVERAGE_LDFLAGS="-lgcov" -fi -])]) # AC_TDD_GCOV + # Check availability of gcovr + AC_CHECK_PROG(GCOVR, gcovr, gcovr) + if test -z "$GCOVR"; then + ac_cv_check_gcovr=no + else + ac_cv_check_gcovr=yes + fi +fi +]) # AC_TDD_GCOV -- cgit v1.2.3 From b11161a7ffab99f5415e4136ce9ddd0bf6e1fa76 Mon Sep 17 00:00:00 2001 From: Allan LeSage Date: Thu, 15 Mar 2012 11:30:13 -0500 Subject: Dummy commit on 'no rule' err. --- Makefile.am | 4 ++++ configure.ac | 20 +++++++++++++++++ m4/gtest.m4 | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++ test/Makefile.am | 24 ++++++++++++++++++++ test/test-gtest.cpp | 13 +++++++++++ 5 files changed, 124 insertions(+) create mode 100644 m4/gtest.m4 create mode 100644 test/Makefile.am create mode 100644 test/test-gtest.cpp diff --git a/Makefile.am b/Makefile.am index 45c511a..1e8aa57 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,6 +4,10 @@ SUBDIRS = \ data \ po +if BUILD_TESTS +SUBDIRS += test +endif + DISTCHECK_CONFIGURE_FLAGS = --enable-localinstall --enable-deprecations dist-hook: diff --git a/configure.ac b/configure.ac index 159c740..a85773d 100644 --- a/configure.ac +++ b/configure.ac @@ -31,6 +31,9 @@ AS_IF([test "x$enable_deprecations" = xno], [CFLAGS="$CFLAGS -DG_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED -DGDK_PIXBUF_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED -DGSEAL_ENABLE -DGTK_DISABLE_SINGLE_INCLUDES"] ) +# the Google Test targets are cpp +AC_PROG_CXX + ########################### # Dependencies ########################### @@ -68,6 +71,15 @@ AS_IF([test "x$with_gtk" = x3], AC_SUBST(APPLET_CFLAGS) AC_SUBST(APPLET_LIBS) +########################### +# Test Dependencies +########################### + +AC_ARG_ENABLE([tests], + AC_HELP_STRING([--disable-tests], [Disable test scripts and tools]),, + [enable_tests=auto]) +AM_CONDITIONAL(BUILD_TESTS, test xyes = xyes) + ########################### # Status Provider Deps ########################### @@ -103,6 +115,13 @@ AC_SUBST(COVERAGE_CFLAGS) AC_SUBST(COVERAGE_CXXFLAGS) AC_SUBST(COVERAGE_LDFLAGS) +########################### +# Google Test framework +########################### + +m4_include([m4/gtest.m4]) +CHECK_GTEST + ########################### # Check to see if we're local ########################### @@ -192,6 +211,7 @@ data/icons/scalable/Makefile data/icons/scalable/status/Makefile data/icons/scalable/categories/Makefile po/Makefile.in +test/Makefile ]) ########################### diff --git a/m4/gtest.m4 b/m4/gtest.m4 new file mode 100644 index 0000000..2de334c --- /dev/null +++ b/m4/gtest.m4 @@ -0,0 +1,63 @@ +# Copyright (C) 2012 Canonical, Ltd. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice (including the next +# paragraph) shall be included in all copies or substantial portions of the +# Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +# Checks whether the gtest source is available on the system. Allows for +# adjusting the include and source path. Sets have_gtest=yes if the source is +# present. Sets GTEST_CPPFLAGS and GTEST_SOURCE to the preprocessor flags and +# source location respectively. +AC_DEFUN([CHECK_GTEST], +[ + AC_ARG_WITH([gtest-include-path], + [AS_HELP_STRING([--with-gtest-include-path], + [location of the Google test headers])], + [GTEST_CPPFLAGS="-I$withval"]) + + AC_ARG_WITH([gtest-source-path], + [AS_HELP_STRING([--with-gtest-source-path], + [location of the Google test sources, defaults to /usr/src/gtest])], + [GTEST_SOURCE="$withval"], + [GTEST_SOURCE="/usr/src/gtest"]) + + GTEST_CPPFLAGS="$GTEST_CPPFLAGS -I$GTEST_SOURCE" + + AC_LANG_PUSH([C++]) + + tmp_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $GTEST_CPPFLAGS" + + AC_CHECK_HEADER([gtest/gtest.h]) + + CPPFLAGS="$tmp_CPPFLAGS" + + AC_LANG_POP + + AC_CHECK_FILES([$GTEST_SOURCE/src/gtest-all.cc] + [$GTEST_SOURCE/src/gtest_main.cc], + [have_gtest_source=yes], + [have_gtest_source=no]) + + AS_IF([test "x$ac_cv_header_gtest_gtest_h" = xyes -a \ + "x$have_gtest_source" = xyes], + [have_gtest=yes] + [AC_SUBST(GTEST_CPPFLAGS)] + [AC_SUBST(GTEST_SOURCE)], + [have_gtest=no]) +]) # CHECK_GTEST diff --git a/test/Makefile.am b/test/Makefile.am new file mode 100644 index 0000000..fa7bace --- /dev/null +++ b/test/Makefile.am @@ -0,0 +1,24 @@ + +check_LIBRARIES = libgtest.a + +AM_CPPFLAGS = $(GTEST_CPPFLAGS) + +nodist_libgtest_a_SOURCES = $(GTEST_SOURCE)/src/gtest-all.cc +libgtest_a_CPPFLAGS = $(GTEST_CPPFLAGS) -w +libgtest_a_CXXFLAGS = $(AM_CXXFLAGS) + +libgtest_a_SOURCES = \ + $(GTEST_SOURCE)/src/gtest-all.cc \ + $(GTEST_SOURCE)/src/gtest-main.cc +lib_gtest_a_CPPFLAGS = \ + $(GTEST_CPPFLAGS) \ + -I$(top_srcdir)/include \ + -I$(top_srcdir) +libxorg_gtest_a_CXXFLAGS = $(GTEST_CXXFLAGS) $(AM_CXXFLAGS) + +check_PROGRAMS = test_gtest + +test_gtest_SOURCES = test-gtest.cpp + +test_gtest_LDADD = \ + libgtest.a diff --git a/test/test-gtest.cpp b/test/test-gtest.cpp new file mode 100644 index 0000000..739a5c8 --- /dev/null +++ b/test/test-gtest.cpp @@ -0,0 +1,13 @@ + +#include +#include + + + + +int +main (int argc, char ** argv) +{ + printf("oheck\n"); + return 0; +} -- cgit v1.2.3 From bacad6ee225001ec39b6263ceb4aa99d55a67ba6 Mon Sep 17 00:00:00 2001 From: Allan LeSage Date: Thu, 15 Mar 2012 18:22:37 -0500 Subject: Temp commit for review by charles. --- configure.ac | 8 ++++++-- test/Makefile.am | 28 ++++++++++++++++------------ test/test-gtest.cpp | 21 ++++++++++++--------- 3 files changed, 34 insertions(+), 23 deletions(-) diff --git a/configure.ac b/configure.ac index a85773d..8646a0f 100644 --- a/configure.ac +++ b/configure.ac @@ -45,6 +45,7 @@ PANEL_REQUIRED_VERSION=2.0.0 INDICATE_REQUIRED_VERSION=0.6.90 INDICATOR_REQUIRED_VERSION=0.3.19 DBUSMENUGTK_REQUIRED_VERSION=0.5.90 +GLIB_REQUIRED_VERSION=2.31.20 AC_ARG_WITH([gtk], [AS_HELP_STRING([--with-gtk], @@ -57,14 +58,17 @@ AS_IF([test "x$with_gtk" = x3], gio-unix-2.0 >= $GIO_UNIX_REQUIRED_VERSION indicator3-0.4 >= $INDICATOR_REQUIRED_VERSION indicate-0.7 >= $INDICATE_REQUIRED_VERSION - dbusmenu-gtk3-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION) + dbusmenu-gtk3-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION + glib-2.0 >= GLIB_REQUIRED_VERSION) + ], [test "x$with_gtk" = x2], [PKG_CHECK_MODULES(APPLET, gtk+-2.0 >= $GTK_REQUIRED_VERSION gio-unix-2.0 >= $GIO_UNIX_REQUIRED_VERSION indicator-0.4 >= $INDICATOR_REQUIRED_VERSION indicate-0.7 >= $INDICATE_REQUIRED_VERSION - dbusmenu-gtk-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION) + dbusmenu-gtk-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION + glib-2.0 >= GLIB_REQUIRED_VERSION) ], [AC_MSG_FAILURE([Value for --with-indicator-gtk was neither 2 nor 3])] ) diff --git a/test/Makefile.am b/test/Makefile.am index fa7bace..7b59f54 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,24 +1,28 @@ check_LIBRARIES = libgtest.a +check_PROGRAMS = test-gtest + +TESTS = AM_CPPFLAGS = $(GTEST_CPPFLAGS) nodist_libgtest_a_SOURCES = $(GTEST_SOURCE)/src/gtest-all.cc -libgtest_a_CPPFLAGS = $(GTEST_CPPFLAGS) -w -libgtest_a_CXXFLAGS = $(AM_CXXFLAGS) - libgtest_a_SOURCES = \ $(GTEST_SOURCE)/src/gtest-all.cc \ - $(GTEST_SOURCE)/src/gtest-main.cc -lib_gtest_a_CPPFLAGS = \ - $(GTEST_CPPFLAGS) \ - -I$(top_srcdir)/include \ - -I$(top_srcdir) -libxorg_gtest_a_CXXFLAGS = $(GTEST_CXXFLAGS) $(AM_CXXFLAGS) - -check_PROGRAMS = test_gtest + $(GTEST_SOURCE)/src/gtest_main.cc +libgtest_a_CPPFLAGS = \ + $(GTEST_CPPFLAGS) -w +libgtest_a_CXXFLAGS = \ + $(AM_CXXFLAGS) -test_gtest_SOURCES = test-gtest.cpp +TESTS += test-gtest +test_gtest_SOURCES = \ + test-gtest.cpp +test_gtest_CPPFLAGS = \ + $(APPLET_CFLAGS) \ + -I$(top_srcdir)/src +test_gtest_LDFLAGS = -pthread test_gtest_LDADD = \ + $(APPLET_LIBS) \ libgtest.a diff --git a/test/test-gtest.cpp b/test/test-gtest.cpp index 739a5c8..87edeab 100644 --- a/test/test-gtest.cpp +++ b/test/test-gtest.cpp @@ -1,13 +1,16 @@ -#include -#include - - +#include +#include +extern "C" { + #include "launcher-menu-item.h" +} -int -main (int argc, char ** argv) -{ - printf("oheck\n"); - return 0; +TEST(LauncherMenuItem, EmptyAtStart) { + gboolean result; + // FIXME + //LauncherMenuItem * test_li = ???; + gboolean test_eclipsed; + //result = launcher_menu_item_set_eclipsed(test_li, test_eclipsed); + EXPECT_TRUE(false); } -- cgit v1.2.3 From a5695b6ae268abc5c446a734ea8dbbcc30bc47fb Mon Sep 17 00:00:00 2001 From: Allan LeSage Date: Fri, 16 Mar 2012 16:11:07 -0500 Subject: Experimental Makefile.am changes to support GTest. --- test/Makefile.am | 6 ++++-- test/test-gtest.cpp | 14 +++++++------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/test/Makefile.am b/test/Makefile.am index 7b59f54..e262bae 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -18,10 +18,12 @@ libgtest_a_CXXFLAGS = \ TESTS += test-gtest test_gtest_SOURCES = \ + $(top_srcdir)/src/launcher-menu-item.c \ + $(top_srcdir)/src/default-applications.c \ + $(top_srcdir)/src/seen-db.c \ test-gtest.cpp test_gtest_CPPFLAGS = \ - $(APPLET_CFLAGS) \ - -I$(top_srcdir)/src + $(APPLET_CFLAGS) test_gtest_LDFLAGS = -pthread test_gtest_LDADD = \ $(APPLET_LIBS) \ diff --git a/test/test-gtest.cpp b/test/test-gtest.cpp index 87edeab..bb9943d 100644 --- a/test/test-gtest.cpp +++ b/test/test-gtest.cpp @@ -6,11 +6,11 @@ extern "C" { #include "launcher-menu-item.h" } -TEST(LauncherMenuItem, EmptyAtStart) { - gboolean result; - // FIXME - //LauncherMenuItem * test_li = ???; - gboolean test_eclipsed; - //result = launcher_menu_item_set_eclipsed(test_li, test_eclipsed); - EXPECT_TRUE(false); +TEST(LauncherMenuItem, NameInitialized) { + g_type_init(); + //const gchar * expected = "foo"; + //LauncherMenuItem * test_li = launcher_menu_item_new ("foo"); + //gchar * result = launcher_menu_item_get_name(test_li); + //EXPECT_EQ(0, strcmp("foo", result)); + EXPECT_TRUE(true); } -- cgit v1.2.3 From 25fcbef28e8b33fc1ee624359ac4b39fbcb741dc Mon Sep 17 00:00:00 2001 From: Allan LeSage Date: Mon, 19 Mar 2012 10:14:53 -0500 Subject: Charles-advised changes to test/Makefile.am for proper CPPFLAGS. --- test/Makefile.am | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/Makefile.am b/test/Makefile.am index e262bae..e359ad4 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -4,7 +4,8 @@ check_PROGRAMS = test-gtest TESTS = -AM_CPPFLAGS = $(GTEST_CPPFLAGS) +AM_CPPFLAGS = $(GTEST_CPPFLAGS) \ + -I${top_srcdir}/src nodist_libgtest_a_SOURCES = $(GTEST_SOURCE)/src/gtest-all.cc libgtest_a_SOURCES = \ @@ -14,6 +15,8 @@ libgtest_a_CPPFLAGS = \ $(GTEST_CPPFLAGS) -w libgtest_a_CXXFLAGS = \ $(AM_CXXFLAGS) +libgtest_a_CPPFLAGS = \ + $(AM_CPPFLAGS) TESTS += test-gtest @@ -23,7 +26,8 @@ test_gtest_SOURCES = \ $(top_srcdir)/src/seen-db.c \ test-gtest.cpp test_gtest_CPPFLAGS = \ - $(APPLET_CFLAGS) + $(APPLET_CFLAGS) \ + $(AM_CPPFLAGS) test_gtest_LDFLAGS = -pthread test_gtest_LDADD = \ $(APPLET_LIBS) \ -- cgit v1.2.3 From 46ff11853c8c1ea7ca02ad8786e9bb222fa7a7cf Mon Sep 17 00:00:00 2001 From: Allan LeSage Date: Mon, 19 Mar 2012 12:35:49 -0500 Subject: Made gcovr optional. --- Makefile.am | 35 +---------------------------------- Makefile.am.coverage | 44 ++++++++++++++++++++++++++++++++++++++++++++ configure.ac | 3 +++ m4/gcov.m4 | 23 +++++++++++++---------- 4 files changed, 61 insertions(+), 44 deletions(-) create mode 100644 Makefile.am.coverage diff --git a/Makefile.am b/Makefile.am index e31937a..6d4e4ee 100644 --- a/Makefile.am +++ b/Makefile.am @@ -33,37 +33,4 @@ dist-hook: fi -# Coverage targets - -.PHONY: clean-gcda -clean-gcda: - @echo Removing old coverage results - -find -name '*.gcda' -print | xargs -r rm - -.PHONY: coverage-html generate-coverage-html clean-coverage-html -coverage-html: clean-gcda - -$(MAKE) $(AM_MAKEFLAGS) -k check - $(MAKE) $(AM_MAKEFLAGS) generate-coverage-html - -generate-coverage-html: - @echo Collecting coverage data - $(LCOV) --directory $(top_builddir) --capture --output-file coverage.info --no-checksum --compat-libtool - LANG=C $(GENHTML) --prefix $(top_builddir) --output-directory coveragereport --title "Code Coverage" --legend --show-details coverage.info - -clean-coverage-html: clean-gcda - -$(LCOV) --directory $(top_builddir) -z - -rm -rf coverage.info coveragereport - -.PHONY: coverage-xml generate-coverage-xml clean-coverage-xml -coverage-xml: clean-gcda - -$(MAKE) $(AM_MAKEFLAGS) -k check - $(MAKE) $(AM_MAKEFLAGS) generate-coverage-xml - -generate-coverage-xml: - @echo Generating coverage XML report - $(GCOVR) -x -r $(top_builddir) -o $(top_builddir)/coverage.xml - -clean-coverage-xml: clean-gcda - -rm -rf $(top_builddir)/coverage.xml - -clean-local: clean-coverage-html clean-coverage-xml +include $(top_srcdir)/Makefile.am.coverage diff --git a/Makefile.am.coverage b/Makefile.am.coverage new file mode 100644 index 0000000..9edc849 --- /dev/null +++ b/Makefile.am.coverage @@ -0,0 +1,44 @@ + +# Coverage targets + +if HAVE_GCOV + +.PHONY: clean-gcda +clean-gcda: + @echo Removing old coverage results + -find -name '*.gcda' -print | xargs -r rm + +.PHONY: coverage-html generate-coverage-html +coverage-html: clean-gcda + -$(MAKE) $(AM_MAKEFLAGS) -k check + $(MAKE) $(AM_MAKEFLAGS) generate-coverage-html + +generate-coverage-html: + @echo Collecting coverage data + $(LCOV) --directory $(top_builddir) --capture --output-file coverage.info --no-checksum --compat-libtool + LANG=C $(GENHTML) --prefix $(top_builddir) --output-directory coveragereport --title "Code Coverage" --legend --show-details coverage.info + +clean-coverage-html: clean-gcda + -$(LCOV) --directory $(top_builddir) -z + -rm -rf coverage.info coveragereport + +if HAVE_GCOVR + +.PHONY: coverage-gcovr generate-coverage-gcovr +coverage-gcovr: clean-gcda + -$(MAKE) $(AM_MAKEFLAGS) -k check + $(MAKE) $(AM_MAKEFLAGS) generate-coverage-gcovr + +generate-coverage-gcovr: + @echo Generating coverage GCOVR report + $(GCOVR) -x -r $(top_builddir) -o $(top_builddir)/coverage.gcovr + +clean-coverage-gcovr: clean-gcda + -rm -rf $(top_builddir)/coverage.gcovr + +endif # HAVE_GCOVR + +endif # HAVE_GCOV + +.PHONY: clean-coverage-html clean-coverage-gcovr +clean-local: clean-coverage-html clean-coverage-gcovr diff --git a/configure.ac b/configure.ac index 179d679..8ba218e 100644 --- a/configure.ac +++ b/configure.ac @@ -96,6 +96,9 @@ AC_SUBST(STATUS_PROVIDER_EMESENE_LIBS) m4_include([m4/gcov.m4]) AC_TDD_GCOV +AM_CONDITIONAL([HAVE_GCOV], [test "x$ac_cv_check_gcov" = xyes]) +AM_CONDITIONAL([HAVE_LCOV], [test "x$ac_cv_check_lcov" = xyes]) +AM_CONDITIONAL([HAVE_GCOVR], [test "x$ac_cv_check_gcovr" = xyes]) AC_SUBST(COVERAGE_CFLAGS) AC_SUBST(COVERAGE_CXXFLAGS) AC_SUBST(COVERAGE_LDFLAGS) diff --git a/m4/gcov.m4 b/m4/gcov.m4 index 1169573..3163584 100644 --- a/m4/gcov.m4 +++ b/m4/gcov.m4 @@ -5,11 +5,10 @@ # * gcovr # # Sets ac_cv_check_gcov to yes if tooling is present -# and reports the executables to the variables LCOV, GCOVR and GENHTML. +# and reports the executables to the variables LCOV, GCOVR and GENHTML. AC_DEFUN([AC_TDD_GCOV], -[AC_CACHE_CHECK([whether code coverage tools are available], ac_cv_check_gcov, [ -AC_ARG_ENABLE(gcov, + AC_ARG_ENABLE(gcov, AS_HELP_STRING([--enable-gcov], [enable coverage testing with gcov]), [use_gcov=$enableval], [use_gcov=no]) @@ -34,7 +33,6 @@ AC_ARG_ENABLE(gcov, lcov_version_list="1.6 1.7 1.8 1.9" AC_CHECK_PROG(LCOV, lcov, lcov) AC_CHECK_PROG(GENHTML, genhtml, genhtml) - AC_CHECK_PROG(GCOVR, gcovr, gcovr) if test "$LCOV"; then AC_CACHE_CHECK([for lcov version], glib_cv_lcov_version, [ @@ -63,10 +61,8 @@ AC_ARG_ENABLE(gcov, AC_MSG_ERROR([Could not find genhtml from the lcov package]) fi - if test -z "$GCOVR"; then - AC_MSG_ERROR([Could not find gcovr; easy_install (or pip) gcovr]) - fi - + ac_cv_check_gcov=yes + ac_cv_check_lcov=yes # Remove all optimization flags from CFLAGS changequote({,}) @@ -78,6 +74,13 @@ AC_ARG_ENABLE(gcov, COVERAGE_CXXFLAGS="-O0 -fprofile-arcs -ftest-coverage" COVERAGE_LDFLAGS="-lgcov" -fi -])]) # AC_TDD_GCOV + # Check availability of gcovr + AC_CHECK_PROG(GCOVR, gcovr, gcovr) + if test -z "$GCOVR"; then + ac_cv_check_gcovr=no + else + ac_cv_check_gcovr=yes + fi +fi +]) # AC_TDD_GCOV -- cgit v1.2.3 From b85b7c4ad314a27e6f4b08830305ccfaf6cc3d1e Mon Sep 17 00:00:00 2001 From: Allan LeSage Date: Mon, 19 Mar 2012 12:46:11 -0500 Subject: Tested moving PHONY clean targets to top of Makefile. --- Makefile.am.coverage | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile.am.coverage b/Makefile.am.coverage index 9edc849..296ad10 100644 --- a/Makefile.am.coverage +++ b/Makefile.am.coverage @@ -1,6 +1,9 @@ # Coverage targets +.PHONY: clean-coverage-html clean-coverage-gcovr +clean-local: clean-coverage-html clean-coverage-gcovr + if HAVE_GCOV .PHONY: clean-gcda @@ -39,6 +42,3 @@ clean-coverage-gcovr: clean-gcda endif # HAVE_GCOVR endif # HAVE_GCOV - -.PHONY: clean-coverage-html clean-coverage-gcovr -clean-local: clean-coverage-html clean-coverage-gcovr -- cgit v1.2.3 From b5b2b08a71f9babbadeb19ac956ba0029a7ff080 Mon Sep 17 00:00:00 2001 From: Allan LeSage Date: Mon, 19 Mar 2012 13:02:04 -0500 Subject: Consolidated PHONYs. --- Makefile.am.coverage | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile.am.coverage b/Makefile.am.coverage index 296ad10..9c59b95 100644 --- a/Makefile.am.coverage +++ b/Makefile.am.coverage @@ -1,17 +1,18 @@ # Coverage targets -.PHONY: clean-coverage-html clean-coverage-gcovr +.PHONY: clean-gcda \ + coverage-html generate-coverage-html clean-coverage-html \ + coverage-gcovr generate-coverage-gcovr clean-coverage-gcovr + clean-local: clean-coverage-html clean-coverage-gcovr if HAVE_GCOV -.PHONY: clean-gcda clean-gcda: @echo Removing old coverage results -find -name '*.gcda' -print | xargs -r rm -.PHONY: coverage-html generate-coverage-html coverage-html: clean-gcda -$(MAKE) $(AM_MAKEFLAGS) -k check $(MAKE) $(AM_MAKEFLAGS) generate-coverage-html @@ -27,7 +28,6 @@ clean-coverage-html: clean-gcda if HAVE_GCOVR -.PHONY: coverage-gcovr generate-coverage-gcovr coverage-gcovr: clean-gcda -$(MAKE) $(AM_MAKEFLAGS) -k check $(MAKE) $(AM_MAKEFLAGS) generate-coverage-gcovr -- cgit v1.2.3 From ab5696a78727fc9d20a5679481876e926baf7de7 Mon Sep 17 00:00:00 2001 From: Allan LeSage Date: Mon, 19 Mar 2012 13:38:41 -0500 Subject: Corrected a Makefile merge omission for tests, stripped down dummy test. --- Makefile.am | 5 +++++ test/test-gtest.cpp | 4 ---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Makefile.am b/Makefile.am index 6d4e4ee..0b5a4a3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,6 +4,11 @@ SUBDIRS = \ data \ po +if BUILD_TESTS +SUBDIRS += \ + test +endif + DISTCHECK_CONFIGURE_FLAGS = --enable-localinstall --enable-deprecations dist-hook: diff --git a/test/test-gtest.cpp b/test/test-gtest.cpp index bb9943d..1cc97be 100644 --- a/test/test-gtest.cpp +++ b/test/test-gtest.cpp @@ -8,9 +8,5 @@ extern "C" { TEST(LauncherMenuItem, NameInitialized) { g_type_init(); - //const gchar * expected = "foo"; - //LauncherMenuItem * test_li = launcher_menu_item_new ("foo"); - //gchar * result = launcher_menu_item_get_name(test_li); - //EXPECT_EQ(0, strcmp("foo", result)); EXPECT_TRUE(true); } -- cgit v1.2.3 From 6251928d97a1e10fb7e0e4c2df6372e8cead133e Mon Sep 17 00:00:00 2001 From: Allan LeSage Date: Tue, 20 Mar 2012 14:28:35 -0500 Subject: Attempt to build lib of code under test. --- test/Makefile.am | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/test/Makefile.am b/test/Makefile.am index e359ad4..522568a 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -32,3 +32,56 @@ test_gtest_LDFLAGS = -pthread test_gtest_LDADD = \ $(APPLET_LIBS) \ libgtest.a + + +###################################### +# Lib containing code under test +###################################### + +lib_LTLIBRARIES = \ + libindicator-messages-service.la + +libindicator_messages_service_la_HEADERS = \ + $(top_srcdir)/src/default-applications.h \ + $(top_srcdir)/src/messages-service-dbus.h \ + $(top_srcdir)/src/gen-messages-service.xml.h \ + $(top_srcdir)/src/im-menu-item.h \ + $(top_srcdir)/src/app-menu-item.h \ + $(top_srcdir)/src/launcher-menu-item.h \ + $(top_srcdir)/src/seen-db.h \ + $(top_srcdir)/src/dirs.h \ + $(top_srcdir)/src/dbus-data.h \ + $(top_srcdir)/src/status-items.h + +libindicator_messages_service_la_SOURCES = \ + $(top_srcdir)/src/default-applications.c \ + $(top_srcdir)/src/messages-service.c \ + $(top_srcdir)/src/messages-service-dbus.c \ + $(top_srcdir)/src/gen-messages-service.xml.c \ + $(top_srcdir)/src/im-menu-item.c \ + $(top_srcdir)/src/app-menu-item.c \ + $(top_srcdir)/src/launcher-menu-item.c \ + $(top_srcdir)/src/seen-db.c \ + $(top_srcdir)/src/status-items.c + +libindicator_messages_service_ladir = \ + $(includedir)/libindicator-messages-service/ + +libindicator_messages_service_la_CFLAGS = \ + $(APPLET_CFLAGS) \ + $(COVERAGE_CFLAGS) \ + -Wall \ + -Wl,-Bsymbolic-functions \ + -Wl,-z,defs \ + -Wl,--as-needed \ + -Werror \ + -DG_LOG_DOMAIN=\"Indicator-Messages\" \ + -DSTATUS_PROVIDER_DIR=\"$(STATUS_PROVIDER_DIR)\" + +libindicator_messages_service_la_LIBADD = \ + $(APPLET_LIBS) \ + libindicator-messages-status-provider.la + +libindicator_messages_service_la_LDFLAGS = \ + $(COVERAGE_LDFLAGS) + -- cgit v1.2.3 From f7d971a8407224ddd8b1b8744d18a33032c9142d Mon Sep 17 00:00:00 2001 From: Allan LeSage Date: Tue, 20 Mar 2012 15:30:16 -0500 Subject: Makefile fixes for code under test lib. --- Makefile.am | 7 +++++++ configure.ac | 3 +-- test/Makefile.am | 3 +-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Makefile.am b/Makefile.am index 0b5a4a3..bef67bd 100644 --- a/Makefile.am +++ b/Makefile.am @@ -7,8 +7,15 @@ SUBDIRS = \ if BUILD_TESTS SUBDIRS += \ test + +# build src first +test: src + endif + + + DISTCHECK_CONFIGURE_FLAGS = --enable-localinstall --enable-deprecations dist-hook: diff --git a/configure.ac b/configure.ac index 8646a0f..5ec945a 100644 --- a/configure.ac +++ b/configure.ac @@ -59,8 +59,7 @@ AS_IF([test "x$with_gtk" = x3], indicator3-0.4 >= $INDICATOR_REQUIRED_VERSION indicate-0.7 >= $INDICATE_REQUIRED_VERSION dbusmenu-gtk3-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION - glib-2.0 >= GLIB_REQUIRED_VERSION) - + glib-2.0 >= $GLIB_REQUIRED_VERSION) ], [test "x$with_gtk" = x2], [PKG_CHECK_MODULES(APPLET, gtk+-2.0 >= $GTK_REQUIRED_VERSION diff --git a/test/Makefile.am b/test/Makefile.am index 522568a..8986a40 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -80,8 +80,7 @@ libindicator_messages_service_la_CFLAGS = \ libindicator_messages_service_la_LIBADD = \ $(APPLET_LIBS) \ - libindicator-messages-status-provider.la + $(top_builddir)/src/.libs/libindicator-messages-status-provider.la libindicator_messages_service_la_LDFLAGS = \ $(COVERAGE_LDFLAGS) - -- cgit v1.2.3 From 4700a77b61efa6bb089d019223177e47cdc5c3db Mon Sep 17 00:00:00 2001 From: Allan LeSage Date: Tue, 20 Mar 2012 16:36:08 -0500 Subject: Charles-suggested fixes for gmodule dependency. --- configure.ac | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 5ec945a..1690ad6 100644 --- a/configure.ac +++ b/configure.ac @@ -59,7 +59,8 @@ AS_IF([test "x$with_gtk" = x3], indicator3-0.4 >= $INDICATOR_REQUIRED_VERSION indicate-0.7 >= $INDICATE_REQUIRED_VERSION dbusmenu-gtk3-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION - glib-2.0 >= $GLIB_REQUIRED_VERSION) + glib-2.0 >= $GLIB_REQUIRED_VERSION + gmodule-2.0 >= $GLIB_REQUIRED_VERSION) ], [test "x$with_gtk" = x2], [PKG_CHECK_MODULES(APPLET, gtk+-2.0 >= $GTK_REQUIRED_VERSION @@ -67,7 +68,8 @@ AS_IF([test "x$with_gtk" = x3], indicator-0.4 >= $INDICATOR_REQUIRED_VERSION indicate-0.7 >= $INDICATE_REQUIRED_VERSION dbusmenu-gtk-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION - glib-2.0 >= GLIB_REQUIRED_VERSION) + glib-2.0 >= $GLIB_REQUIRED_VERSION + gmodule-2.0 >= $GLIB_REQUIRED_VERSION) ], [AC_MSG_FAILURE([Value for --with-indicator-gtk was neither 2 nor 3])] ) -- cgit v1.2.3 From dcd64738bfb7a4060080526203fa68e9c176e48b Mon Sep 17 00:00:00 2001 From: Allan LeSage Date: Tue, 20 Mar 2012 17:10:57 -0500 Subject: Tabs vs. spaces cosmetic change in configure.ac. --- configure.ac | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index 1690ad6..a429d17 100644 --- a/configure.ac +++ b/configure.ac @@ -59,8 +59,8 @@ AS_IF([test "x$with_gtk" = x3], indicator3-0.4 >= $INDICATOR_REQUIRED_VERSION indicate-0.7 >= $INDICATE_REQUIRED_VERSION dbusmenu-gtk3-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION - glib-2.0 >= $GLIB_REQUIRED_VERSION - gmodule-2.0 >= $GLIB_REQUIRED_VERSION) + glib-2.0 >= $GLIB_REQUIRED_VERSION + gmodule-2.0 >= $GLIB_REQUIRED_VERSION) ], [test "x$with_gtk" = x2], [PKG_CHECK_MODULES(APPLET, gtk+-2.0 >= $GTK_REQUIRED_VERSION @@ -68,8 +68,8 @@ AS_IF([test "x$with_gtk" = x3], indicator-0.4 >= $INDICATOR_REQUIRED_VERSION indicate-0.7 >= $INDICATE_REQUIRED_VERSION dbusmenu-gtk-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION - glib-2.0 >= $GLIB_REQUIRED_VERSION - gmodule-2.0 >= $GLIB_REQUIRED_VERSION) + glib-2.0 >= $GLIB_REQUIRED_VERSION + gmodule-2.0 >= $GLIB_REQUIRED_VERSION) ], [AC_MSG_FAILURE([Value for --with-indicator-gtk was neither 2 nor 3])] ) -- cgit v1.2.3