Skip to content
This repository has been archived by the owner on Aug 6, 2023. It is now read-only.

Commit

Permalink
Print the total time and test results at the bottom
Browse files Browse the repository at this point in the history
  • Loading branch information
aduerig committed Mar 8, 2023
1 parent 0bb4f5e commit e480e67
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

from tqdm import tqdm

from helpers import *


class TestResult(str, Enum):
PASSED = "PASSED"
Expand Down Expand Up @@ -62,6 +64,7 @@ class TestRun:
TestResult.RUNNER_EXCEPTION: "🐍",
TestResult.TODO_ERROR: "📝",
}
EMOJIS_TO_TEST_RESULT = {v: k for k, v in EMOJIS.items()}

NON_FAIL_RESULTS = [TestResult.PASSED, TestResult.SKIPPED]

Expand Down Expand Up @@ -288,6 +291,7 @@ def __init__(
self.extra_runner_options = extra_runner_options or []
self.update_function: Callable[[int], None] | None = None
self.print_output: Callable[[Optional[Any]], Any] = print
self.emoji_result_counter = Counter()

self.forward_stderr_function: Callable[[str], None] | None
if forward_stderr:
Expand Down Expand Up @@ -316,6 +320,10 @@ def find_tests(self, pattern: str, ignore: str) -> None:
glob.iglob(str(self.test262_root / ignore), recursive=True)
)
for path in glob.iglob(str(self.test262_root / pattern), recursive=True):
import random

if random.random() < 0.99:
continue
found_path = Path(path)
if (
found_path.is_dir()
Expand Down Expand Up @@ -396,6 +404,13 @@ def print_tree(tree, path, level):
for k, v in self.directory_result_map.items():
print_tree(v, k, 0)

test_results_pretty = [
f" {count}: {emoji} ({EMOJIS_TO_TEST_RESULT[emoji]})"
for emoji, count in self.emoji_result_counter.items()
]
print(f"All test results finished in {self.duration}")
print("\n".join(test_results_pretty))

def process_list(self, files: list[Path]) -> list[TestRun]:
if not files:
return []
Expand Down Expand Up @@ -449,12 +464,12 @@ def run(self) -> None:
total=self.total_count, mininterval=1, unit="tests", smoothing=0.1
)

def update_progress(value, new_results, total_stats=Counter()):
def update_progress(value, new_results):
progress_mutex.acquire()
total_stats.update(new_results)
self.emoji_result_counter.update(new_results)
try:
progressbar.update(value)
progressbar.set_postfix(**total_stats)
progressbar.set_postfix(**self.emoji_result_counter)
finally:
progress_mutex.release()

Expand Down

0 comments on commit e480e67

Please sign in to comment.