chiark / gitweb /
more automation of test logic
authorRichard Kettlewell <rjk@greenend.org.uk>
Wed, 21 Nov 2007 10:14:54 +0000 (10:14 +0000)
committerRichard Kettlewell <rjk@greenend.org.uk>
Wed, 21 Nov 2007 10:14:54 +0000 (10:14 +0000)
tests/alltests
tests/dtest.py

index 0d216f3d832f9ad8005a5d69574c5f1d087d6010..4e3f64da1a200e3838a164a78b7394dc90788fd8 100755 (executable)
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 # USA
 #
-import sys,re,os.path
+import sys,re,os.path,os
 
 # Parse the makefile in the current directory to identify the source directory
 top_srcdir = None
 for l in file("Makefile"):
-    r = re.match("top_srcdir *= *(.*)",  l)
+    r = re.search("^top_srcdir *= *(.*)$",  l)
     if r:
         top_srcdir = r.group(1)
         break
@@ -32,10 +32,26 @@ if not top_srcdir:
 
 # Make sure that the test directory is on the module search path (so we can
 # find dtest and the tests themselves)
-sys.path.insert(0, os.path.join(top_srcdir, "tests"))
+testdir = os.path.join(top_srcdir, "tests")
+sys.path.insert(0, testdir)
 import dtest
 
-tests = ["nothing", "version"]
+# The tests are all the *.py files in the test source directory that
+# call dtest.run
+tests = []
+for f in os.listdir(testdir):
+    r = re.search("^(.*)\\.py$", f)
+    if r is not None:
+        isTest = False
+        base = r.group(1)
+        for l in file(os.path.join(testdir, f)):
+            r = re.search("dtest\\.run", l)
+            if r is not None:
+                isTest = True
+                break
+        if isTest:
+            tests.append(base)
+tests.sort()                            # let's have a consistent order
 
 for test in tests:
     print "Test '%s'" % test
index b9862f401365d2a2e3d9f57af8b3c23379c43a4b..937d83e017ca5288cf93e65c9bb69e9878b468f8 100644 (file)
@@ -195,7 +195,7 @@ stopword the a an and to too in on of we i am as im for is
 username fred
 password fredpass
 allow fred fredpass
-plugins ../plugins
+plugins %s/plugins
 player *.mp3 execraw disorder-decode
 player *.ogg execraw disorder-decode
 player *.wav execraw disorder-decode
@@ -204,6 +204,6 @@ tracklength *.mp3 disorder-tracklength
 tracklength *.ogg disorder-tracklength
 tracklength *.wav disorder-tracklength
 tracklength *.flac disorder-tracklength
-""" % (testroot, testroot, testroot, testroot))
+""" % (testroot, testroot, testroot, testroot, top_builddir))
 copyfile("%s/sounds/scratch.ogg" % top_srcdir,
          "%s/scratch.ogg" % testroot)