tests/run-tests.py
branchstable
changeset 1139 cdabdd17f980
parent 1138 bb419c4bfdd9
child 1143 38b7bb8f1c85
equal deleted inserted replaced
1138:bb419c4bfdd9 1139:cdabdd17f980
   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 splitnewlines(text):
       
   287     '''like str.splitlines, but only split on newlines.
       
   288     keep line endings.'''
       
   289     i = 0
       
   290     lines = []
       
   291     while True:
       
   292         n = text.find('\n', i)
       
   293         if n == -1:
       
   294             last = text[i:]
       
   295             if last:
       
   296                 lines.append(last)
       
   297             return lines
       
   298         lines.append(text[i:n + 1])
       
   299         i = n + 1
       
   300 
       
   301 def parsehghaveoutput(lines):
   286 def parsehghaveoutput(lines):
   302     '''Parse hghave log lines.
   287     '''Parse hghave log lines.
   303     Return tuple of lists (missing, failed):
   288     Return tuple of lists (missing, failed):
   304       * the missing/unknown features
   289       * the missing/unknown features
   305       * the features for which existence check failed'''
   290       * the features for which existence check failed'''
   759     if ret:
   744     if ret:
   760         killdaemons()
   745         killdaemons()
   761 
   746 
   762     for s, r in replacements:
   747     for s, r in replacements:
   763         output = re.sub(s, r, output)
   748         output = re.sub(s, r, output)
   764     return ret, splitnewlines(output)
   749     return ret, output.splitlines(True)
   765 
   750 
   766 def runone(options, test):
   751 def runone(options, test):
   767     '''tristate output:
   752     '''tristate output:
   768     None -> skipped
   753     None -> skipped
   769     True -> passed
   754     True -> passed
   922     # check test output against it.
   907     # check test output against it.
   923     if options.debug:
   908     if options.debug:
   924         refout = None                   # to match "out is None"
   909         refout = None                   # to match "out is None"
   925     elif os.path.exists(ref):
   910     elif os.path.exists(ref):
   926         f = open(ref, "r")
   911         f = open(ref, "r")
   927         refout = list(splitnewlines(f.read()))
   912         refout = f.read().splitlines(True)
   928         f.close()
   913         f.close()
   929     else:
   914     else:
   930         refout = []
   915         refout = []
   931 
   916 
   932     if (ret != 0 or out != refout) and not skipped and not options.debug:
   917     if (ret != 0 or out != refout) and not skipped and not options.debug: