|
1 | 1 |
|
2 | 2 | from concurrent.futures import ThreadPoolExecutor |
| 3 | +from dataclasses import dataclass |
| 4 | +from datetime import timedelta |
3 | 5 | import os |
4 | 6 | import sys |
5 | 7 | import subprocess |
| 8 | +from time import perf_counter |
6 | 9 | from typing import List # , Set, Dict, Tuple, Optional |
7 | 10 |
|
8 | 11 | from tests.util import * |
@@ -200,18 +203,31 @@ def run(self, conf: Config) -> bool: |
200 | 203 | return True |
201 | 204 |
|
202 | 205 |
|
| 206 | +@dataclass |
| 207 | +class TestResult: |
| 208 | + test: Test |
| 209 | + passed: bool |
| 210 | + time: timedelta |
| 211 | + |
| 212 | + |
203 | 213 | def run_tests(conf: Config): |
204 | 214 | if not conf.ignore_requirements: |
205 | 215 | check(conf) |
206 | 216 |
|
207 | 217 | tests = [Test(td) for td in conf.project_dirs] |
208 | 218 |
|
209 | | - def run(tt: Test) -> tuple[Test, bool]: |
210 | | - return tt, tt.run(conf) |
| 219 | + def run(test: Test) -> TestResult: |
| 220 | + start = perf_counter() |
| 221 | + passed = test.run(conf) |
| 222 | + end = perf_counter() |
| 223 | + time = timedelta(seconds=end - start) |
| 224 | + return TestResult(test=test, passed=passed, time=time) |
211 | 225 |
|
212 | 226 | with ThreadPoolExecutor() as executor: |
213 | 227 | results = executor.map(run, tests) |
214 | 228 |
|
215 | | - if not all(result[1] for result in results): |
216 | | - print(f"projects failed: {" ".join(result[0].name for result in results)}") |
| 229 | + for result in results: |
| 230 | + print(f"{result.test.name} took {result.time}") |
| 231 | + if not all(result.passed for result in results): |
| 232 | + print(f"projects failed: {" ".join(result.test.name for result in results)}") |
217 | 233 | exit(1) |
0 commit comments