tests/run-tests.py
changeset 21323 a7c677e2f6ae
parent 21322 512968bfb00a
child 21324 6454ddaee991
equal deleted inserted replaced
21322:512968bfb00a 21323:a7c677e2f6ae
   676         return env
   676         return env
   677 
   677 
   678     def success(self):
   678     def success(self):
   679         return '.', self._test, ''
   679         return '.', self._test, ''
   680 
   680 
       
   681     def fail(self, msg, ret):
       
   682         warned = ret is False
       
   683         if not self._options.nodiff:
       
   684             log("\n%s: %s %s" % (warned and 'Warning' or 'ERROR', self._test,
       
   685                                  msg))
       
   686         if (not ret and self._options.interactive and
       
   687             os.path.exists(self._errpath)):
       
   688             iolock.acquire()
       
   689             print 'Accept this change? [n] ',
       
   690             answer = sys.stdin.readline().strip()
       
   691             iolock.release()
       
   692             if answer.lower() in ('y', 'yes').split():
       
   693                 if self._test.endswith('.t'):
       
   694                     rename(self._errpath, self._testpath)
       
   695                 else:
       
   696                     rename(self._errpath, '%s.out' % self._testpath)
       
   697 
       
   698                 return '.', self._test, ''
       
   699 
       
   700         return warned and '~' or '!', self._test, msg
       
   701 
   681 class TestResult(object):
   702 class TestResult(object):
   682     """Holds the result of a test execution."""
   703     """Holds the result of a test execution."""
   683 
   704 
   684     def __init__(self):
   705     def __init__(self):
   685         self.ret = None
   706         self.ret = None
  1032     def skip(msg):
  1053     def skip(msg):
  1033         if options.verbose:
  1054         if options.verbose:
  1034             log("\nSkipping %s: %s" % (testpath, msg))
  1055             log("\nSkipping %s: %s" % (testpath, msg))
  1035         return 's', test, msg
  1056         return 's', test, msg
  1036 
  1057 
  1037     def fail(msg, ret):
       
  1038         warned = ret is False
       
  1039         if not options.nodiff:
       
  1040             log("\n%s: %s %s" % (warned and 'Warning' or 'ERROR', test, msg))
       
  1041         if (not ret and options.interactive
       
  1042             and os.path.exists(testpath + ".err")):
       
  1043             iolock.acquire()
       
  1044             print "Accept this change? [n] ",
       
  1045             answer = sys.stdin.readline().strip()
       
  1046             iolock.release()
       
  1047             if answer.lower() in "y yes".split():
       
  1048                 if test.endswith(".t"):
       
  1049                     rename(testpath + ".err", testpath)
       
  1050                 else:
       
  1051                     rename(testpath + ".err", testpath + ".out")
       
  1052                 return '.', test, ''
       
  1053         return warned and '~' or '!', test, msg
       
  1054 
       
  1055     def ignore(msg):
  1058     def ignore(msg):
  1056         return 'i', test, msg
  1059         return 'i', test, msg
  1057 
  1060 
  1058     def describe(ret):
  1061     def describe(ret):
  1059         if ret < 0:
  1062         if ret < 0:
  1099     t = runner(test, testpath, options, count, ref, err)
  1102     t = runner(test, testpath, options, count, ref, err)
  1100     res = TestResult()
  1103     res = TestResult()
  1101     t.run(res)
  1104     t.run(res)
  1102 
  1105 
  1103     if res.exception:
  1106     if res.exception:
  1104         return fail('Exception during execution: %s' % res.exception, 255)
  1107         return t.fail('Exception during execution: %s' % res.exception, 255)
  1105 
  1108 
  1106     ret = res.ret
  1109     ret = res.ret
  1107     out = res.out
  1110     out = res.out
  1108 
  1111 
  1109     times.append((test, res.duration))
  1112     times.append((test, res.duration))
  1126         else:
  1129         else:
  1127             missing, failed = parsehghaveoutput(out)
  1130             missing, failed = parsehghaveoutput(out)
  1128         if not missing:
  1131         if not missing:
  1129             missing = ['irrelevant']
  1132             missing = ['irrelevant']
  1130         if failed:
  1133         if failed:
  1131             result = fail("hghave failed checking for %s" % failed[-1], ret)
  1134             result = t.fail("hghave failed checking for %s" % failed[-1], ret)
  1132             skipped = False
  1135             skipped = False
  1133         else:
  1136         else:
  1134             result = skip(missing[-1])
  1137             result = skip(missing[-1])
  1135     elif ret == 'timeout':
  1138     elif ret == 'timeout':
  1136         result = fail("timed out", ret)
  1139         result = t.fail("timed out", ret)
  1137     elif out != refout:
  1140     elif out != refout:
  1138         info = {}
  1141         info = {}
  1139         if not options.nodiff:
  1142         if not options.nodiff:
  1140             iolock.acquire()
  1143             iolock.acquire()
  1141             if options.view:
  1144             if options.view:
  1147         if info.get('servefail'): msg += "serve failed and "
  1150         if info.get('servefail'): msg += "serve failed and "
  1148         if ret:
  1151         if ret:
  1149             msg += "output changed and " + describe(ret)
  1152             msg += "output changed and " + describe(ret)
  1150         else:
  1153         else:
  1151             msg += "output changed"
  1154             msg += "output changed"
  1152         result = fail(msg, ret)
  1155         result = t.fail(msg, ret)
  1153     elif ret:
  1156     elif ret:
  1154         result = fail(describe(ret), ret)
  1157         result = t.fail(describe(ret), ret)
  1155     else:
  1158     else:
  1156         result = t.success()
  1159         result = t.success()
  1157 
  1160 
  1158     if not options.verbose:
  1161     if not options.verbose:
  1159         iolock.acquire()
  1162         iolock.acquire()