Commits

Anonymous committed c08cfb2

changes to run_tests_sub.py, now quacks like run_tests.py, output suitable for build page

Comments (0)

Files changed (1)

 sys.path += [test_subdir]
 
 import test_utils
-
 ################################### CONSTANTS ##################################
 
 # If an xxxx_test.py take longer than TIME_OUT seconds it will be killed
 # Any tests in IGNORE will not be ran
 
 IGNORE = (
-    # "scrap_test.py",         # No need to ignore as pygame.init() in another
+    "scrap_test.py",         # No need to ignore as pygame.init() in another
                                # process
 )
 
 
 ################################################################################
 
+DOTS = re.compile("^([FE.]+)$", re.MULTILINE)
+
 TEST_MODULE_RE = re.compile('^(.+_test\.py)$')
 
-NUM_TESTS_RE   = re.compile(r"Ran (\d+) tests?")
-NUM_FAILS_RE   = re.compile(r"failures=(\d+)")
-NUM_ERRORS_RE  = re.compile(r"errors=(\d+)")
-
-def count_of(regex, test_output):
-    count = regex.search(test_output)
-    return count and int(count.group(1)) or 0
-
 ################################################################################
 
 if sys.platform == 'win32':
                     stderr=subprocess.STDOUT, shell = 1,
                 )
             )
-            print '\nUsing subprocess.Popen("%s" '%kill_cmd+'% pid) for os.kill\n'
+            # print '\nUsing subprocess.Popen("%s" '%kill_cmd+'% pid) for os.kill\n'
             break
 
         else: os.kill = None
 ################################################################################
 
 def run_test(cmd):
-    test_name = os.path.basename(cmd)
-    print 'running %s' % test_name
+    test_name = os.path.basename(cmd).split('.')[0]
+    print 'loading %s' % test_name
 
     proc = async_sub.Popen (
         cmd, shell = True, bufsize = -1,
     test_results = pygame.threads.tmap (
         run_test, test_cmds,
         stop_on_error = False,
-        num_workers = len(sys.argv) == 3 and int(sys.argv[2]) or 4
+        num_workers = sys.argv[2:] and int(sys.argv[2]) or 4
     )
 else:
     test_results = map(run_test, test_cmds)
 
 ################################################################################
 
-total_tests = total_fails = total_errors = 0
-
+all_dots = ''
+failures = []
 complete_failures = {}
 
 for module, ret_code, ret in test_results:
-    if ret_code:
+    if ret_code and ret_code is not 1:                  # TODO: ??
         complete_failures[module] = ret_code, ret
         continue
 
-    total_errors += count_of(NUM_ERRORS_RE, ret)
-    total_fails  += count_of(NUM_FAILS_RE,  ret)
-    total_tests  += count_of(NUM_TESTS_RE,  ret)
+    dots = DOTS.search(ret).group(1)
+    all_dots += dots
 
-    print "%s %s" % (module, 'OK' in ret and 'OK' or ret.split(DIV)[0])
+    if 'E' in dots or 'F' in dots:
+        failures.append(ret.split(DIV)[0][ret.index(dots)+len(dots):])
 
+total_fails, total_errors  = all_dots.count('F'), all_dots.count('E')
+total_tests  = len(all_dots)
+
+print all_dots
+print '\n'.join(failures).lstrip('\n')
 print "\n%s %s tests in %.3fs\n" % (DIV, total_tests, t)
 
 if not total_errors and not total_fails:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.