tests/run-tests.py
branchstable
changeset 1237 ac098555f410
parent 1236 b1062bc760a9
child 1238 c2b8e0ffffc8
equal deleted inserted replaced
1236:b1062bc760a9 1237:ac098555f410
   850             if answer.lower() in "y yes".split():
   850             if answer.lower() in "y yes".split():
   851                 if test.endswith(".t"):
   851                 if test.endswith(".t"):
   852                     rename(testpath + ".err", testpath)
   852                     rename(testpath + ".err", testpath)
   853                 else:
   853                 else:
   854                     rename(testpath + ".err", testpath + ".out")
   854                     rename(testpath + ".err", testpath + ".out")
   855                 return 'p', test, ''
   855                 return '.', test, ''
   856         return 'f', test, msg
   856         return '!', test, msg
   857 
   857 
   858     def success():
   858     def success():
   859         return 'p', test, ''
   859         return '.', test, ''
   860 
   860 
   861     def ignore(msg):
   861     def ignore(msg):
   862         return 'i', test, msg
   862         return 'i', test, msg
   863 
   863 
   864     def describe(ret):
   864     def describe(ret):
   935         times.append((test, endtime - starttime))
   935         times.append((test, endtime - starttime))
   936     vlog("# Ret was:", ret)
   936     vlog("# Ret was:", ret)
   937 
   937 
   938     killdaemons()
   938     killdaemons()
   939 
   939 
   940     mark = '.'
       
   941 
       
   942     skipped = (ret == SKIPPED_STATUS)
   940     skipped = (ret == SKIPPED_STATUS)
   943 
   941 
   944     # If we're not in --debug mode and reference output file exists,
   942     # If we're not in --debug mode and reference output file exists,
   945     # check test output against it.
   943     # check test output against it.
   946     if options.debug:
   944     if options.debug:
   958         for line in out:
   956         for line in out:
   959             f.write(line)
   957             f.write(line)
   960         f.close()
   958         f.close()
   961 
   959 
   962     if skipped:
   960     if skipped:
   963         mark = 's'
       
   964         if out is None:                 # debug mode: nothing to parse
   961         if out is None:                 # debug mode: nothing to parse
   965             missing = ['unknown']
   962             missing = ['unknown']
   966             failed = None
   963             failed = None
   967         else:
   964         else:
   968             missing, failed = parsehghaveoutput(out)
   965             missing, failed = parsehghaveoutput(out)
   972             result = fail("hghave failed checking for %s" % failed[-1], ret)
   969             result = fail("hghave failed checking for %s" % failed[-1], ret)
   973             skipped = False
   970             skipped = False
   974         else:
   971         else:
   975             result = skip(missing[-1])
   972             result = skip(missing[-1])
   976     elif ret == 'timeout':
   973     elif ret == 'timeout':
   977         mark = 't'
       
   978         result = fail("timed out", ret)
   974         result = fail("timed out", ret)
   979     elif out != refout:
   975     elif out != refout:
   980         mark = '!'
       
   981         if not options.nodiff:
   976         if not options.nodiff:
   982             iolock.acquire()
   977             iolock.acquire()
   983             if options.view:
   978             if options.view:
   984                 os.system("%s %s %s" % (options.view, ref, err))
   979                 os.system("%s %s %s" % (options.view, ref, err))
   985             else:
   980             else:
   988         if ret:
   983         if ret:
   989             result = fail("output changed and " + describe(ret), ret)
   984             result = fail("output changed and " + describe(ret), ret)
   990         else:
   985         else:
   991             result = fail("output changed", ret)
   986             result = fail("output changed", ret)
   992     elif ret:
   987     elif ret:
   993         mark = '!'
       
   994         result = fail(describe(ret), ret)
   988         result = fail(describe(ret), ret)
   995     else:
   989     else:
   996         result = success()
   990         result = success()
   997 
   991 
   998     if not options.verbose:
   992     if not options.verbose:
   999         iolock.acquire()
   993         iolock.acquire()
  1000         sys.stdout.write(mark)
   994         sys.stdout.write(result[0])
  1001         sys.stdout.flush()
   995         sys.stdout.flush()
  1002         iolock.release()
   996         iolock.release()
  1003 
   997 
  1004     if not options.keep_tmpdir:
   998     if not options.keep_tmpdir:
  1005         shutil.rmtree(testtmp, True)
   999         shutil.rmtree(testtmp, True)
  1114         try:
  1108         try:
  1115             childresults = pickle.load(fp)
  1109             childresults = pickle.load(fp)
  1116         except (pickle.UnpicklingError, EOFError):
  1110         except (pickle.UnpicklingError, EOFError):
  1117             sys.exit(255)
  1111             sys.exit(255)
  1118         else:
  1112         else:
  1119             passed += len(childresults['p'])
  1113             passed += len(childresults['.'])
  1120             skipped += len(childresults['s'])
  1114             skipped += len(childresults['s'])
  1121             failed += len(childresults['f'])
  1115             failed += len(childresults['!'])
  1122             skips.extend(childresults['s'])
  1116             skips.extend(childresults['s'])
  1123             fails.extend(childresults['f'])
  1117             fails.extend(childresults['!'])
  1124         if options.time:
  1118         if options.time:
  1125             childtimes = pickle.load(fp)
  1119             childtimes = pickle.load(fp)
  1126             times.extend(childtimes)
  1120             times.extend(childtimes)
  1127 
  1121 
  1128         vlog('pid %d exited, status %d' % (pid, status))
  1122         vlog('pid %d exited, status %d' % (pid, status))
  1145         outputtimes(options)
  1139         outputtimes(options)
  1146     if options.anycoverage:
  1140     if options.anycoverage:
  1147         outputcoverage(options)
  1141         outputcoverage(options)
  1148     sys.exit(failures != 0)
  1142     sys.exit(failures != 0)
  1149 
  1143 
  1150 results = dict(p=[], f=[], s=[], i=[])
  1144 results = {'.':[], '!':[], 's':[], 'i':[]}
  1151 resultslock = threading.Lock()
  1145 resultslock = threading.Lock()
  1152 times = []
  1146 times = []
  1153 iolock = threading.Lock()
  1147 iolock = threading.Lock()
  1154 
  1148 
  1155 def runqueue(options, tests):
  1149 def runqueue(options, tests):
  1186                 print "running all tests"
  1180                 print "running all tests"
  1187                 tests = orig
  1181                 tests = orig
  1188 
  1182 
  1189         runqueue(options, tests)
  1183         runqueue(options, tests)
  1190 
  1184 
  1191         failed = len(results['f'])
  1185         failed = len(results['!'])
  1192         tested = len(results['p']) + failed
  1186         tested = len(results['.']) + failed
  1193         skipped = len(results['s'])
  1187         skipped = len(results['s'])
  1194         ignored = len(results['i'])
  1188         ignored = len(results['i'])
  1195 
  1189 
  1196         if options.child:
  1190         if options.child:
  1197             fp = os.fdopen(options.child, 'wb')
  1191             fp = os.fdopen(options.child, 'wb')
  1201             fp.close()
  1195             fp.close()
  1202         else:
  1196         else:
  1203             print
  1197             print
  1204             for s in results['s']:
  1198             for s in results['s']:
  1205                 print "Skipped %s: %s" % s
  1199                 print "Skipped %s: %s" % s
  1206             for s in results['f']:
  1200             for s in results['!']:
  1207                 print "Failed %s: %s" % s
  1201                 print "Failed %s: %s" % s
  1208             _checkhglib("Tested")
  1202             _checkhglib("Tested")
  1209             print "# Ran %d tests, %d skipped, %d failed." % (
  1203             print "# Ran %d tests, %d skipped, %d failed." % (
  1210                 tested, skipped + ignored, failed)
  1204                 tested, skipped + ignored, failed)
  1211             if options.time:
  1205             if options.time: