Show directories in testsuite summary; partially fixes #5024
authorIan Lynagh <igloo@earth.li>
Wed, 15 Jun 2011 20:58:27 +0000 (21:58 +0100)
committerIan Lynagh <igloo@earth.li>
Wed, 15 Jun 2011 20:58:27 +0000 (21:58 +0100)
testsuite/driver/testlib.py

index e87f9bc..1ef04e7 100644 (file)
@@ -646,19 +646,13 @@ def do_test(name, way, func, args):
             else:
                 print '*** unexpected pass for', full_name
                 t.n_unexpected_passes = t.n_unexpected_passes + 1
-                if name in t.unexpected_passes:
-                    t.unexpected_passes[name].append(way)
-                else:
-                    t.unexpected_passes[name] = [way]
+                addTestInfo(t.unexpected_passes, getTestOpts().testdir, name, way)
         else:
             if getTestOpts().expect == 'pass' \
                and way not in getTestOpts().expect_fail_for:
                 print '*** unexpected failure for', full_name
                 t.n_unexpected_failures = t.n_unexpected_failures + 1
-                if name in t.unexpected_failures:
-                    t.unexpected_failures[name].append(way)
-                else:
-                    t.unexpected_failures[name] = [way]
+                addTestInfo(t.unexpected_failures, getTestOpts().testdir, name, way)
             else:
                 t.n_expected_failures = t.n_expected_failures + 1
                 if name in t.expected_failures:
@@ -669,6 +663,17 @@ def do_test(name, way, func, args):
         framework_fail(name, way, 'do_test exception')
         traceback.print_exc()
 
+def addTestInfo (testInfos, directory, name, way):
+    directory = re.sub('^\\.[/\\\\]', '', directory)
+
+    if not directory in testInfos:
+        testInfos[directory] = {}
+
+    if not name in testInfos[directory]:
+        testInfos[directory][name] = []
+
+    testInfos[directory][name].append(way)
+
 def skiptest (name, way):
     # print 'Skipping test \"', name, '\"'
     t.n_tests_skipped = t.n_tests_skipped + 1
@@ -1577,21 +1582,23 @@ def summary(t, file):
 
     if t.n_unexpected_passes > 0:
         file.write('Unexpected passes:\n')
-        keys = t.unexpected_passes.keys()
-        keys.sort()
-        for test in keys:
-            file.write('   ' + test + '(' + \
-                       join(t.unexpected_passes[test],',') + ')\n')
-        file.write('\n')
-            
+        printTestInfosSummary(file, t.unexpected_passes)
+
     if t.n_unexpected_failures > 0:
         file.write('Unexpected failures:\n')
-        keys = t.unexpected_failures.keys()
-        keys.sort()
-        for test in keys:
-            file.write('   ' + test + '(' + \
-                       join(t.unexpected_failures[test],',') + ')\n')
-        file.write('\n')
+        printTestInfosSummary(file, t.unexpected_failures)
+
+def printTestInfosSummary(file, testInfos):
+    directories = testInfos.keys()
+    directories.sort()
+    maxDirLen = max(map ((lambda x : len(x)), directories))
+    for directory in directories:
+        tests = testInfos[directory].keys()
+        tests.sort()
+        for test in tests:
+           file.write('   ' + directory.ljust(maxDirLen + 2) + test + \
+                      ' (' + join(testInfos[directory][test],',') + ')\n')
+    file.write('\n')
 
 def getStdout(cmd):
     if have_subprocess: