run-tests: move parsehghaveoutput() into TTest
authorGregory Szorc <gregory.szorc@gmail.com>
Sun, 20 Apr 2014 10:14:25 -0700
changeset 21379 ab1a95270a50
parent 21378 f7ac3c63d844
child 21380 de6ea36ca9f7
run-tests: move parsehghaveoutput() into TTest This patch starts a sequence of patches that will try to isolate everything related to t tests into the TTest class.
tests/run-tests.py
--- a/tests/run-tests.py	Sun Apr 20 10:11:46 2014 -0700
+++ b/tests/run-tests.py	Sun Apr 20 10:14:25 2014 -0700
@@ -283,23 +283,6 @@
     shutil.copy(src, dst)
     os.remove(src)
 
-def parsehghaveoutput(lines):
-    '''Parse hghave log lines.
-    Return tuple of lists (missing, failed):
-      * the missing/unknown features
-      * the features for which existence check failed'''
-    missing = []
-    failed = []
-    for line in lines:
-        if line.startswith(SKIPPED_PREFIX):
-            line = line.splitlines()[0]
-            missing.append(line[len(SKIPPED_PREFIX):])
-        elif line.startswith(FAILED_PREFIX):
-            line = line.splitlines()[0]
-            failed.append(line[len(FAILED_PREFIX):])
-
-    return missing, failed
-
 def showdiff(expected, output, ref, err):
     print
     servefail = False
@@ -472,7 +455,7 @@
                 missing = ['unknown']
                 failed = None
             else:
-                missing, failed = parsehghaveoutput(out)
+                missing, failed = TTest.parsehghaveoutput(out)
 
             if not missing:
                 missing = ['irrelevant']
@@ -908,6 +891,25 @@
                 return '+glob'
         return False
 
+    @staticmethod
+    def parsehghaveoutput(lines):
+        '''Parse hghave log lines.
+
+        Return tuple of lists (missing, failed):
+          * the missing/unknown features
+          * the features for which existence check failed'''
+        missing = []
+        failed = []
+        for line in lines:
+            if line.startswith(SKIPPED_PREFIX):
+                line = line.splitlines()[0]
+                missing.append(line[len(SKIPPED_PREFIX):])
+            elif line.startswith(FAILED_PREFIX):
+                line = line.splitlines()[0]
+                failed.append(line[len(FAILED_PREFIX):])
+
+        return missing, failed
+
 wifexited = getattr(os, "WIFEXITED", lambda x: False)
 def run(cmd, wd, options, replacements, env, abort):
     """Run command in a sub-process, capturing the output (stdout and stderr).