1067 if os.path.abspath(actualhg) != os.path.abspath(expecthg): |
1067 if os.path.abspath(actualhg) != os.path.abspath(expecthg): |
1068 sys.stderr.write('warning: %s with unexpected mercurial lib: %s\n' |
1068 sys.stderr.write('warning: %s with unexpected mercurial lib: %s\n' |
1069 ' (expected %s)\n' |
1069 ' (expected %s)\n' |
1070 % (verb, actualhg, expecthg)) |
1070 % (verb, actualhg, expecthg)) |
1071 |
1071 |
1072 def runchildren(options, tests): |
|
1073 if INST: |
|
1074 installhg(options) |
|
1075 _checkhglib("Testing") |
|
1076 else: |
|
1077 usecorrectpython() |
|
1078 |
|
1079 optcopy = dict(options.__dict__) |
|
1080 optcopy['jobs'] = 1 |
|
1081 |
|
1082 # Because whitelist has to override keyword matches, we have to |
|
1083 # actually load the whitelist in the children as well, so we allow |
|
1084 # the list of whitelist files to pass through and be parsed in the |
|
1085 # children, but not the dict of whitelisted tests resulting from |
|
1086 # the parse, used here to override blacklisted tests. |
|
1087 whitelist = optcopy['whitelisted'] or [] |
|
1088 del optcopy['whitelisted'] |
|
1089 |
|
1090 blacklist = optcopy['blacklist'] or [] |
|
1091 del optcopy['blacklist'] |
|
1092 blacklisted = [] |
|
1093 |
|
1094 if optcopy['with_hg'] is None: |
|
1095 optcopy['with_hg'] = os.path.join(BINDIR, "hg") |
|
1096 optcopy.pop('anycoverage', None) |
|
1097 |
|
1098 opts = [] |
|
1099 for opt, value in optcopy.iteritems(): |
|
1100 name = '--' + opt.replace('_', '-') |
|
1101 if value is True: |
|
1102 opts.append(name) |
|
1103 elif isinstance(value, list): |
|
1104 for v in value: |
|
1105 opts.append(name + '=' + str(v)) |
|
1106 elif value is not None: |
|
1107 opts.append(name + '=' + str(value)) |
|
1108 |
|
1109 tests.reverse() |
|
1110 jobs = [[] for j in xrange(options.jobs)] |
|
1111 while tests: |
|
1112 for job in jobs: |
|
1113 if not tests: |
|
1114 break |
|
1115 test = tests.pop() |
|
1116 if test not in whitelist and test in blacklist: |
|
1117 blacklisted.append(test) |
|
1118 else: |
|
1119 job.append(test) |
|
1120 |
|
1121 waitq = queue.Queue() |
|
1122 |
|
1123 # windows lacks os.wait, so we must emulate it |
|
1124 def waitfor(proc, rfd): |
|
1125 fp = os.fdopen(rfd, 'rb') |
|
1126 return lambda: waitq.put((proc.pid, proc.wait(), fp)) |
|
1127 |
|
1128 for j, job in enumerate(jobs): |
|
1129 if not job: |
|
1130 continue |
|
1131 rfd, wfd = os.pipe() |
|
1132 childopts = ['--child=%d' % wfd, '--port=%d' % (options.port + j * 3)] |
|
1133 childtmp = os.path.join(HGTMP, 'child%d' % j) |
|
1134 childopts += ['--tmpdir', childtmp] |
|
1135 if options.keep_tmpdir: |
|
1136 childopts.append('--keep-tmpdir') |
|
1137 cmdline = [PYTHON, sys.argv[0]] + opts + childopts + job |
|
1138 vlog(' '.join(cmdline)) |
|
1139 proc = subprocess.Popen(cmdline, executable=cmdline[0]) |
|
1140 threading.Thread(target=waitfor(proc, rfd)).start() |
|
1141 os.close(wfd) |
|
1142 signal.signal(signal.SIGINT, signal.SIG_IGN) |
|
1143 failures = 0 |
|
1144 passed, skipped, failed = 0, 0, 0 |
|
1145 skips = [] |
|
1146 fails = [] |
|
1147 for job in jobs: |
|
1148 if not job: |
|
1149 continue |
|
1150 pid, status, fp = waitq.get() |
|
1151 try: |
|
1152 childresults = pickle.load(fp) |
|
1153 except (pickle.UnpicklingError, EOFError): |
|
1154 sys.exit(255) |
|
1155 else: |
|
1156 passed += len(childresults['.']) |
|
1157 skipped += len(childresults['s']) |
|
1158 failed += len(childresults['!']) |
|
1159 skips.extend(childresults['s']) |
|
1160 fails.extend(childresults['!']) |
|
1161 if options.time: |
|
1162 childtimes = pickle.load(fp) |
|
1163 times.extend(childtimes) |
|
1164 |
|
1165 vlog('pid %d exited, status %d' % (pid, status)) |
|
1166 failures |= status |
|
1167 print |
|
1168 skipped += len(blacklisted) |
|
1169 if not options.noskips: |
|
1170 for s in skips: |
|
1171 print "Skipped %s: %s" % (s[0], s[1]) |
|
1172 for s in blacklisted: |
|
1173 print "Skipped %s: blacklisted" % s |
|
1174 for s in fails: |
|
1175 print "Failed %s: %s" % (s[0], s[1]) |
|
1176 |
|
1177 _checkhglib("Tested") |
|
1178 print "# Ran %d tests, %d skipped, %d failed." % ( |
|
1179 passed + failed, skipped, failed) |
|
1180 |
|
1181 if options.time: |
|
1182 outputtimes(options) |
|
1183 if options.anycoverage: |
|
1184 outputcoverage(options) |
|
1185 sys.exit(failures != 0) |
|
1186 |
|
1187 results = {'.':[], '!':[], 's':[], 'i':[]} |
1072 results = {'.':[], '!':[], 's':[], 'i':[]} |
1188 resultslock = threading.Lock() |
1073 resultslock = threading.Lock() |
1189 times = [] |
1074 times = [] |
1190 iolock = threading.Lock() |
1075 iolock = threading.Lock() |
1191 abort = False |
1076 abort = False |