8
8
from datetime import datetime
9
9
from typing import List , cast
10
10
11
+ from .filters import TestFilter
11
12
from .runtime_adapter import RuntimeAdapter
12
13
from .test_case import (
13
14
Result ,
@@ -25,28 +26,52 @@ def run_tests_from_test_suite(
25
26
runtime : RuntimeAdapter ,
26
27
validators : List [Validator ],
27
28
reporters : List [TestReporter ],
29
+ filters : List [TestFilter ],
28
30
) -> TestSuite :
29
31
test_cases : List [TestCase ] = []
30
32
test_start = datetime .now ()
31
33
32
34
_cleanup_test_output (test_suite_path )
33
35
36
+ test_suite_name = _read_manifest (test_suite_path )
37
+
34
38
for test_path in glob .glob (os .path .join (test_suite_path , "*.wasm" )):
35
- test_case = _execute_single_test (runtime , validators , test_path )
39
+ test_name = os .path .splitext (os .path .basename (test_path ))[0 ]
40
+ for filt in filters :
41
+ # for now, just drop the skip reason string. it might be
42
+ # useful to make reporters report it.
43
+ skip , _ = filt .should_skip (test_suite_name , test_name )
44
+ if skip :
45
+ test_case = _skip_single_test (runtime , validators , test_path )
46
+ break
47
+ else :
48
+ test_case = _execute_single_test (runtime , validators , test_path )
36
49
test_cases .append (test_case )
37
50
for reporter in reporters :
38
51
reporter .report_test (test_case )
39
52
40
53
elapsed = (datetime .now () - test_start ).total_seconds ()
41
54
42
55
return TestSuite (
43
- name = _read_manifest ( test_suite_path ) ,
56
+ name = test_suite_name ,
44
57
time = test_start ,
45
58
duration_s = elapsed ,
46
59
test_cases = test_cases ,
47
60
)
48
61
49
62
63
+ def _skip_single_test (
64
+ _runtime : RuntimeAdapter , _validators : List [Validator ], test_path : str
65
+ ) -> TestCase :
66
+ config = _read_test_config (test_path )
67
+ return TestCase (
68
+ name = os .path .splitext (os .path .basename (test_path ))[0 ],
69
+ config = config ,
70
+ result = Result (output = Output (0 , "" , "" ), is_executed = False , failures = []),
71
+ duration_s = 0 ,
72
+ )
73
+
74
+
50
75
def _execute_single_test (
51
76
runtime : RuntimeAdapter , validators : List [Validator ], test_path : str
52
77
) -> TestCase :
0 commit comments