[hyena] Support --enable-tests and 'make test'



commit dd75393c571de84d06c79b86708508bd4ec2efae
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Tue Jan 12 14:51:04 2010 -0800

    Support --enable-tests and 'make test'

 Makefile.am                       |   18 ++++++++++++++++++
 configure.ac                      |   29 +++++++++++++++++++++++++++++
 src/Hyena.Data.Sqlite/Makefile.am |   14 ++++++++++++--
 src/Hyena.Gui/Makefile.am         |   17 ++++++++++++-----
 src/Hyena/Makefile.am             |   14 ++++++++++++--
 5 files changed, 83 insertions(+), 9 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 7f7aad8..e8500a2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -13,3 +13,21 @@ endif
 if ENABLE_WINDOWS
  SUBDIRS =  src/Hyena src/Mono.Data.Sqlite src/Hyena.Data.Sqlite src/Hyena.Gui
 endif
+
+if ENABLE_TESTS
+TEST_ASSEMBLIES = \
+	Hyena.dll \
+	Hyena.Data.Sqlite.dll \
+	Hyena.Gui.dll
+
+ENV_OPTIONS = TZ=America/Chicago LC_ALL=it_IT LANG=it_IT
+RUNNER = for asm in $${TEST_ASSEMBLIES}; do echo -e "\033[1mRunning tests on $${asm}...\033[0m"; $(ENV_OPTIONS) nunit-console2 -nologo -noshadow $$asm; done
+
+test:
+	@pushd bin &>/dev/null; \
+	export TEST_ASSEMBLIES="$(TEST_ASSEMBLIES)"; $(RUNNER); \
+	popd &>/dev/null;
+else
+test:
+	echo "Tests not enabled.  Pass --enable-tests to configure or ./autogen.sh"
+endif
diff --git a/configure.ac b/configure.ac
index f30c633..51896a8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -63,6 +63,34 @@ dnl See if Gtk# is recent enought to enable managed widget a11y
 PKG_CHECK_MODULES(GTKSHARP_A11Y, gtk-sharp-2.0 >= 2.12.10, gtksharp_with_a11y=yes, gtksharp_with_a11y=no)
 AM_CONDITIONAL(ENABLE_ATK, test "x$gtksharp_with_a11y" = "xyes")
 
+dnl Check for nunit
+NUNIT_REQUIRED=2.4.7
+
+AC_ARG_ENABLE(tests, AC_HELP_STRING([--enable-tests], [Enable NUnit tests]),
+    enable_tests=$enableval, enable_tests="no")
+
+if test "x$enable_tests" = "xno"; then
+    do_tests=no
+    AM_CONDITIONAL(ENABLE_TESTS, false)
+else
+    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.4,
+            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
+            AC_MSG_WARN([Could not find nunit: tests will not be available])			fi
+    fi
+fi
+
 dnl package checks, per config
 
 
@@ -82,6 +110,7 @@ cat <<EOF
 
 ${PACKAGE}-${VERSION}
 
+Unit Tests:        ${do_tests} (requires nunit >= ${NUNIT_REQUIRED})
 Custom a11y:       ${gtksharp_with_a11y} (requires gtk-sharp >= 2.12.10)
 
 EOF
diff --git a/src/Hyena.Data.Sqlite/Makefile.am b/src/Hyena.Data.Sqlite/Makefile.am
index 548e15d..6f0b72c 100644
--- a/src/Hyena.Data.Sqlite/Makefile.am
+++ b/src/Hyena.Data.Sqlite/Makefile.am
@@ -3,9 +3,11 @@ EXTRA_DIST =
 
 # Warning: This is an automatically generated file, do not edit!
 
+ASSEMBLY_COMPILER_FLAGS = ""
+
 if ENABLE_DEBUG
 ASSEMBLY_COMPILER_COMMAND = $(MCS)
-ASSEMBLY_COMPILER_FLAGS =  -noconfig -codepage:utf8 -warn:4 -optimize+ -debug -define:DEBUG "-define:NET_2_0"
+ASSEMBLY_COMPILER_FLAGS +=  -noconfig -codepage:utf8 -warn:4 -optimize+ -debug -define:DEBUG "-define:NET_2_0"
 ASSEMBLY = ../../bin/Hyena.Data.Sqlite.dll
 ASSEMBLY_MDB = $(ASSEMBLY).mdb
 COMPILE_TARGET = library
@@ -24,7 +26,7 @@ endif
 
 if ENABLE_WINDOWS
 ASSEMBLY_COMPILER_COMMAND = $(MCS)
-ASSEMBLY_COMPILER_FLAGS =  -noconfig -codepage:utf8 -warn:4 -optimize- -debug -define:DEBUG
+ASSEMBLY_COMPILER_FLAGS +=  -noconfig -codepage:utf8 -warn:4 -optimize- -debug -define:DEBUG
 ASSEMBLY = ../../bin/Hyena.Data.Sqlite.dll
 ASSEMBLY_MDB = $(ASSEMBLY).mdb
 COMPILE_TARGET = library
@@ -41,6 +43,10 @@ HYENA_DATA_SQLITE_DLL_MDB_SOURCE=../../bin/Hyena.Data.Sqlite.dll.mdb
 
 endif
 
+if ENABLE_TESTS
+ASSEMBLY_COMPILER_FLAGS += -define:ENABLE_TESTS
+endif
+
 AL=al2
 SATELLITE_ASSEMBLY_NAME=$(notdir $(basename $(ASSEMBLY))).resources.dll
 
@@ -84,6 +90,10 @@ REFERENCES =  \
 	System.Data \
 	System.Xml
 
+if ENABLE_TESTS
+REFERENCES += $(NUNIT_LIBS)
+endif
+
 DLL_REFERENCES = 
 
 CLEANFILES = $(PROGRAMFILES) $(LINUX_PKGCONFIG) 
diff --git a/src/Hyena.Gui/Makefile.am b/src/Hyena.Gui/Makefile.am
index cde27d2..77cec37 100644
--- a/src/Hyena.Gui/Makefile.am
+++ b/src/Hyena.Gui/Makefile.am
@@ -3,9 +3,11 @@ EXTRA_DIST =
 
 # Warning: This is an automatically generated file, do not edit!
 
+ASSEMBLY_COMPILER_FLAGS = ""
+
 if ENABLE_DEBUG
 ASSEMBLY_COMPILER_COMMAND = $(MCS)
-ASSEMBLY_COMPILER_FLAGS =  -noconfig -codepage:utf8 -unsafe -warn:4 -optimize+ -debug -define:DEBUG "-define:NET_2_0"
+ASSEMBLY_COMPILER_FLAGS +=  -noconfig -codepage:utf8 -unsafe -warn:4 -optimize+ -debug -define:DEBUG "-define:NET_2_0"
 ASSEMBLY = ../../bin/Hyena.Gui.dll
 ASSEMBLY_MDB = $(ASSEMBLY).mdb
 COMPILE_TARGET = library
@@ -16,11 +18,11 @@ BUILD_DIR = ../../bin
 HYENA_DLL_SOURCE=../../bin/Hyena.dll
 HYENA_DLL_MDB_SOURCE=../../bin/Hyena.dll.mdb
 HYENA_GUI_DLL_MDB_SOURCE=../../bin/Hyena.Gui.dll.mdb
+endif
 
-else
 if ENABLE_WINDOWS
 ASSEMBLY_COMPILER_COMMAND = $(MCS)
-ASSEMBLY_COMPILER_FLAGS =  -noconfig -codepage:utf8 -unsafe -warn:4 -optimize- -debug -define:DEBUG
+ASSEMBLY_COMPILER_FLAGS +=  -noconfig -codepage:utf8 -unsafe -warn:4 -optimize- -debug -define:DEBUG
 ASSEMBLY = ../../bin/Hyena.Gui.dll
 ASSEMBLY_MDB = $(ASSEMBLY).mdb
 COMPILE_TARGET = library
@@ -31,9 +33,10 @@ BUILD_DIR = ../../bin
 HYENA_DLL_SOURCE=../../bin/Hyena.dll
 HYENA_DLL_MDB_SOURCE=../../bin/Hyena.dll.mdb
 HYENA_GUI_DLL_MDB_SOURCE=../../bin/Hyena.Gui.dll.mdb
-else
-ASSEMBLY_COMPILER_FLAGS = ""
 endif
+
+if ENABLE_TESTS
+ASSEMBLY_COMPILER_FLAGS += -define:ENABLE_TESTS
 endif
 
 if ENABLE_ATK
@@ -176,6 +179,10 @@ REFERENCES =  \
 	$(GLIB_SHARP_20_LIBS) \
 	System.Xml
 
+if ENABLE_TESTS
+REFERENCES += $(NUNIT_LIBS)
+endif
+
 DLL_REFERENCES = \
 	$(HYENA_DLL)
 
diff --git a/src/Hyena/Makefile.am b/src/Hyena/Makefile.am
index 71121f5..ed9d64d 100644
--- a/src/Hyena/Makefile.am
+++ b/src/Hyena/Makefile.am
@@ -3,9 +3,11 @@ EXTRA_DIST =
 
 # Warning: This is an automatically generated file, do not edit!
 
+ASSEMBLY_COMPILER_FLAGS = ""
+
 if ENABLE_DEBUG
 ASSEMBLY_COMPILER_COMMAND = $(MCS)
-ASSEMBLY_COMPILER_FLAGS =  -noconfig -codepage:utf8 -warn:4 -optimize+ -debug -define:DEBUG "-define:NET_2_0"
+ASSEMBLY_COMPILER_FLAGS +=  -noconfig -codepage:utf8 -warn:4 -optimize+ -debug -define:DEBUG "-define:NET_2_0"
 ASSEMBLY = ../../bin/Hyena.dll
 ASSEMBLY_MDB = $(ASSEMBLY).mdb
 COMPILE_TARGET = library
@@ -18,7 +20,7 @@ endif
 
 if ENABLE_WINDOWS
 ASSEMBLY_COMPILER_COMMAND = $(MCS)
-ASSEMBLY_COMPILER_FLAGS =  -noconfig -codepage:utf8 -warn:4 -optimize- -debug -define:DEBUG
+ASSEMBLY_COMPILER_FLAGS +=  -noconfig -codepage:utf8 -warn:4 -optimize- -debug -define:DEBUG
 ASSEMBLY = ../../bin/Hyena.dll
 ASSEMBLY_MDB = $(ASSEMBLY).mdb
 COMPILE_TARGET = library
@@ -29,6 +31,10 @@ HYENA_DLL_MDB_SOURCE=../../bin/Hyena.dll.mdb
 
 endif
 
+if ENABLE_TESTS
+ASSEMBLY_COMPILER_FLAGS += -define:ENABLE_TESTS
+endif
+
 AL=al2
 SATELLITE_ASSEMBLY_NAME=$(notdir $(basename $(ASSEMBLY))).resources.dll
 
@@ -165,6 +171,10 @@ REFERENCES =  \
 	System.Data \
 	System.Xml
 
+if ENABLE_TESTS
+REFERENCES += $(NUNIT_LIBS)
+endif
+
 DLL_REFERENCES = 
 
 CLEANFILES = $(PROGRAMFILES) $(LINUX_PKGCONFIG) 



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