Code

"make check" now compiles and runs on Linux.
authortweenk <tweenk@users.sourceforge.net>
Mon, 8 Dec 2008 20:29:12 +0000 (20:29 +0000)
committertweenk <tweenk@users.sourceforge.net>
Mon, 8 Dec 2008 20:29:12 +0000 (20:29 +0000)
src/Makefile.am
src/Makefile_insert
src/libnr/Makefile_insert
src/preferences.h
src/svg/Makefile_insert
src/test-stubs.cpp
src/util/list-container-test.h
src/xml/Makefile_insert

index b1df010747a3802879ac1e936de85eac7e137957..49fad32268df03944a819150f64fe542a20b1423 100644 (file)
@@ -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
 
 # ################################################
 #
index 1d2ba935227103b9fecf341f0c2d87edf7d51bf4..ac410086266115aa58f7f676216973de4b047f17 100644 (file)
@@ -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
index ef813a8be8b3607612de3206c07925e8618d89c5..21cce1ea26d0ea388eeb786c0bfe24df635310e8 100644 (file)
@@ -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
index 2f2337b8131892f1dc6157cd8ad1970fc0e1f74b..0c37be24baba4c462ccd95ed25d567a65bf124db 100644 (file)
@@ -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.
index 0c59677fa2c9d633fc2dba58a7e6c9f8e63d68d0..3219f171e1efac7cd09134b9cae6d0336be32e6b 100644 (file)
@@ -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)
+
index efc5cf7d82ee8bf81df0e0b14a5aed7e7b6e3495..449cce1b63a30351d39accf2396de6518ef1dc95 100644 (file)
@@ -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 <twwenk.pl@gmail.com>
+ * This file is in the public domain.
+ */
+
+#include "preferences.h"
+#include <glib.h>
+#include <glib/gstdio.h>
+#include <cstring>
+#include <cstdlib>
 
-// 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<Glib::ustring, Preferences::Entry> _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<gchar const *>(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<gchar const *>(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<gchar const *>(v._value);
+    return g_ascii_strtod(s, NULL);
+}
+
+Glib::ustring Preferences::_extractString(Entry const &v)
+{
+    return Glib::ustring(static_cast<gchar const *>(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 :
index c2db79fee0e52d5f4e39fa797ec9299ce65edb2b..7765352eb17594d5270417d16d35ba219202fd3f 100644 (file)
@@ -115,15 +115,16 @@ public:
 
     void testContainerSize()
     {
+        // max_size() and size() return ListContainer<>::size_type which is unsigned int
         Inkscape::Util::ListContainer<int> empty;
         TS_ASSERT(empty.empty());
-        TS_ASSERT_EQUALS(static_cast<int>(empty.size()), 0);
+        TS_ASSERT_EQUALS(empty.size(), 0u);
         int const a[] = { 1, 2, 3 };
         Inkscape::Util::ListContainer<int> c_a(ARRAY_RANGE(a));
         TS_ASSERT(!c_a.empty());
-        TS_ASSERT_EQUALS(static_cast<int>(c_a.size()), 3);
+        TS_ASSERT_EQUALS(c_a.size(), 3u);
 
-        TS_ASSERT_LESS_THAN(0, static_cast<int>(empty.max_size()));
+        TS_ASSERT_LESS_THAN(0u, empty.max_size());
     }
 
     void testAppending()
index 84e90712659a3d38178ac5095d7a84359f73276f..5810052dee1fd02f249fe4fe23d219f42513d864 100644 (file)
@@ -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     \