Skip to content

Commit c4bb27b

Browse files
test: Record durations
1 parent 7200ebd commit c4bb27b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

scripts/test.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from pathlib import Path
66
from subprocess import CalledProcessError, run
77
from sys import stderr
8+
from time import perf_counter
89
from typing import Any
910

1011
ROOT_DIR = Path(__file__).parent.parent
@@ -48,6 +49,7 @@ def __init__(
4849
args: list[str] = ["latexmk"],
4950
env: dict[str, str] | None = None,
5051
) -> None:
52+
assert directory.exists()
5153
self.icon = icon
5254
self.directory = directory
5355
self.name = name or directory.name
@@ -57,7 +59,7 @@ def __init__(
5759
def execute(self) -> CalledProcessError | None:
5860
"""Execute the test case."""
5961
print(f"🟡 Compiling `{self}`", file=stderr)
60-
assert self.directory.exists()
62+
start = perf_counter()
6163
try:
6264
run(
6365
self.args,
@@ -66,11 +68,13 @@ def execute(self) -> CalledProcessError | None:
6668
env=None if self.env is None else {**environ, **self.env},
6769
check=True,
6870
)
69-
log(f"✅{self.icon} 可正常编译 {self.name}。")
7071
except CalledProcessError as error:
7172
log(f"💥{self.icon} 无法编译 {self.name}。")
7273
return error
7374

75+
duration = perf_counter() - start
76+
log(f"✅{self.icon} 可正常编译 {self.name}:⌛ {duration:.1f} 秒。")
77+
7478

7579
TESTS = [
7680
TestCase("📁", SCAFFOLD_DIR / "undergraduate-thesis"),

0 commit comments

Comments
 (0)