[PATCH 084 of 179 tests-refactor] run-tests: move parsehghaveoutput() into TTest
Gregory Szorc
gregory.szorc at gmail.com
Fri May 2 13:38:41 CDT 2014
# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1398014065 25200
# Sun Apr 20 10:14:25 2014 -0700
# Branch stable
# Node ID f6820235f603f171f82ba5e1641805ae5b423674
# Parent c943a9f897eeabbc08d82c80fdc134c8e8bc8930
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.
diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -276,33 +276,16 @@ def parseargs(args, parser):
def rename(src, dst):
"""Like os.rename(), trade atomicity and opened files friendliness
for existing destination support.
"""
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
for line in difflib.unified_diff(expected, output, ref, err):
sys.stdout.write(line)
if not servefail and line.startswith(
'+ abort: child process failed to start'):
servefail = True
@@ -465,17 +448,17 @@ class Test(object):
skipped = False
if ret == SKIPPED_STATUS:
if out is None: # Debug mode, nothing to parse.
missing = ['unknown']
failed = None
else:
- missing, failed = parsehghaveoutput(out)
+ missing, failed = TTest.parsehghaveoutput(out)
if not missing:
missing = ['irrelevant']
if failed:
res = self.fail('hg have failed checking for %s' % failed[-1],
ret)
else:
@@ -901,16 +884,35 @@ class TTest(Test):
if el.endswith(" (re)\n"):
return TTest.rematch(el[:-6], l)
if el.endswith(" (glob)\n"):
return TTest.globmatch(el[:-8], l)
if os.altsep and l.replace('\\', '/') == el:
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).
Return a tuple (exitcode, output). output is None in debug mode."""
# TODO: Use subprocess.Popen if we're running on Python 2.4
if options.debug:
proc = subprocess.Popen(cmd, shell=True, cwd=wd, env=env)
ret = proc.wait()
More information about the Mercurial-devel
mailing list