From: tweenk Date: Mon, 8 Dec 2008 20:29:12 +0000 (+0000) Subject: "make check" now compiles and runs on Linux. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=b75c8c079c27d43ecebd305ec1796d5ebd5b9bb9;p=inkscape.git "make check" now compiles and runs on Linux. --- diff --git a/src/Makefile.am b/src/Makefile.am index b1df01074..49fad3226 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -30,6 +30,7 @@ INCLUDES = \ -I$(top_srcdir)/cxxtest \ $(WIN32_CFLAGS) +# Include all partial makefiles from subdirectories include Makefile_insert include application/Makefile_insert include bind/Makefile_insert @@ -74,8 +75,11 @@ include util/Makefile_insert include trace/Makefile_insert include 2geom/Makefile_insert +# Executables compiled by "make" and installed by "make install" bin_PROGRAMS = inkscape inkview +# Libraries which should be compiled by "make" but not installed +# Currently we use one library per source directory. noinst_LIBRARIES = \ libinkpre.a \ application/libinkapp.a \ @@ -119,19 +123,13 @@ noinst_LIBRARIES = \ 2geom/lib2geom.a \ libinkpost.a -check_LIBRARIES = \ - display/libtest-display.a \ - helper/libtest-helper.a \ - libnr/libtest-nr.a \ - svg/libtest-svg.a \ - util/libtest-util.a \ - xml/libtest-xml.a - +# Extra files to remove when doing "make distclean" DISTCLEANFILES = \ helper/sp-marshal.cpp \ helper/sp-marshal.h \ inkscape_version.h +# Extra files not mentioned as sources to include in the source tarball EXTRA_DIST = \ Doxyfile \ sp-skeleton.cpp sp-skeleton.h \ @@ -196,6 +194,14 @@ EXTRA_PROGRAMS = \ inkview \ libnr/testnr + +################################## +### TESTING STUFF (make check) ### +################################## + +# List of all tests to be run. Should contain one per directory. +# Automake 1.10 appends EXEEXT automatically, so this should be changed +# when we move to Automake 1.10. TESTS = \ test-src$(EXEEXT) \ style-test$(EXEEXT) \ @@ -219,18 +225,15 @@ TESTS = \ xml/quote-test$(EXEEXT) \ xml/repr-action-test$(EXEEXT) -# As of 2007-01-13, these are failing... -#XFAIL_TESTS = \ -# test-src$(EXEEXT) \ -# style-test$(EXEEXT) - # streamtest is unfinished and can't handle the relocations done during # "make distcheck". Not needed for the 0.41 release. # io/streamtest$(EXEEXT) - # automake adds $(EXEEXT) to check_PROGRAMS items but not to TESTS items: # TESTS items can be scripts etc. +# List of all programs that should be built before testing. Note that this is +# not necessarily equal to TESTS, because some tests can be scripts that don't +# need to be built. check_PROGRAMS = \ test-src \ style-test \ @@ -253,23 +256,16 @@ check_PROGRAMS = \ xml/test-xml \ xml/quote-test \ xml/repr-action-test - # io/streamtest - -test-src.cpp: \ - $(test_src_includes) - $(top_srcdir)/cxxtest/cxxtestgen.pl --have-eh --template=$(srcdir)/selfname.tpl -root -o test-src.cpp \ - $(test_src_includes) - -test_src_SOURCES = \ - test-src.cpp $(test_src_includes) - - -test_src_LDADD = \ - $(all_libs) \ - io/libio.a - +# Additional libraries needed by the tests - to be removed later. +check_LIBRARIES = \ + display/libtest-display.a \ + helper/libtest-helper.a \ + libnr/libtest-nr.a \ + svg/libtest-svg.a \ + util/libtest-util.a \ + xml/libtest-xml.a # ################################################ # diff --git a/src/Makefile_insert b/src/Makefile_insert index 1d2ba9352..ac4100862 100644 --- a/src/Makefile_insert +++ b/src/Makefile_insert @@ -399,19 +399,33 @@ style_test_LDADD = $(all_libs) inkscape_version.h: ../configure.ac echo '#define INKSCAPE_VERSION "$(VERSION)"' > inkscape_version.h -test_src_includes = \ - $(srcdir)/MultiPrinter.h \ - $(srcdir)/TRPIFormatter.h \ - $(srcdir)/PylogFormatter.h \ +test_src_includes = \ + $(srcdir)/MultiPrinter.h \ + $(srcdir)/TRPIFormatter.h \ + $(srcdir)/PylogFormatter.h \ $(srcdir)/attributes-test.h \ $(srcdir)/color-profile-test.h \ $(srcdir)/dir-util-test.h \ $(srcdir)/extract-uri-test.h \ - $(srcdir)/mod360-test.h \ - $(srcdir)/round-test.h \ - $(srcdir)/preferences-test.h \ + $(srcdir)/mod360-test.h \ + $(srcdir)/round-test.h \ + $(srcdir)/preferences-test.h \ $(srcdir)/sp-gradient-test.h \ $(srcdir)/sp-style-elem-test.h \ - $(srcdir)/style-test.h \ - $(srcdir)/test-helpers.h \ + $(srcdir)/style-test.h \ + $(srcdir)/test-helpers.h \ $(srcdir)/verbs-test.h + +test-src.cpp: \ + $(test_src_includes) + $(top_srcdir)/cxxtest/cxxtestgen.pl --have-eh --template=$(srcdir)/selfname.tpl -root -o test-src.cpp \ + $(test_src_includes) + +test_src_SOURCES = \ + test-src.cpp \ + $(test_src_includes) + + +test_src_LDADD = \ + $(all_libs) \ + io/libio.a diff --git a/src/libnr/Makefile_insert b/src/libnr/Makefile_insert index ef813a8be..21cce1ea2 100644 --- a/src/libnr/Makefile_insert +++ b/src/libnr/Makefile_insert @@ -128,16 +128,17 @@ libnr_test_nr_SOURCES = \ libnr/test-nr-main.cpp \ $(libnr_test_nr_includes) -libnr_test_nr_LDADD = \ - libnr/libnr.a \ +libnr_test_nr_LDADD = \ + libnr/libnr.a \ libnr/libtest-nr.a \ + 2geom/lib2geom.a \ -lglib-2.0 # -L/usr/X11R6/lib # -lX11 libnr_in_svg_plane_test_SOURCES = libnr/in-svg-plane-test.cpp -libnr_in_svg_plane_test_LDADD = libnr/libnr.a -lglib-2.0 +libnr_in_svg_plane_test_LDADD = libnr/libnr.a 2geom/lib2geom.a -lglib-2.0 libnr_nr_types_test_SOURCES = libnr/nr-types-test.cpp libnr_nr_types_test_LDADD = libnr/libnr.a -lglib-2.0 diff --git a/src/preferences.h b/src/preferences.h index 2f2337b81..0c37be24b 100644 --- a/src/preferences.h +++ b/src/preferences.h @@ -109,6 +109,7 @@ public: friend class Preferences; // Preferences class has to access _value public: ~Entry() {} + Entry() : _pref_path(""), _value(NULL) {} // needed to enable use in maps Entry(Entry const &other) : _pref_path(other._pref_path), _value(other._value) {} /** * @brief Check whether the received entry is valid. diff --git a/src/svg/Makefile_insert b/src/svg/Makefile_insert index 0c59677fa..3219f171e 100644 --- a/src/svg/Makefile_insert +++ b/src/svg/Makefile_insert @@ -45,19 +45,24 @@ svg/test-svg.cpp: $(svg_test_svg_includes) svg/Makefile_insert svg_test_svg_includes = \ $(srcdir)/svg/css-ostringstream-test.h \ $(srcdir)/svg/stringstream-test.h \ - $(srcdir)/svg/svg-affine-test.h \ - $(srcdir)/svg/svg-color-test.h \ - $(srcdir)/svg/svg-length-test.h \ + $(srcdir)/svg/svg-affine-test.h \ + $(srcdir)/svg/svg-color-test.h \ + $(srcdir)/svg/svg-length-test.h \ $(srcdir)/svg/svg-path-geom-test.h svg_libtest_svg_a_SOURCES = \ svg/test-svg.cpp \ $(svg_test_svg_includes) -svg_test_svg_SOURCES = \ +svg_test_svg_SOURCES = \ svg/test-svg-main.cpp \ $(svg_test_svg_includes) -svg_test_svg_LDADD = \ +svg_test_svg_LDADD = \ + svg/libspsvg.a \ svg/libtest-svg.a \ - $(all_libs) + test-stubs.o \ + 2geom/lib2geom.a \ + libnr/libnr.a \ + $(INKSCAPE_LIBS) + diff --git a/src/test-stubs.cpp b/src/test-stubs.cpp index efc5cf7d8..449cce1b6 100644 --- a/src/test-stubs.cpp +++ b/src/test-stubs.cpp @@ -1,4 +1,115 @@ +/** @file + * @brief Alternate stub implementations for some functions. + * + * This file exists only for the benefit of the linker when building tests, + * to avoid circular dependencies. If some test causes link errors because of a function + * it doesn't need, feel free to add a stub here. + */ +/* Authors: Krzysztof Kosiński + * This file is in the public domain. + */ + +#include "preferences.h" +#include +#include +#include +#include -// dummy functions to prevent link errors int sp_main_gui(int /*argc*/, char const **/*argv*/) { return 0; } int sp_main_console(int /*argc*/, char const **/*argv*/) { return 0; } + +// stubbed out preferences implementation using a simple map +namespace Inkscape { + +std::map _prefs; + +Preferences::Preferences() : + _prefs_basename(""), + _prefs_dir(""), + _prefs_filename(""), + _prefs_doc(NULL), + _use_gui(true), + _quiet(false), + _loaded(false), + _writable(false) +{ +} + +Preferences::~Preferences() +{ +} + +void Preferences::load(bool use_gui, bool quiet) {} +void Preferences::save() {} + +// getter methods + +Preferences::Entry const Preferences::getEntry(Glib::ustring const &pref_path) +{ + return _prefs[pref_path]; +} +void Preferences::setBool(Glib::ustring const &pref_path, bool value) +{ + _prefs[pref_path] = _create_pref_value(pref_path, (void const*) (value ? "1" : "0")); +} +void Preferences::setInt(Glib::ustring const &pref_path, int value) +{ + gchar *intstr = (gchar*) g_malloc(32); + g_snprintf(intstr, 32, "%d", value); + _prefs[pref_path] = _create_pref_value(pref_path, (void const*) intstr); +} +void Preferences::setDouble(Glib::ustring const &pref_path, double value) +{ + gchar *buf = (gchar*) g_malloc(G_ASCII_DTOSTR_BUF_SIZE); + g_ascii_dtostr(buf, G_ASCII_DTOSTR_BUF_SIZE, value); + _prefs[pref_path] = _create_pref_value(pref_path, (void const*) buf); +} +void Preferences::setString(Glib::ustring const &pref_path, Glib::ustring const &value) +{ + _prefs[pref_path] = _create_pref_value(pref_path, (void const*) g_strdup(value.data())); +} + +bool Preferences::_extractBool(Entry const &v) +{ + gchar const *s = static_cast(v._value); + if ( !s[0] || !strcmp(s, "0") || !strcmp(s, "false") ) return false; + return true; +} +int Preferences::_extractInt(Entry const &v) +{ + gchar const *s = static_cast(v._value); + if ( !strcmp(s, "true") ) return true; + if ( !strcmp(s, "false") ) return false; + return atoi(s); +} +double Preferences::_extractDouble(Entry const &v) +{ + gchar const *s = static_cast(v._value); + return g_ascii_strtod(s, NULL); +} + +Glib::ustring Preferences::_extractString(Entry const &v) +{ + return Glib::ustring(static_cast(v._value)); +} +Preferences::Entry const Preferences::_create_pref_value(Glib::ustring const &path, void const *ptr) +{ + return Entry(path, ptr); +} + +Preferences *Preferences::_instance = NULL; + + +} // namespace Inkscape + + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/util/list-container-test.h b/src/util/list-container-test.h index c2db79fee..7765352eb 100644 --- a/src/util/list-container-test.h +++ b/src/util/list-container-test.h @@ -115,15 +115,16 @@ public: void testContainerSize() { + // max_size() and size() return ListContainer<>::size_type which is unsigned int Inkscape::Util::ListContainer empty; TS_ASSERT(empty.empty()); - TS_ASSERT_EQUALS(static_cast(empty.size()), 0); + TS_ASSERT_EQUALS(empty.size(), 0u); int const a[] = { 1, 2, 3 }; Inkscape::Util::ListContainer c_a(ARRAY_RANGE(a)); TS_ASSERT(!c_a.empty()); - TS_ASSERT_EQUALS(static_cast(c_a.size()), 3); + TS_ASSERT_EQUALS(c_a.size(), 3u); - TS_ASSERT_LESS_THAN(0, static_cast(empty.max_size())); + TS_ASSERT_LESS_THAN(0u, empty.max_size()); } void testAppending() diff --git a/src/xml/Makefile_insert b/src/xml/Makefile_insert index 84e907126..5810052de 100644 --- a/src/xml/Makefile_insert +++ b/src/xml/Makefile_insert @@ -73,11 +73,11 @@ xml_test_xml_SOURCES = \ xml_test_xml_LDADD = \ xml/libtest-xml.a \ - xml/libspxml.a \ + xml/libspxml.a \ util/libinkutil.a \ - svg/libspsvg.a \ - svg/libtest-stubs.a \ - libinkpost.a \ + svg/libspsvg.a \ + test-stubs.o \ + libinkpost.a \ debug/libinkdebug.a \ $(INKSCAPE_LIBS) @@ -87,7 +87,7 @@ xml_repr_action_test_SOURCES = \ xml_repr_action_test_LDADD = \ xml/libspxml.a \ svg/libspsvg.a \ - svg/libtest-stubs.a \ + libtest-stubs.a \ util/libinkutil.a \ libinkpost.a \ debug/libinkdebug.a \