git » libjio » commit cf835d7

tests/behaviour: Allow the user to run a single test

author Alberto Bertogli
2009-04-15 15:43:56 UTC
committer Alberto Bertogli
2009-04-15 15:52:45 UTC
parent d568f22dcd16364f5ff754d7f775111436357076

tests/behaviour: Allow the user to run a single test

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>

tests/behaviour/runtests +7 -2
tests/behaviour/tf.py +5 -1

diff --git a/tests/behaviour/runtests b/tests/behaviour/runtests
index 645a3bf..2860493 100755
--- a/tests/behaviour/runtests
+++ b/tests/behaviour/runtests
@@ -5,7 +5,8 @@ import tf
 
 possible_tests = ('normal', 'corruption', 'fi')
 if len(sys.argv) < 2 or sys.argv[1] not in possible_tests + ('all',):
-	print 'Usage: runtests', '|'.join(possible_tests + ('all',))
+	print 'Usage: runtests', '|'.join(possible_tests + ('all',)),
+	print '[test_name]'
 	sys.exit(1)
 
 if sys.argv[1] == 'all':
@@ -13,7 +14,11 @@ if sys.argv[1] == 'all':
 else:
 	mnames = ('t_' + sys.argv[1],)
 
+specific_test = None
+if len(sys.argv) >= 3:
+	specific_test = sys.argv[2]
+
 for mn in mnames:
 	print '--', mn
-	tf.autorun(__import__(mn))
+	tf.autorun(__import__(mn), specific_test)
 
diff --git a/tests/behaviour/tf.py b/tests/behaviour/tf.py
index 016fd1e..7dbd2eb 100644
--- a/tests/behaviour/tf.py
+++ b/tests/behaviour/tf.py
@@ -216,7 +216,7 @@ def gen_ret_after(n, notyet, itstime):
 	return newf
 
 
-def autorun(module):
+def autorun(module, specific_test = None):
 	"Runs all the functions in the given module that begin with 'test'."
 	for name in sorted(dir(module)):
 		if not name.startswith('test'):
@@ -227,6 +227,10 @@ def autorun(module):
 			name = name[len('test'):]
 			if name.startswith('_'):
 				name = name[1:]
+
+			if specific_test and name != specific_test:
+				continue
+
 			desc = ''
 			if obj.__doc__:
 				desc = obj.__doc__