| 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())) |
| 225 | elif not self.isatty: |
| 226 | print() |
| 227 | |
| 228 | def print_(self, msg): |
| 229 | print(msg, end="") |