@@ -62,12 +62,13 @@ def run(filename, rule_type=RuleType.ALL, with_console_output=False, execution_m
62
62
63
63
# If this is a test file from the repository filter only the relevant scenarios
64
64
feature_filter = []
65
- try :
66
- rule_code = os .path .basename (filename ).split ('-' )[1 ].strip ().upper ()
67
- if re .match (r'[A-Z]{3}[0-9]{3}' , rule_code ):
68
- feature_filter = ["-i" , rule_code ]
69
- except Exception as e :
70
- print (e )
65
+ if execution_mode != ExecutionMode .PRODUCTION :
66
+ bfn = os .path .basename (filename )
67
+ parts = bfn .split ('-' )
68
+ if len (parts ) >= 2 :
69
+ rule_code = parts [1 ].strip ().upper ()
70
+ if re .match (r'[A-Z]{3}[0-9]{3}' , rule_code ):
71
+ feature_filter = ["-i" , rule_code ]
71
72
72
73
if with_console_output :
73
74
# Sometimes it's easier to see what happens exactly on the console output
@@ -81,6 +82,11 @@ def run(filename, rule_type=RuleType.ALL, with_console_output=False, execution_m
81
82
],
82
83
cwd = cwd
83
84
)
85
+
86
+ kwargs = {}
87
+ if execution_mode == ExecutionMode .TESTING :
88
+ # Only capture output in testing mode
89
+ kwargs ['capture_output' ] = True
84
90
85
91
proc = subprocess .run (
86
92
[
@@ -90,8 +96,7 @@ def run(filename, rule_type=RuleType.ALL, with_console_output=False, execution_m
90
96
"--define" , f"execution_mode={ execution_mode } " ,
91
97
"-f" , "json" , "-o" , jsonfn # save to json file
92
98
],
93
- cwd = cwd , capture_output = True
94
- )
99
+ cwd = cwd , ** kwargs )
95
100
96
101
if execution_mode == ExecutionMode .TESTING :
97
102
with open (jsonfn ) as f :
0 commit comments