@@ -370,14 +370,38 @@ def __call__(self, manifest_iter):
370
370
371
371
372
372
class TestLoader (object ):
373
- def __init__ (self , tests_root , metadata_root , test_filter , run_info ):
373
+ def __init__ (self , tests_root , metadata_root , test_types , test_filter , run_info ,
374
+ chunk_type = "none" , total_chunks = 1 , chunk_number = 1 ):
374
375
self .tests_root = tests_root
375
376
self .metadata_root = metadata_root
377
+ self .test_types = test_types
376
378
self .test_filter = test_filter
377
379
self .run_info = run_info
378
380
self .manifest_path = os .path .join (self .metadata_root , "MANIFEST.json" )
379
381
self .manifest = self .load_manifest ()
380
382
self .tests = None
383
+ self .disabled_tests = None
384
+
385
+ self .chunk_type = chunk_type
386
+ self .total_chunks = total_chunks
387
+ self .chunk_number = chunk_number
388
+
389
+ self .chunker = {"none" : Unchunked ,
390
+ "hash" : HashChunker ,
391
+ "equal_time" : EqualTimeChunker }[chunk_type ](total_chunks ,
392
+ chunk_number )
393
+
394
+ self ._test_ids = None
395
+ self ._load_tests ()
396
+
397
+ @property
398
+ def test_ids (self ):
399
+ if self ._test_ids is None :
400
+ self ._test_ids = []
401
+ for test_dict in [self .disabled_tests , self .tests ]:
402
+ for test_type in self .test_types :
403
+ self ._test_ids += [item .id for item in test_dict [test_type ]]
404
+ return self ._test_ids
381
405
382
406
def create_manifest (self ):
383
407
logger .info ("Creating test manifest" )
@@ -401,11 +425,11 @@ def get_test(self, manifest_test, expected_file):
401
425
def load_expected_manifest (self , test_path ):
402
426
return manifestexpected .get_manifest (self .metadata_root , test_path , self .run_info )
403
427
404
- def iter_tests (self , test_types , chunker = None ):
405
- manifest_items = self .test_filter (self .manifest .itertypes (* test_types ))
428
+ def iter_tests (self ):
429
+ manifest_items = self .test_filter (self .manifest .itertypes (* self . test_types ))
406
430
407
- if chunker is not None :
408
- manifest_items = chunker (manifest_items )
431
+ if self . chunker is not None :
432
+ manifest_items = self . chunker (manifest_items )
409
433
410
434
for test_path , tests in manifest_items :
411
435
expected_file = self .load_expected_manifest (test_path )
@@ -414,34 +438,19 @@ def iter_tests(self, test_types, chunker=None):
414
438
test_type = manifest_test .item_type
415
439
yield test_path , test_type , test
416
440
417
- def get_disabled (self , test_types ):
418
- rv = defaultdict (list )
419
-
420
- for test_path , test_type , test in self .iter_tests (test_types ):
421
- if test .disabled ():
422
- rv [test_type ].append (test )
423
-
424
- return rv
425
-
426
- def load_tests (self , test_types , chunk_type , total_chunks , chunk_number ):
441
+ def _load_tests (self ):
427
442
"""Read in the tests from the manifest file and add them to a queue"""
428
- rv = defaultdict (list )
443
+ tests = {"enabled" :defaultdict (list ),
444
+ "disabled" :defaultdict (list )}
429
445
430
- chunker = {"none" : Unchunked ,
431
- "hash" : HashChunker ,
432
- "equal_time" : EqualTimeChunker }[chunk_type ](total_chunks ,
433
- chunk_number )
446
+ for test_path , test_type , test in self .iter_tests ():
447
+ key = "enabled" if not test .disabled () else "disabled"
448
+ tests [key ][test_type ].append (test )
434
449
435
- for test_path , test_type , test in self .iter_tests (test_types , chunker ):
436
- if not test .disabled ():
437
- rv [test_type ].append (test )
438
-
439
- return rv
440
-
441
- def get_groups (self , test_types , chunk_type = "none" , total_chunks = 1 , chunk_number = 1 ):
442
- if self .tests is None :
443
- self .tests = self .load_tests (test_types , chunk_type , total_chunks , chunk_number )
450
+ self .tests = tests ["enabled" ]
451
+ self .disabled_tests = tests ["disabled" ]
444
452
453
+ def groups (self , test_types , chunk_type = "none" , total_chunks = 1 , chunk_number = 1 ):
445
454
groups = set ()
446
455
447
456
for test_type in test_types :
@@ -451,20 +460,14 @@ def get_groups(self, test_types, chunk_type="none", total_chunks=1, chunk_number
451
460
452
461
return groups
453
462
454
- def queue_tests (self , test_types , chunk_type , total_chunks , chunk_number ):
455
- if self .tests is None :
456
- self .tests = self .load_tests (test_types , chunk_type , total_chunks , chunk_number )
457
-
463
+ def queue_tests (self ):
458
464
tests_queue = defaultdict (Queue )
459
- test_ids = []
460
465
461
- for test_type in test_types :
466
+ for test_type in self . test_types :
462
467
for test in self .tests [test_type ]:
463
468
tests_queue [test_type ].put (test )
464
- test_ids .append (test .id )
465
-
466
- return test_ids , tests_queue
467
469
470
+ return tests_queue
468
471
469
472
class LogThread (threading .Thread ):
470
473
def __init__ (self , queue , logger , level ):
@@ -517,18 +520,18 @@ def list_test_groups(tests_root, metadata_root, test_types, product, **kwargs):
517
520
run_info = wpttest .get_run_info (metadata_root , product , debug = False )
518
521
test_filter = TestFilter (include = kwargs ["include" ], exclude = kwargs ["exclude" ],
519
522
manifest_path = kwargs ["include_manifest" ])
520
- test_loader = TestLoader (tests_root , metadata_root , test_filter , run_info )
523
+ test_loader = TestLoader (tests_root , metadata_root , test_types , test_filter , run_info )
521
524
522
- for item in sorted (test_loader .get_groups ( test_types )):
525
+ for item in sorted (test_loader .groups ( )):
523
526
print item
524
527
525
528
526
529
def list_disabled (tests_root , metadata_root , test_types , product , ** kwargs ):
527
530
rv = []
528
531
run_info = wpttest .get_run_info (metadata_root , product , debug = False )
529
- test_loader = TestLoader (tests_root , metadata_root , TestFilter (), run_info )
532
+ test_loader = TestLoader (tests_root , metadata_root , test_types , TestFilter (), run_info )
530
533
531
- for test_type , tests in test_loader .get_disabled ( test_types ) .iteritems ():
534
+ for test_type , tests in test_loader .disabled_tests .iteritems ():
532
535
for test in tests :
533
536
rv .append ({"test" : test .id , "reason" : test .disabled ()})
534
537
print json .dumps (rv , indent = 2 )
@@ -566,9 +569,17 @@ def run_tests(config, tests_root, metadata_root, product, **kwargs):
566
569
if "test_loader" in kwargs :
567
570
test_loader = kwargs ["test_loader" ]
568
571
else :
569
- test_filter = TestFilter (include = kwargs ["include" ], exclude = kwargs ["exclude" ],
572
+ test_filter = TestFilter (include = kwargs ["include" ],
573
+ exclude = kwargs ["exclude" ],
570
574
manifest_path = kwargs ["include_manifest" ])
571
- test_loader = TestLoader (tests_root , metadata_root , test_filter , run_info )
575
+ test_loader = TestLoader (tests_root ,
576
+ metadata_root ,
577
+ kwargs ["test_types" ],
578
+ test_filter ,
579
+ run_info ,
580
+ kwargs ["chunk_type" ],
581
+ kwargs ["total_chunks" ],
582
+ kwargs ["this_chunk" ])
572
583
573
584
logger .info ("Using %i client processes" % kwargs ["processes" ])
574
585
@@ -586,14 +597,17 @@ def run_tests(config, tests_root, metadata_root, product, **kwargs):
586
597
if repeat > 1 :
587
598
logger .info ("Repetition %i / %i" % (repeat_count + 1 , repeat ))
588
599
589
- test_ids , test_queues = test_loader .queue_tests (kwargs ["test_types" ],
590
- kwargs ["chunk_type" ],
591
- kwargs ["total_chunks" ],
592
- kwargs ["this_chunk" ])
600
+ test_queues = test_loader .queue_tests ()
601
+
593
602
unexpected_count = 0
594
- logger .suite_start (test_ids , run_info )
603
+ logger .suite_start (test_loader . test_ids , run_info )
595
604
for test_type in kwargs ["test_types" ]:
596
605
logger .info ("Running %s tests" % test_type )
606
+
607
+ for test in test_loader .disabled_tests [test_type ]:
608
+ logger .test_start (test .id )
609
+ logger .test_end (test .id , status = "SKIP" )
610
+
597
611
tests_queue = test_queues [test_type ]
598
612
599
613
executor_cls = executor_classes .get (test_type )
0 commit comments