[f-spot] Revive the unit tests.



commit 7f7b1387daba2048807501568a4e67317e04937a
Author: Ruben Vermeersch <ruben savanne be>
Date:   Sat Jul 4 17:47:27 2009 +0100

    Revive the unit tests.
    
    Rework the test build system. This will always build tests if you have nunit
    and will ignore it if you don't. Inspiration taken from Banshee's build
    system.
    
    The tests are still very verbose on errors and other nasty output (should be
    fixed), but most of them are probably broken anyway. However, reviving this
    allows for useful tests to be added in the future :-).
    
    Fails distcheck, but I am not capable of fixing it.

 Makefile.am                                       |    9 +++
 Tests/src/Makefile                                |   45 ---------------
 configure.ac                                      |   57 ++++++++------------
 src/Makefile.am                                   |    4 +-
 tests/.gitignore                                  |    2 +
 tests/Makefile.am                                 |    9 +++
 {Tests => tests}/images/pano.jpg                  |  Bin 802438 -> 802438 bytes
 tests/src/.gitignore                              |    6 ++
 {Tests => tests}/src/ChangeLog                    |    0
 {Tests => tests}/src/Cms/Cms.cs                   |    2 -
 {Tests => tests}/src/Filters/ColorFilter.cs       |    2 -
 {Tests => tests}/src/Filters/JpegFilter.cs        |    3 -
 {Tests => tests}/src/Filters/OrientationFilter.cs |    3 -
 {Tests => tests}/src/IBrowsableItem.cs            |    3 -
 {Tests => tests}/src/ImageTest.cs                 |    0
 {Tests => tests}/src/Imaging/JpegFile.cs          |    0
 {Tests => tests}/src/Imaging/PngFile.cs           |    0
 {Tests => tests}/src/Imaging/Tiff.cs              |    2 -
 tests/src/Makefile.am                             |   60 +++++++++++++++++++++
 {Tests => tests}/src/PhotoStore.cs                |   17 +++---
 {Tests => tests}/src/Query/LogicalTerm.cs         |    0
 {Tests => tests}/src/TagStore.cs                  |   21 +++----
 {Tests => tests}/src/ThumbnailGenerator.cs        |    0
 23 files changed, 128 insertions(+), 117 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 71aee3d..de468f3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -18,6 +18,7 @@ SUBDIRS = 		\
 	po		\
 	src		\
 	extensions	\
+	tests		\
 	GKeyFile
 
 DIST_SUBDIRS = 		\
@@ -40,6 +41,7 @@ DIST_SUBDIRS = 		\
 	po		\
 	src		\
 	extensions	\
+	tests		\
 	GKeyFile
 
 desktop_in_files=	\
@@ -95,3 +97,10 @@ install-data-hook:
 
 uninstall-hook: 
 	$(UPDATE_DESKTOP)
+
+if ENABLE_TESTS
+test:
+	@pushd tests/src/; \
+	make test; \
+	popd;
+endif
diff --git a/configure.ac b/configure.ac
index bc68d03..d924ef8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -146,43 +146,28 @@ AC_SUBST(LINK_DBUS)
 AC_SUBST(PATH_DBUS)
 
 dnl -- nunit
-AC_ARG_ENABLE([nunit],[AC_HELP_STRING([--disable-unit], [build without unit tests])],,)
-AM_CONDITIONAL(DISABLE_NUNIT, test "x$enable_nunit" = "xno")
-
-if test "x$enable_nunit" = "xno"; then
-	NUNIT_DEFINES=''
-	NUNIT_PKG=''
-
-else 	
-NUNIT_DEFINES='-d:ENABLE_NUNIT'
-PKG_CHECK_MODULES(MONO_NUNIT, mono-nunit >= $MONO_REQUIRED,
-[
-  NUNIT_LIBS=$MONO_NUNIT_LIBS
-  NUNIT_PKG='-pkg:mono-nunit'
-],
-[
-  PKG_CHECK_MODULES(NUNIT22, nunit-2.2 >= $MONO_REQUIRED,
-  [
-    NUNIT_LIBS=$NUNIT22_LIBS
-    NUNIT_PKG='-pkg:nunit-2.2'
-  ],
-  [
-    PKG_CHECK_MODULES(NUNIT, nunit >= $MONO_REQUIRED,
-    [
-	NUNIT_LIBS=$NUNIT_LIBS
-	NUNIT_PKG='-pkg:nunit'
-    ],
-    [
-        NUNIT_DEFINES=''
-	NUNIT_PKG=''
-    ])
-  ])
-])
+PKG_CHECK_MODULES(NUNIT, nunit >= $NUNIT_REQUIRED, 
+	do_tests="yes", do_tests="no")
+
+AC_SUBST(NUNIT_LIBS)
+AM_CONDITIONAL(ENABLE_TESTS, test "x$do_tests" = "xyes")
+
+if test "x$do_tests" = "xno"; then
+	PKG_CHECK_MODULES(NUNIT, mono-nunit >= 2.0, 
+		do_tests="yes", do_tests="no")
+	
+	AC_SUBST(NUNIT_LIBS)
+	AM_CONDITIONAL(ENABLE_TESTS, test "x$do_tests" = "xyes")
+
+	if test "x$do_tests" = "xno"; then
+		NUNIT_DEFINES=''
+		AC_MSG_WARN([Could not find nunit: tests will not be available.])
+	else
+		NUNIT_DEFINES='-d:ENABLE_NUNIT'
+	fi
+	AC_SUBST(NUNIT_DEFINES)
 fi
 
-AC_SUBST(NUNIT_PKG)
-AC_SUBST(NUNIT_DEFINES)
-
 
 dnl --- GConf
 
@@ -356,6 +341,8 @@ extensions/Tools/ChangePhotoPath/Makefile
 extensions/Tools/HashJob/Makefile
 extensions/Tools/DevelopInUFraw/Makefile
 extensions/Tools/MergeDb/Makefile
+tests/Makefile
+tests/src/Makefile
 f-spot.pc
 f-spot.spec
 f-spot.desktop.in
diff --git a/src/Makefile.am b/src/Makefile.am
index 7989284..bf79e46 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -308,7 +308,7 @@ GCONF_PKG = -pkg:gconf-sharp-2.0
 endif
 
 CMS_ASSEMBLIES = 				\
-	$(NUNIT_PKG)				\
+	$(NUNIT_LIBS)				\
 	-pkg:gtk-sharp-2.0
 
 CORE_ASSEMBLIES =				\
@@ -388,7 +388,7 @@ F_SPOT_ASSEMBLIES = 				\
 	-r:FSpot.Widgets.dll			\
 	-r:FSpot.Platform.dll			\
 	-r:Cms.dll				\
-	$(NUNIT_PKG)				\
+	$(NUNIT_LIBS)				\
 	$(GCONF_PKG)				\
 	$(GTKHTML_SHARP_PKG)			\
 	-pkg:glade-sharp-2.0			\
diff --git a/tests/.gitignore b/tests/.gitignore
new file mode 100644
index 0000000..b336cc7
--- /dev/null
+++ b/tests/.gitignore
@@ -0,0 +1,2 @@
+/Makefile
+/Makefile.in
diff --git a/tests/Makefile.am b/tests/Makefile.am
new file mode 100644
index 0000000..c168055
--- /dev/null
+++ b/tests/Makefile.am
@@ -0,0 +1,9 @@
+if ENABLE_TESTS
+
+SUBDIRS = \
+	src
+
+endif
+
+MAINTAINERCLEANFILES = \
+	Makefile.in
diff --git a/Tests/images/pano.jpg b/tests/images/pano.jpg
similarity index 100%
rename from Tests/images/pano.jpg
rename to tests/images/pano.jpg
diff --git a/tests/src/.gitignore b/tests/src/.gitignore
new file mode 100644
index 0000000..52e20c8
--- /dev/null
+++ b/tests/src/.gitignore
@@ -0,0 +1,6 @@
+/Makefile
+/Makefile.in
+/FSpot.Tests.dll
+/*Test.db
+/*NUnitPrimaryTrace.txt
+/TestResult.xml
diff --git a/Tests/src/ChangeLog b/tests/src/ChangeLog
similarity index 100%
rename from Tests/src/ChangeLog
rename to tests/src/ChangeLog
diff --git a/Tests/src/Cms/Cms.cs b/tests/src/Cms/Cms.cs
similarity index 98%
rename from Tests/src/Cms/Cms.cs
rename to tests/src/Cms/Cms.cs
index 6830588..512be13 100644
--- a/Tests/src/Cms/Cms.cs
+++ b/tests/src/Cms/Cms.cs
@@ -1,4 +1,3 @@
-#if ENABLE_NUNIT
 using NUnit.Framework;
 
 namespace Cms.Tests
@@ -58,4 +57,3 @@ namespace Cms.Tests
 		}
 	}
 }
-#endif 		
diff --git a/Tests/src/Filters/ColorFilter.cs b/tests/src/Filters/ColorFilter.cs
similarity index 98%
rename from Tests/src/Filters/ColorFilter.cs
rename to tests/src/Filters/ColorFilter.cs
index d709bb5..325c26d 100644
--- a/Tests/src/Filters/ColorFilter.cs
+++ b/tests/src/Filters/ColorFilter.cs
@@ -1,4 +1,3 @@
-#if ENABLE_NUNIT
 using NUnit.Framework;
 using Gdk;
 using System.IO;
@@ -47,5 +46,4 @@ namespace FSpot.Filters.Tests
 		}
 	}
 }
-#endif	
 
diff --git a/Tests/src/Filters/JpegFilter.cs b/tests/src/Filters/JpegFilter.cs
similarity index 98%
rename from Tests/src/Filters/JpegFilter.cs
rename to tests/src/Filters/JpegFilter.cs
index 786f067..dee2464 100644
--- a/Tests/src/Filters/JpegFilter.cs
+++ b/tests/src/Filters/JpegFilter.cs
@@ -1,4 +1,3 @@
-#if ENABLE_NUNIT
 using NUnit.Framework;
 using System;
 
@@ -72,5 +71,3 @@ namespace FSpot.Filters.Tests
 		}
 	}
 }
-#endif
-
diff --git a/Tests/src/Filters/OrientationFilter.cs b/tests/src/Filters/OrientationFilter.cs
similarity index 94%
rename from Tests/src/Filters/OrientationFilter.cs
rename to tests/src/Filters/OrientationFilter.cs
index 0d19ebb..7515df4 100644
--- a/Tests/src/Filters/OrientationFilter.cs
+++ b/tests/src/Filters/OrientationFilter.cs
@@ -1,4 +1,3 @@
-#if ENABLE_NUNIT
 using NUnit.Framework;
 namespace FSpot.Filters.Test
 {
@@ -14,5 +13,3 @@ namespace FSpot.Filters.Test
 		}
 	}
 }
-#endif
-
diff --git a/Tests/src/IBrowsableItem.cs b/tests/src/IBrowsableItem.cs
similarity index 98%
rename from Tests/src/IBrowsableItem.cs
rename to tests/src/IBrowsableItem.cs
index 7e61ed4..7d08ee1 100644
--- a/Tests/src/IBrowsableItem.cs
+++ b/tests/src/IBrowsableItem.cs
@@ -1,4 +1,3 @@
-#if ENABLE_NUNIT
 using NUnit.Framework;
 
 namespace FSpot.Tests
@@ -78,5 +77,3 @@ namespace FSpot.Tests
 		}
 	}
 }
-#endif
-
diff --git a/Tests/src/ImageTest.cs b/tests/src/ImageTest.cs
similarity index 100%
rename from Tests/src/ImageTest.cs
rename to tests/src/ImageTest.cs
diff --git a/Tests/src/Imaging/JpegFile.cs b/tests/src/Imaging/JpegFile.cs
similarity index 100%
rename from Tests/src/Imaging/JpegFile.cs
rename to tests/src/Imaging/JpegFile.cs
diff --git a/Tests/src/Imaging/PngFile.cs b/tests/src/Imaging/PngFile.cs
similarity index 100%
rename from Tests/src/Imaging/PngFile.cs
rename to tests/src/Imaging/PngFile.cs
diff --git a/Tests/src/Imaging/Tiff.cs b/tests/src/Imaging/Tiff.cs
similarity index 99%
rename from Tests/src/Imaging/Tiff.cs
rename to tests/src/Imaging/Tiff.cs
index 4805cdb..e6444bb 100644
--- a/Tests/src/Imaging/Tiff.cs
+++ b/tests/src/Imaging/Tiff.cs
@@ -1,6 +1,5 @@
 // Author: Larry
 
-#if ENABLE_NUNIT
 	[TestFixture]
 	public class Tests {
 		public Tests ()
@@ -72,5 +71,4 @@
 			}
 		}
 	}
-#endif
 
diff --git a/tests/src/Makefile.am b/tests/src/Makefile.am
new file mode 100644
index 0000000..f627049
--- /dev/null
+++ b/tests/src/Makefile.am
@@ -0,0 +1,60 @@
+include $(top_srcdir)/Makefile.include
+
+all: FSpot.Tests.dll
+
+SOURCES = 				\
+	IBrowsableItem.cs		\
+	ImageTest.cs			\
+	PhotoStore.cs			\
+	TagStore.cs			\
+	ThumbnailGenerator.cs		\
+	Query/LogicalTerm.cs		\
+	Cms/Cms.cs			\
+	Filters/JpegFilter.cs		\
+	Filters/OrientationFilter.cs	\
+	Filters/ColorFilter.cs
+
+PKGS = 					\
+	-pkg:mono-nunit			\
+	-pkg:gnome-vfs-sharp-2.0	\
+	-pkg:gnome-sharp-2.0		\
+	-pkg:gtk-sharp-2.0
+
+REFS =										\
+	$(LINK_GPHOTO2)							\
+	$(LINK_MONO_ADDINS)						\
+	$(LINK_GIOSHARP)						\
+	-r:$(top_srcdir)/src/f-spot.exe			\
+	-r:$(top_srcdir)/src/FSpot.Core.dll		\
+	-r:$(top_srcdir)/src/FSpot.Query.dll	\
+	-r:$(top_srcdir)/src/FSpot.Utils.dll	\
+	-r:$(top_srcdir)/src/FSpot.Platform.dll	\
+	-r:$(top_srcdir)/src/Cms.dll			\
+	-r:$(top_srcdir)/semweb/SemWeb.dll
+
+EXTRA_DIST =			\
+	$(SOURCES)
+
+RESOURCES =							\
+	-resource:$(top_srcdir)/icons/f-spot-32.png,f-spot-32.png
+
+TEST_ASSEMBLIES =				\
+	FSpot.Tests.dll
+
+MCSFLAGS = -t:library -d:ENABLE_NUNIT
+
+FSpot.Tests.dll: $(SOURCES)
+	gmcs $(MCSFLAGS) $(PKGS) $(REFS) $(SOURCES) $(RESOURCES) -out:FSpot.Tests.dll
+
+test: FSpot.Tests.dll
+	export MONO_PATH=$(top_srcdir)/src:$(top_srcdir)/gio-sharp/gio/:$(top_srcdir)/semweb:$(top_srcdir)/gtk-sharp-beans; nunit-console -noshadow -nologo $(TEST_ASSEMBLIES) 
+
+CLEANFILES =			\
+	FSpot.Tests.dll.mdb	\
+	FSpot.Tests.dll		\
+	PhotoTestStore.db	\
+	TagTestStore.db		\
+	TestResult.xml
+
+MAINTAINERCLEANFILES = \
+	Makefile.in
diff --git a/Tests/src/PhotoStore.cs b/tests/src/PhotoStore.cs
similarity index 86%
rename from Tests/src/PhotoStore.cs
rename to tests/src/PhotoStore.cs
index 76819d3..f60c87d 100644
--- a/Tests/src/PhotoStore.cs
+++ b/tests/src/PhotoStore.cs
@@ -1,4 +1,5 @@
 #if ENABLE_NUNIT
+using FSpot.Utils;
 using NUnit.Framework;
 using System.Collections;
 using System.IO;
@@ -94,18 +95,18 @@ namespace FSpot.Tests
 		[Test]
 		public void PopulatendRetrieve ()
 		{
-			Tag portraits_tag = db.Tags.CreateTag (null, "Portraits");
-			Tag landscapes_tag = db.Tags.CreateTag (null, "Landscapes");
-			Tag favorites_tag = db.Tags.CreateTag (null, "Street");
+			/*Tag portraits_tag = */db.Tags.CreateTag (null, "Portraits", false);
+			Tag landscapes_tag = db.Tags.CreateTag (null, "Landscapes", false);
+			Tag favorites_tag = db.Tags.CreateTag (null, "Street", false);
 	
-			uint portraits_tag_id = portraits_tag.Id;
-			uint landscapes_tag_id = landscapes_tag.Id;
-			uint favorites_tag_id = favorites_tag.Id;
+			//uint portraits_tag_id = portraits_tag.Id;
+			//uint landscapes_tag_id = landscapes_tag.Id;
+			//uint favorites_tag_id = favorites_tag.Id;
 	
 			Pixbuf unused_thumbnail;
 	
-			Photo ny_landscape = db.Photos.Create ("./pano.jpg", 0, out unused_thumbnail);
-			ny_landscape.Description = "Pretty NY skyline";
+			Photo ny_landscape = db.Photos.Create (UriUtils.PathToFileUri ("../images/pano.jpg"), 0, out unused_thumbnail);
+			ny_landscape.Description = "Snowy landscape";
 			ny_landscape.AddTag (landscapes_tag);
 			ny_landscape.AddTag (favorites_tag);
 			db.Photos.Commit (ny_landscape);
diff --git a/Tests/src/Query/LogicalTerm.cs b/tests/src/Query/LogicalTerm.cs
similarity index 100%
rename from Tests/src/Query/LogicalTerm.cs
rename to tests/src/Query/LogicalTerm.cs
diff --git a/Tests/src/TagStore.cs b/tests/src/TagStore.cs
similarity index 79%
rename from Tests/src/TagStore.cs
rename to tests/src/TagStore.cs
index 4975d51..18c53d1 100644
--- a/Tests/src/TagStore.cs
+++ b/tests/src/TagStore.cs
@@ -1,4 +1,3 @@
-#if ENABLE_NUNIT
 using NUnit.Framework;
 using System;
 using System.IO;
@@ -34,20 +33,20 @@ namespace FSpot.Tests
 		public void InsertCloseAndCheck ()
 		{
 			Category people_category = db.Tags.GetTagByName ("People") as Category;
-			db.Tags.CreateTag (people_category, "Anna");
-			db.Tags.CreateTag (people_category, "Ettore");
-			Tag miggy_tag = db.Tags.CreateTag (people_category, "Miggy");
+			db.Tags.CreateTag (people_category, "Anna", true);
+			db.Tags.CreateTag (people_category, "Ettore", true);
+			Tag miggy_tag = db.Tags.CreateTag (people_category, "Miggy", true);
 			miggy_tag.SortPriority = -1;
 			db.Tags.Commit (miggy_tag);
 	
 			Category places_category = db.Tags.GetTagByName ("Places") as Category;
-			db.Tags.CreateTag (places_category, "Milan");
-			db.Tags.CreateTag (places_category, "Boston");
+			db.Tags.CreateTag (places_category, "Milan", true);
+			db.Tags.CreateTag (places_category, "Boston", true);
 	
-			Category exotic_category = db.Tags.CreateCategory (places_category, "Exotic");
-			db.Tags.CreateTag (exotic_category, "Bengalore");
-			db.Tags.CreateTag (exotic_category, "Manila");
-			Tag tokyo_tag = db.Tags.CreateTag (exotic_category, "Tokyo");
+			Category exotic_category = db.Tags.CreateCategory (places_category, "Exotic", true);
+			db.Tags.CreateTag (exotic_category, "Bengalore", true);
+			db.Tags.CreateTag (exotic_category, "Manila", true);
+			Tag tokyo_tag = db.Tags.CreateTag (exotic_category, "Tokyo", true);
 	
 			tokyo_tag.Category = places_category;
 			tokyo_tag.Name = "Paris";
@@ -80,5 +79,3 @@ namespace FSpot.Tests
 
 	}
 }
-#endif
-
diff --git a/Tests/src/ThumbnailGenerator.cs b/tests/src/ThumbnailGenerator.cs
similarity index 100%
rename from Tests/src/ThumbnailGenerator.cs
rename to tests/src/ThumbnailGenerator.cs



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]