@@ -34,9 +34,12 @@ def find_utc_tool(search_path, utc_name):
34
34
return None
35
35
36
36
37
- def run_utc_tool (utc_name , utc_tool , testname ):
37
+ def run_utc_tool (utc_name , utc_tool , testname , environment ):
38
38
result = subprocess .run (
39
- [utc_tool , testname ], stdout = subprocess .PIPE , stderr = subprocess .PIPE
39
+ [utc_tool , testname ],
40
+ stdout = subprocess .PIPE ,
41
+ stderr = subprocess .PIPE ,
42
+ env = environment ,
40
43
)
41
44
return (result .returncode , result .stdout , result .stderr )
42
45
@@ -60,6 +63,42 @@ def expand_listfile_args(arg_list):
60
63
return exp_arg_list
61
64
62
65
66
+ def utc_lit_plugin (result , test ):
67
+ testname = test .getFilePath ()
68
+ if not testname :
69
+ return None
70
+
71
+ script_name = os .path .abspath (__file__ )
72
+ utc_search_path = os .path .join (os .path .dirname (script_name ), os .path .pardir )
73
+
74
+ with open (testname , "r" ) as f :
75
+ header = f .readline ().strip ()
76
+
77
+ m = RE_ASSERTIONS .search (header )
78
+ if m is None :
79
+ return None
80
+
81
+ utc_name = m .group (1 )
82
+ utc_tool = find_utc_tool ([utc_search_path ], utc_name )
83
+ if not utc_tool :
84
+ return f"update-utc-tests: { utc_name } not found"
85
+
86
+ return_code , stdout , stderr = run_utc_tool (
87
+ utc_name , utc_tool , testname , test .config .environment
88
+ )
89
+
90
+ stderr = stderr .decode (errors = "replace" )
91
+ if return_code != 0 :
92
+ if stderr :
93
+ return f"update-utc-tests: { utc_name } exited with return code { return_code } \n { stderr .rstrip ()} "
94
+ return f"update-utc-tests: { utc_name } exited with return code { return_code } "
95
+
96
+ stdout = stdout .decode (errors = "replace" )
97
+ if stdout :
98
+ return f"update-utc-tests: updated { testname } \n { stdout .rstrip ()} "
99
+ return f"update-utc-tests: updated { testname } "
100
+
101
+
63
102
def main ():
64
103
from argparse import RawTextHelpFormatter
65
104
@@ -78,6 +117,11 @@ def main():
78
117
nargs = "*" ,
79
118
help = "Additional directories to scan for update_*_test_checks scripts" ,
80
119
)
120
+ parser .add_argument (
121
+ "--path" ,
122
+ help = """Additional directories to scan for executables invoked by the update_*_test_checks scripts,
123
+ separated by the platform path separator""" ,
124
+ )
81
125
parser .add_argument ("tests" , nargs = "+" )
82
126
config = parser .parse_args ()
83
127
@@ -88,6 +132,10 @@ def main():
88
132
script_name = os .path .abspath (__file__ )
89
133
utc_search_path .append (os .path .join (os .path .dirname (script_name ), os .path .pardir ))
90
134
135
+ local_env = os .environ .copy ()
136
+ if config .path :
137
+ local_env ["PATH" ] = config .path + os .pathsep + local_env ["PATH" ]
138
+
91
139
not_autogenerated = []
92
140
utc_tools = {}
93
141
have_error = False
@@ -117,7 +165,7 @@ def main():
117
165
continue
118
166
119
167
future = executor .submit (
120
- run_utc_tool , utc_name , utc_tools [utc_name ], testname
168
+ run_utc_tool , utc_name , utc_tools [utc_name ], testname , local_env
121
169
)
122
170
jobs .append ((testname , future ))
123
171
0 commit comments