16
16
import os
17
17
import re
18
18
import sys
19
+ import subprocess
19
20
from pathlib import Path
20
21
21
22
from chiptest import AllChipToolYamlTests
22
23
23
24
DEFAULT_CHIP_ROOT = os .path .abspath (
24
25
os .path .join (os .path .dirname (__file__ ), '..' , '..' ))
25
26
26
- # TODO: These tests need to be re-written. Please see https://github.com/project-chip/connectedhomeip/issues/32620
27
- KNOWN_BAD_UNIT_TESTING = set (('Test_TC_S_2_2.yaml' , 'Test_TC_S_2_3.yaml' ))
28
-
29
27
30
28
def _is_cert_test (path ):
31
29
return "certification" in os .path .dirname (path )
32
30
33
31
34
- def main ():
32
+ def check_unit_testing ():
35
33
bad_tests = set ()
36
34
for test in AllChipToolYamlTests (use_short_run_name = False ):
37
35
with open (test .run_name , "r" ) as f :
@@ -47,10 +45,31 @@ def main():
47
45
print (f'\t { line + 1 } : { val } ' )
48
46
bad_tests .add (Path (test .run_name ).name )
49
47
50
- if bad_tests - KNOWN_BAD_UNIT_TESTING :
48
+ if bad_tests :
51
49
return 1
52
50
return 0
53
51
54
52
53
+ def check_manual_steps ():
54
+ # Doing this on a test-by-test basis so the log message is more obvious
55
+ bad_tests = set ()
56
+ for test in AllChipToolYamlTests (use_short_run_name = False ):
57
+ cmd = ['git' , 'diff' , 'HEAD^..HEAD' , '--unified=0' , '--' , test .run_name ]
58
+ output = subprocess .check_output (cmd ).decode ().splitlines ()
59
+ user_prompt_added = [line for line in output if re .search ('^\+.*UserPrompt.*' , line )]
60
+ user_prompt_removed = [line for line in output if re .search ('^\-.*UserPrompt.*' , line )]
61
+ if len (user_prompt_added ) > len (user_prompt_removed ):
62
+ print (f'Found YAML test with additional manual steps: { test .name } ' )
63
+ if bad_tests :
64
+ return 1
65
+ return 0
66
+
67
+
68
+ def main ():
69
+ ret = check_unit_testing ()
70
+ ret += check_manual_steps ()
71
+ return ret
72
+
73
+
55
74
if __name__ == '__main__' :
56
75
sys .exit (main ())
0 commit comments