From e054d7a8e5e069bb6457b7459a9ee1e2b1acfe8e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Radek=20Hu=C5=A1ek?= <husek@iuuk.mff.cuni.cz>
Date: Sun, 23 Jul 2017 11:14:25 +0200
Subject: [PATCH] add test rule to Makefile (& improve test in
 groupConnectivityNaive)

---
 Makefile                  | 6 ++++++
 groupConnectivityNaive.py | 8 +++++---
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index a1430e1..140822a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,7 @@
 default: groupConnectivity.so clean_obj
 
+.PHONY: test
+
 groupConnectivity.so: groupConnectivity.pyx group-connectivity.h setup.py compileTimeOptions.h generateCompileTimeOptions.sh rings.h fast-array.h twoCuts.h parmap.py groupConnectivityNaive.py
 	./generateCompileTimeOptions.sh > options.h
 	python setup.py build_ext
@@ -12,3 +14,7 @@ clean_obj:
 clean: clean_obj
 	rm -f groupConnectivity.so
 
+test: *.py
+	python2 parmap.py
+	python2 groupConnectivityNaive.py
+
diff --git a/groupConnectivityNaive.py b/groupConnectivityNaive.py
index 76b0fa0..8f15d71 100644
--- a/groupConnectivityNaive.py
+++ b/groupConnectivityNaive.py
@@ -151,8 +151,10 @@ def myHistogram(data):
   return s
 
 if __name__ == "__main__":
-    import doctest
-    ret = doctest.testmod()
-    print "%i tests of %i failed." % ret
+  import doctest
+  (f, t) = doctest.testmod()
+  print "%s: %i tests of %i failed." % (__file__, f, t)
+  if f > 0:
+    exit(1)
 
 
-- 
GitLab