@@ -38,11 +38,16 @@ def handle_args(argv):
38
38
type = str ,
39
39
required = True )
40
40
parser .add_argument (
41
- '-c' ,
42
- '--build-system-call' ,
43
- help = 'The call to the used build system.' ,
41
+ '--build-system-args' ,
42
+ help = 'Additional args to pass to the build system through CMake' ,
44
43
type = str ,
45
44
required = True )
45
+ parser .add_argument (
46
+ '--build-dir' ,
47
+ help = 'The name of the build directory to use/create' ,
48
+ type = str ,
49
+ default = 'build' ,
50
+ required = False )
46
51
parser .add_argument (
47
52
'--build-only' ,
48
53
help = 'Whether to perform only a build without any testing.' ,
@@ -104,11 +109,11 @@ def handle_args(argv):
104
109
'together in a single script run.' )
105
110
exit (- 1 )
106
111
107
- return (args .cmake_exe , args .build_system_name , args .build_system_call ,
112
+ return (args .cmake_exe , args .build_system_name , args .build_system_args ,
108
113
full_conformance , test_deprecated_features , args .exclude_categories ,
109
114
args .implementation_name , args .additional_cmake_args , args .device ,
110
115
args .additional_ctest_args , args .build_only , args .run_only ,
111
- commit_hash , full_feature_set )
116
+ commit_hash , full_feature_set , args . build_dir )
112
117
113
118
114
119
def split_additional_args (additional_args ):
@@ -130,7 +135,8 @@ def split_additional_args(additional_args):
130
135
return shlex .split (additional_args , posix = use_posix_mode )
131
136
132
137
133
- def generate_cmake_call (cmake_exe , build_system_name , full_conformance ,
138
+ def generate_cmake_call (cmake_exe , build_dir , build_system_name ,
139
+ full_conformance ,
134
140
test_deprecated_features , exclude_categories ,
135
141
implementation_name , additional_cmake_args , device ,
136
142
full_feature_set ):
@@ -140,7 +146,8 @@ def generate_cmake_call(cmake_exe, build_system_name, full_conformance,
140
146
"""
141
147
call = [
142
148
cmake_exe ,
143
- '..' ,
149
+ '.' ,
150
+ '-B' + build_dir ,
144
151
'-G' + build_system_name ,
145
152
'-DSYCL_CTS_ENABLE_FULL_CONFORMANCE=' + full_conformance ,
146
153
'-DSYCL_CTS_ENABLE_DEPRECATED_FEATURES_TESTS=' + test_deprecated_features ,
@@ -154,17 +161,29 @@ def generate_cmake_call(cmake_exe, build_system_name, full_conformance,
154
161
return call
155
162
156
163
157
- def generate_ctest_call (additional_ctest_args ):
164
+ def generate_ctest_call (build_dir , additional_ctest_args ):
158
165
"""
159
166
Generates a CTest call based on the input in a form accepted by
160
167
subprocess.call().
161
168
"""
162
169
return [
163
- 'ctest' , '.' , '-T' , 'Test' , '--no-compress-output' ,
170
+ 'ctest' , '.' , '--test-dir' , build_dir , '- T' , 'Test' , '--no-compress-output' ,
164
171
'--test-output-size-passed' , '0' , '--test-output-size-failed' , '0'
165
172
] + split_additional_args (additional_ctest_args )
166
173
167
174
175
+ def generate_build_call (cmake_exe , build_dir , build_system_args ):
176
+ """
177
+ Generates a CTest call based on the input in a form accepted by
178
+ subprocess.call().
179
+ """
180
+ build_call = [ cmake_exe , '--build' , build_dir , '--parallel' ]
181
+ build_system_args = split_additional_args (build_system_args )
182
+ if build_system_args :
183
+ build_call .extend (['--' ] + build_system_args )
184
+ return build_call
185
+
186
+
168
187
def subprocess_call (parameter_list ):
169
188
"""
170
189
Calls subprocess.call() with the parameter list.
@@ -174,7 +193,7 @@ def subprocess_call(parameter_list):
174
193
return subprocess .call (parameter_list )
175
194
176
195
177
- def configure_and_run_tests (cmake_call , build_system_call , build_only ,
196
+ def configure_and_run_tests (cmake_call , build_call , build_only ,
178
197
run_only , ctest_call ):
179
198
"""
180
199
Configures the tests with cmake to produce a ninja.build file.
@@ -185,18 +204,17 @@ def configure_and_run_tests(cmake_call, build_system_call, build_only,
185
204
error_code = 0
186
205
187
206
if (not run_only ):
188
- build_system_call = build_system_call .split ()
189
-
190
207
subprocess_call (cmake_call )
191
- error_code = subprocess_call (build_system_call )
208
+
209
+ error_code = subprocess_call (build_call )
192
210
193
211
if (not build_only ):
194
212
error_code = subprocess_call (ctest_call )
195
213
196
214
return error_code
197
215
198
216
199
- def collect_info_filenames ():
217
+ def collect_info_filenames (build_dir ):
200
218
"""
201
219
Collects all the .info test result files in the Testing directory.
202
220
Exits the program if no result files are found.
@@ -205,8 +223,9 @@ def collect_info_filenames():
205
223
info_filenames = []
206
224
207
225
# Get all the test results in Testing
208
- for filename in os .listdir ('Testing' ):
209
- filename_full = os .path .join ('Testing' , filename )
226
+ testing_dir = os .path .join (build_dir , 'Testing' )
227
+ for filename in os .listdir (testing_dir ):
228
+ filename_full = os .path .join (testing_dir , filename )
210
229
if filename .endswith ('.info' ):
211
230
info_filenames .append (filename_full )
212
231
@@ -236,15 +255,15 @@ def get_valid_json_info(info_filenames):
236
255
return json .loads (reference_info )
237
256
238
257
239
- def get_xml_test_results ():
258
+ def get_xml_test_results (build_dir ):
240
259
"""
241
260
Finds the xml file output by the test and returns the rool of the xml tree.
242
261
"""
243
262
test_tag = ""
244
- with open (os .path .join ("Testing" , "TAG" ), 'r' ) as tag_file :
263
+ with open (os .path .join (build_dir , "Testing" , "TAG" ), 'r' ) as tag_file :
245
264
test_tag = tag_file .readline ()[:- 1 ]
246
265
247
- test_xml_file = os .path .join ("Testing" , test_tag , "Test.xml" )
266
+ test_xml_file = os .path .join (build_dir , "Testing" , test_tag , "Test.xml" )
248
267
test_xml_tree = ET .parse (test_xml_file )
249
268
return test_xml_tree .getroot ()
250
269
@@ -283,7 +302,7 @@ def update_xml_attribs(info_json, implementation_name, test_xml_root,
283
302
test_xml_root .attrib ["FullConformanceMode" ] = full_conformance
284
303
test_xml_root .attrib ["CMakeInput" ] = ' ' .join (cmake_call )
285
304
test_xml_root .attrib ["BuildSystemGenerator" ] = build_system_name
286
- test_xml_root .attrib ["BuildSystemCall" ] = build_system_call
305
+ test_xml_root .attrib ["BuildSystemCall" ] = ' ' . join ( build_system_call )
287
306
test_xml_root .attrib ["CTestCall" ] = ' ' .join (ctest_call )
288
307
test_xml_root .attrib ["TestDeprecatedFeatures" ] = test_deprecated_features
289
308
test_xml_root .attrib ["FullFeatureSet" ] = full_feature_set
@@ -294,57 +313,58 @@ def update_xml_attribs(info_json, implementation_name, test_xml_root,
294
313
def main (argv = sys .argv [1 :]):
295
314
296
315
# Parse and gather all the script args
297
- (cmake_exe , build_system_name , build_system_call , full_conformance ,
316
+ (cmake_exe , build_system_name , build_system_args , full_conformance ,
298
317
test_deprecated_features , exclude_categories , implementation_name ,
299
- additional_cmake_args , device , additional_ctest_args ,
300
- build_only , run_only , commit_hash , full_feature_set ) = handle_args (argv )
318
+ additional_cmake_args , device , additional_ctest_args , build_only , run_only ,
319
+ commit_hash , full_feature_set , build_dir ) = handle_args (argv )
301
320
302
321
# Generate a cmake call in a form accepted by subprocess.call()
303
- cmake_call = generate_cmake_call (cmake_exe , build_system_name ,
322
+ cmake_call = generate_cmake_call (cmake_exe , build_dir , build_system_name ,
304
323
full_conformance , test_deprecated_features ,
305
324
exclude_categories , implementation_name ,
306
325
additional_cmake_args , device ,
307
326
full_feature_set )
308
327
309
328
# Generate a CTest call in a form accepted by subprocess.call()
310
- ctest_call = generate_ctest_call (additional_ctest_args )
329
+ ctest_call = generate_ctest_call (build_dir , additional_ctest_args )
311
330
312
- # Make a build directory if required and enter it
313
- if not os .path .isdir ('build' ):
314
- os .mkdir ('build' )
315
- os .chdir ('build' )
331
+ build_call = generate_build_call (cmake_exe , build_dir , build_system_args )
316
332
317
333
# Configure the build system with cmake, run the build, and run the tests.
318
- error_code = configure_and_run_tests (cmake_call , build_system_call ,
319
- build_only , run_only , ctest_call )
334
+ error_code = configure_and_run_tests (cmake_call , build_call , build_only ,
335
+ run_only , ctest_call )
320
336
321
337
if build_only :
322
338
return error_code
323
339
324
340
# Collect the test info files, validate them and get the contents as json.
325
- info_filenames = collect_info_filenames ()
341
+ info_filenames = collect_info_filenames (build_dir )
326
342
info_json = get_valid_json_info (info_filenames )
327
343
328
344
# Get the xml results and update with the necessary information.
329
- result_xml_root = get_xml_test_results ()
345
+ result_xml_root = get_xml_test_results (build_dir )
330
346
result_xml_root = update_xml_attribs (info_json , implementation_name ,
331
347
result_xml_root , full_conformance ,
332
348
cmake_call , build_system_name ,
333
- build_system_call , ctest_call ,
349
+ build_call , ctest_call ,
334
350
test_deprecated_features ,
335
351
commit_hash ,
336
352
full_feature_set )
337
353
338
354
# Get the xml report stylesheet and add it to the results.
339
- stylesheet_xml_file = os .path .join (".." , "tools" , "stylesheet.xml" )
355
+ stylesheet_xml_file = os .path .join (
356
+ os .path .abspath (os .path .dirname (__file__ )), "tools" , "stylesheet.xml"
357
+ )
340
358
stylesheet_xml_tree = ET .parse (stylesheet_xml_file )
341
359
stylesheet_xml_root = stylesheet_xml_tree .getroot ()
342
360
result_xml_root .append (stylesheet_xml_root [0 ])
343
361
344
362
# Get the xml results as a string and append them to the report header.
345
363
report = REPORT_HEADER + ET .tostring (result_xml_root ).decode ("utf-8" )
346
364
347
- with open ("conformance_report.xml" , 'w' ) as final_conformance_report :
365
+ with open (
366
+ os .path .join (build_dir , "conformance_report.xml" ), "w"
367
+ ) as final_conformance_report :
348
368
final_conformance_report .write (report )
349
369
350
370
return error_code
0 commit comments