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

Class Runner

tools/gyp/test_gyp.py:167–256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

165
166
167class Runner:
168 def __init__(self, formats, tests, gyp_options, verbose):
169 self.formats = formats
170 self.tests = tests
171 self.verbose = verbose
172 self.gyp_options = gyp_options
173 self.failures = []
174 self.num_tests = len(formats) * len(tests)
175 num_digits = len(str(self.num_tests))
176 self.fmt_str = "[%%%dd/%%%dd] (%%s) %%s" % (num_digits, num_digits)
177 self.isatty = sys.stdout.isatty() and not self.verbose
178 self.env = os.environ.copy()
179 self.hpos = 0
180
181 def run(self):
182 run_start = time.time()
183
184 i = 1
185 for fmt in self.formats:
186 for test in self.tests:
187 self.run_test(test, fmt, i)
188 i += 1
189
190 if self.isatty:
191 self.erase_current_line()
192
193 self.took = time.time() - run_start
194
195 def run_test(self, test, fmt, i):
196 if self.isatty:
197 self.erase_current_line()
198
199 msg = self.fmt_str % (i, self.num_tests, fmt, test)
200 self.print_(msg)
201
202 start = time.time()
203 cmd = [sys.executable, test] + self.gyp_options
204 self.env["TESTGYP_FORMAT"] = fmt
205 proc = subprocess.Popen(
206 cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=self.env
207 )
208 proc.wait()
209 took = time.time() - start
210
211 stdout = proc.stdout.read().decode("utf8")
212 if proc.returncode == 2:
213 res = "skipped"
214 elif proc.returncode:
215 res = "failed"
216 self.failures.append(f"({test}) {fmt}")
217 else:
218 res = "passed"
219 res_msg = f" {res} {took:.3f}s"
220 self.print_(res_msg)
221
222 if stdout and not stdout.endswith(("PASSED\n", "NO RESULT\n")):
223 print()
224 print("\n".join(f" {line}" for line in stdout.splitlines()))

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by 1

mainFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…