53 import tempfile |
53 import tempfile |
54 import time |
54 import time |
55 import re |
55 import re |
56 import threading |
56 import threading |
57 import killdaemons as killmod |
57 import killdaemons as killmod |
|
58 import cPickle as pickle |
58 |
59 |
59 processlock = threading.Lock() |
60 processlock = threading.Lock() |
60 |
61 |
61 closefds = os.name == 'posix' |
62 closefds = os.name == 'posix' |
62 def Popen4(cmd, wd, timeout): |
63 def Popen4(cmd, wd, timeout): |
1058 vlog(' '.join(cmdline)) |
1059 vlog(' '.join(cmdline)) |
1059 fps[os.spawnvp(os.P_NOWAIT, cmdline[0], cmdline)] = os.fdopen(rfd, 'r') |
1060 fps[os.spawnvp(os.P_NOWAIT, cmdline[0], cmdline)] = os.fdopen(rfd, 'r') |
1060 os.close(wfd) |
1061 os.close(wfd) |
1061 signal.signal(signal.SIGINT, signal.SIG_IGN) |
1062 signal.signal(signal.SIGINT, signal.SIG_IGN) |
1062 failures = 0 |
1063 failures = 0 |
1063 tested, skipped, failed = 0, 0, 0 |
1064 passed, skipped, failed = 0, 0, 0 |
1064 skips = [] |
1065 skips = [] |
1065 fails = [] |
1066 fails = [] |
1066 while fps: |
1067 while fps: |
1067 pid, status = os.wait() |
1068 pid, status = os.wait() |
1068 fp = fps.pop(pid) |
1069 fp = fps.pop(pid) |
1069 l = fp.read().splitlines() |
|
1070 try: |
1070 try: |
1071 test, skip, fail = map(int, l[:3]) |
1071 childresults = pickle.load(fp) |
1072 except ValueError: |
1072 except pickle.UnpicklingError: |
1073 test, skip, fail = 0, 0, 0 |
1073 pass |
1074 split = -fail or len(l) |
1074 else: |
1075 for s in l[3:split]: |
1075 passed += len(childresults['p']) |
1076 skips.append(s.split(" ", 1)) |
1076 skipped += len(childresults['s']) |
1077 for s in l[split:]: |
1077 failed += len(childresults['f']) |
1078 fails.append(s.split(" ", 1)) |
1078 skips.extend(childresults['s']) |
1079 tested += test |
1079 fails.extend(childresults['f']) |
1080 skipped += skip |
1080 |
1081 failed += fail |
|
1082 vlog('pid %d exited, status %d' % (pid, status)) |
1081 vlog('pid %d exited, status %d' % (pid, status)) |
1083 failures |= status |
1082 failures |= status |
1084 print |
1083 print |
1085 skipped += len(blacklisted) |
1084 skipped += len(blacklisted) |
1086 if not options.noskips: |
1085 if not options.noskips: |
1091 for s in fails: |
1090 for s in fails: |
1092 print "Failed %s: %s" % (s[0], s[1]) |
1091 print "Failed %s: %s" % (s[0], s[1]) |
1093 |
1092 |
1094 _checkhglib("Tested") |
1093 _checkhglib("Tested") |
1095 print "# Ran %d tests, %d skipped, %d failed." % ( |
1094 print "# Ran %d tests, %d skipped, %d failed." % ( |
1096 tested, skipped, failed) |
1095 passed + failed, skipped, failed) |
1097 |
1096 |
1098 if options.anycoverage: |
1097 if options.anycoverage: |
1099 outputcoverage(options) |
1098 outputcoverage(options) |
1100 sys.exit(failures != 0) |
1099 sys.exit(failures != 0) |
1101 |
1100 |
1136 skipped = len(results['s']) |
1135 skipped = len(results['s']) |
1137 ignored = len(results['i']) |
1136 ignored = len(results['i']) |
1138 |
1137 |
1139 if options.child: |
1138 if options.child: |
1140 fp = os.fdopen(options.child, 'w') |
1139 fp = os.fdopen(options.child, 'w') |
1141 fp.write('%d\n%d\n%d\n' % (tested, skipped, failed)) |
1140 pickle.dump(results, fp, pickle.HIGHEST_PROTOCOL) |
1142 for s in results['s']: |
|
1143 fp.write("%s %s\n" % s) |
|
1144 for s in results['f']: |
|
1145 fp.write("%s %s\n" % s) |
|
1146 fp.close() |
1141 fp.close() |
1147 else: |
1142 else: |
1148 print |
1143 print |
1149 for s in results['s']: |
1144 for s in results['s']: |
1150 print "Skipped %s: %s" % s |
1145 print "Skipped %s: %s" % s |