tests/run-tests.py
changeset 21379 ab1a95270a50
parent 21378 f7ac3c63d844
child 21380 de6ea36ca9f7
equal deleted inserted replaced
21378:f7ac3c63d844 21379:ab1a95270a50
   281     for existing destination support.
   281     for existing destination support.
   282     """
   282     """
   283     shutil.copy(src, dst)
   283     shutil.copy(src, dst)
   284     os.remove(src)
   284     os.remove(src)
   285 
   285 
   286 def parsehghaveoutput(lines):
       
   287     '''Parse hghave log lines.
       
   288     Return tuple of lists (missing, failed):
       
   289       * the missing/unknown features
       
   290       * the features for which existence check failed'''
       
   291     missing = []
       
   292     failed = []
       
   293     for line in lines:
       
   294         if line.startswith(SKIPPED_PREFIX):
       
   295             line = line.splitlines()[0]
       
   296             missing.append(line[len(SKIPPED_PREFIX):])
       
   297         elif line.startswith(FAILED_PREFIX):
       
   298             line = line.splitlines()[0]
       
   299             failed.append(line[len(FAILED_PREFIX):])
       
   300 
       
   301     return missing, failed
       
   302 
       
   303 def showdiff(expected, output, ref, err):
   286 def showdiff(expected, output, ref, err):
   304     print
   287     print
   305     servefail = False
   288     servefail = False
   306     for line in difflib.unified_diff(expected, output, ref, err):
   289     for line in difflib.unified_diff(expected, output, ref, err):
   307         sys.stdout.write(line)
   290         sys.stdout.write(line)
   470         if ret == SKIPPED_STATUS:
   453         if ret == SKIPPED_STATUS:
   471             if out is None: # Debug mode, nothing to parse.
   454             if out is None: # Debug mode, nothing to parse.
   472                 missing = ['unknown']
   455                 missing = ['unknown']
   473                 failed = None
   456                 failed = None
   474             else:
   457             else:
   475                 missing, failed = parsehghaveoutput(out)
   458                 missing, failed = TTest.parsehghaveoutput(out)
   476 
   459 
   477             if not missing:
   460             if not missing:
   478                 missing = ['irrelevant']
   461                 missing = ['irrelevant']
   479 
   462 
   480             if failed:
   463             if failed:
   906                 return TTest.globmatch(el[:-8], l)
   889                 return TTest.globmatch(el[:-8], l)
   907             if os.altsep and l.replace('\\', '/') == el:
   890             if os.altsep and l.replace('\\', '/') == el:
   908                 return '+glob'
   891                 return '+glob'
   909         return False
   892         return False
   910 
   893 
       
   894     @staticmethod
       
   895     def parsehghaveoutput(lines):
       
   896         '''Parse hghave log lines.
       
   897 
       
   898         Return tuple of lists (missing, failed):
       
   899           * the missing/unknown features
       
   900           * the features for which existence check failed'''
       
   901         missing = []
       
   902         failed = []
       
   903         for line in lines:
       
   904             if line.startswith(SKIPPED_PREFIX):
       
   905                 line = line.splitlines()[0]
       
   906                 missing.append(line[len(SKIPPED_PREFIX):])
       
   907             elif line.startswith(FAILED_PREFIX):
       
   908                 line = line.splitlines()[0]
       
   909                 failed.append(line[len(FAILED_PREFIX):])
       
   910 
       
   911         return missing, failed
       
   912 
   911 wifexited = getattr(os, "WIFEXITED", lambda x: False)
   913 wifexited = getattr(os, "WIFEXITED", lambda x: False)
   912 def run(cmd, wd, options, replacements, env, abort):
   914 def run(cmd, wd, options, replacements, env, abort):
   913     """Run command in a sub-process, capturing the output (stdout and stderr).
   915     """Run command in a sub-process, capturing the output (stdout and stderr).
   914     Return a tuple (exitcode, output).  output is None in debug mode."""
   916     Return a tuple (exitcode, output).  output is None in debug mode."""
   915     # TODO: Use subprocess.Popen if we're running on Python 2.4
   917     # TODO: Use subprocess.Popen if we're running on Python 2.4