MCPcopy Index your code
hub / github.com/nodejs/node / RunSingle

Method RunSingle

tools/test.py:181–239  ·  view source on GitHub ↗
(self, parallel, thread_id)

Source from the content-addressed store, hash-verified

179 }
180
181 def RunSingle(self, parallel, thread_id):
182 while not self.shutdown_event.is_set():
183 try:
184 test = self.parallel_queue.get_nowait()
185 except Empty:
186 if parallel:
187 return
188 try:
189 test = self.sequential_queue.get_nowait()
190 except Empty:
191 return
192 case = test
193 case.thread_id = thread_id
194 self.lock.acquire()
195 case.serial_id = self.serial_id
196 self.serial_id += 1
197 self.AboutToRun(case)
198 self.lock.release()
199 try:
200 start = datetime.now()
201 output = case.Run()
202 # SmartOS has a bug that causes unexpected ECONNREFUSED errors.
203 # See https://smartos.org/bugview/OS-2767
204 # If ECONNREFUSED on SmartOS, retry the test one time.
205 if (output.UnexpectedOutput() and
206 sys.platform == 'sunos5' and
207 'ECONNREFUSED' in output.output.stderr):
208 output = case.Run()
209 output.diagnostic.append('ECONNREFUSED received, test retried')
210 case.duration = (datetime.now() - start)
211 except IOError:
212 return
213 if self.shutdown_event.is_set():
214 return
215 self.lock.acquire()
216 if output.UnexpectedOutput():
217 if FLAKY in output.test.outcomes and self.flaky_tests_mode == DONTCARE:
218 self.flaky_failed.append(output)
219 elif FLAKY in output.test.outcomes and self.flaky_tests_mode == KEEP_RETRYING:
220 for _ in range(99):
221 if not case.Run().UnexpectedOutput():
222 self.flaky_failed.append(output)
223 break
224 else:
225 # If after 100 tries, the test is not passing, it's not flaky.
226 self.failed.append(output)
227 else:
228 self.failed.append(output)
229 if output.HasCrashed():
230 self.crashed += 1
231 if self.measure_flakiness:
232 outputs = [case.Run() for _ in range(self.measure_flakiness)]
233 # +1s are there because the test already failed once at this point.
234 print(" failed %d out of %d" % (len([i for i in outputs if i.UnexpectedOutput()]) + 1, self.measure_flakiness + 1))
235 else:
236 self.succeeded += 1
237 self.remaining -= 1
238 self.HasRun(output)

Callers 1

RunMethod · 0.95

Calls 11

acquireMethod · 0.80
releaseMethod · 0.80
nowMethod · 0.80
UnexpectedOutputMethod · 0.80
rangeFunction · 0.50
printFunction · 0.50
AboutToRunMethod · 0.45
RunMethod · 0.45
appendMethod · 0.45
HasCrashedMethod · 0.45
HasRunMethod · 0.45

Tested by

no test coverage detected