@@ -230,7 +230,15 @@ def construct_cmd_from_click_api(mode):
230
230
shutil .rmtree (tempdir )
231
231
232
232
233
- def run_all (ok_tests , ok_contexts , ok_graphs , debug , num_parallel , inherit_env ):
233
+ def run_all (
234
+ ok_tests ,
235
+ ok_contexts ,
236
+ ok_graphs ,
237
+ debug ,
238
+ num_parallel ,
239
+ inherit_env ,
240
+ use_chaining_api = False ,
241
+ ):
234
242
235
243
tests = [
236
244
test
@@ -247,17 +255,22 @@ def run_all(ok_tests, ok_contexts, ok_graphs, debug, num_parallel, inherit_env):
247
255
if debug or num_parallel is None :
248
256
for test in tests :
249
257
failed .extend (
250
- run_test_cases ((test , ok_contexts , ok_graphs , debug , base_env ))
258
+ run_test_cases (
259
+ (test , ok_contexts , ok_graphs , debug , base_env , use_chaining_api )
260
+ )
251
261
)
252
262
else :
253
- args = [(test , ok_contexts , ok_graphs , debug , base_env ) for test in tests ]
263
+ args = [
264
+ (test , ok_contexts , ok_graphs , debug , base_env , use_chaining_api )
265
+ for test in tests
266
+ ]
254
267
for fail in Pool (num_parallel ).imap_unordered (run_test_cases , args ):
255
268
failed .extend (fail )
256
269
return failed
257
270
258
271
259
272
def run_test_cases (args ):
260
- test , ok_contexts , ok_graphs , debug , base_env = args
273
+ test , ok_contexts , ok_graphs , debug , base_env , use_chaining_api = args
261
274
contexts = json .load (open ("contexts.json" ))
262
275
graphs = list (iter_graphs ())
263
276
test_name = test .__class__ .__name__
@@ -288,46 +301,40 @@ def run_test_cases(args):
288
301
if enabled_tests and (test_name not in map (str , enabled_tests )):
289
302
continue
290
303
291
- log ("running" , formatter , context )
292
- ret , path = run_test (
304
+ log (
305
+ "running [using chaining api]" if use_chaining_api else "running" ,
293
306
formatter ,
294
307
context ,
295
- debug ,
296
- contexts ["checks" ],
297
- base_env ,
298
308
)
299
-
300
- if ret :
301
- tstid = "%s in context %s" % (formatter , context ["name" ])
302
- failed .append ((tstid , path ))
303
- log ("failed" , formatter , context , real_bad = True )
304
- if debug :
305
- return failed
306
- else :
307
- log ("success" , formatter , context , real_good = True )
308
-
309
- log ("running [with chaining api]" , formatter , context )
310
309
ret , path = run_test (
311
310
formatter ,
312
311
context ,
313
312
debug ,
314
313
contexts ["checks" ],
315
314
base_env ,
316
- use_chaining_api = True ,
315
+ use_chaining_api ,
317
316
)
318
317
319
318
if ret :
320
- tstid = "%s in context %s [with chaining api]" % (
321
- formatter ,
322
- context ["name" ],
319
+ tstid = (
320
+ "%s in context %s [using chaining api]"
321
+ if use_chaining_api
322
+ else "%s in context %s" % (formatter , context ["name" ])
323
323
)
324
324
failed .append ((tstid , path ))
325
- log ("failed [with chaining api]" , formatter , context , real_bad = True )
325
+ log (
326
+ "failed [using chaining api]" if use_chaining_api else "failed" ,
327
+ formatter ,
328
+ context ,
329
+ real_bad = True ,
330
+ )
326
331
if debug :
327
332
return failed
328
333
else :
329
334
log (
330
- "success [with chaining api]" ,
335
+ "success [using chaining api]"
336
+ if use_chaining_api
337
+ else "success" ,
331
338
formatter ,
332
339
context ,
333
340
real_good = True ,
@@ -365,6 +372,12 @@ def run_test_cases(args):
365
372
@click .option (
366
373
"--inherit-env" , is_flag = True , default = False , help = "Inherit env variables"
367
374
)
375
+ @click .option (
376
+ "--use-chaining-api" ,
377
+ is_flag = True ,
378
+ default = False ,
379
+ help = "Use low-level chaining API to generate commands." ,
380
+ )
368
381
@click .option (
369
382
"--num-parallel" ,
370
383
show_default = True ,
@@ -379,6 +392,7 @@ def cli(
379
392
num_parallel = None ,
380
393
debug = False ,
381
394
inherit_env = False ,
395
+ use_chaining_api = False ,
382
396
):
383
397
384
398
parse = lambda x : {t .lower () for t in x .split ("," ) if t }
@@ -390,6 +404,7 @@ def cli(
390
404
debug ,
391
405
num_parallel ,
392
406
inherit_env ,
407
+ use_chaining_api ,
393
408
)
394
409
395
410
if failed :
0 commit comments