5
5
from pathlib import Path
6
6
from subprocess import CalledProcessError , run
7
7
from sys import stderr
8
+ from time import perf_counter
8
9
from typing import Any
9
10
10
11
ROOT_DIR = Path (__file__ ).parent .parent
@@ -48,6 +49,7 @@ def __init__(
48
49
args : list [str ] = ["latexmk" ],
49
50
env : dict [str , str ] | None = None ,
50
51
) -> None :
52
+ assert directory .exists ()
51
53
self .icon = icon
52
54
self .directory = directory
53
55
self .name = name or directory .name
@@ -57,7 +59,7 @@ def __init__(
57
59
def execute (self ) -> CalledProcessError | None :
58
60
"""Execute the test case."""
59
61
print (f"🟡 Compiling `{ self } `" , file = stderr )
60
- assert self . directory . exists ()
62
+ start = perf_counter ()
61
63
try :
62
64
run (
63
65
self .args ,
@@ -66,11 +68,13 @@ def execute(self) -> CalledProcessError | None:
66
68
env = None if self .env is None else {** environ , ** self .env },
67
69
check = True ,
68
70
)
69
- log (f"✅{ self .icon } 可正常编译 { self .name } 。" )
70
71
except CalledProcessError as error :
71
72
log (f"💥{ self .icon } 无法编译 { self .name } 。" )
72
73
return error
73
74
75
+ duration = perf_counter () - start
76
+ log (f"✅{ self .icon } 可正常编译 { self .name } :⌛ { duration :.1f} 秒。" )
77
+
74
78
75
79
TESTS = [
76
80
TestCase ("📁" , SCAFFOLD_DIR / "undergraduate-thesis" ),
0 commit comments