33
33
EXIT_TIMEOUT = 120.0
34
34
35
35
36
+ ALL_RESOURCES = ('audio' , 'curses' , 'largefile' , 'network' ,
37
+ 'decimal' , 'cpu' , 'subprocess' , 'urlfetch' , 'gui' , 'walltime' )
38
+
39
+ # Other resources excluded from --use=all:
40
+ #
41
+ # - extralagefile (ex: test_zipfile64): really too slow to be enabled
42
+ # "by default"
43
+ # - tzdata: while needed to validate fully test_datetime, it makes
44
+ # test_datetime too slow (15-20 min on some buildbots) and so is disabled by
45
+ # default (see bpo-30822).
46
+ RESOURCE_NAMES = ALL_RESOURCES + ('extralargefile' , 'tzdata' )
47
+
48
+
36
49
# Types for types hints
37
50
StrPath = str
38
51
TestName = str
@@ -535,6 +548,31 @@ def is_cross_compiled():
535
548
return ('_PYTHON_HOST_PLATFORM' in os .environ )
536
549
537
550
551
+ def format_resources (use_resources : tuple [str , ...]):
552
+ # set preserves insertion order
553
+ use_resources = set (use_resources )
554
+ all_resources = set (ALL_RESOURCES )
555
+
556
+ # Express resources relative to "all"
557
+ relative_all = ['all' ]
558
+ for name in all_resources - use_resources :
559
+ relative_all .append (f'-{ name } ' )
560
+ for name in use_resources - all_resources :
561
+ relative_all .append (f'+{ name } ' )
562
+ all_text = ', ' .join (relative_all )
563
+ all_text = f"resources: { all_text } "
564
+
565
+ # List of enabled resources
566
+ text = ', ' .join (sorted (use_resources ))
567
+ text = f"resources ({ len (use_resources )} ): { text } "
568
+
569
+ # Pick the shortest string (prefer relative to all if lengths are equal)
570
+ if len (all_text ) <= len (text ):
571
+ return all_text
572
+ else :
573
+ return text
574
+
575
+
538
576
def display_header (use_resources : tuple [str , ...],
539
577
python_cmd : tuple [str , ...] | None ):
540
578
# Print basic platform information
@@ -550,14 +588,15 @@ def display_header(use_resources: tuple[str, ...],
550
588
if process_cpu_count and process_cpu_count != cpu_count :
551
589
cpu_count = f"{ process_cpu_count } (process) / { cpu_count } (system)"
552
590
print ("== CPU count:" , cpu_count )
553
- print ("== encodings: locale=%s, FS=%s"
591
+ print ("== encodings: locale=%s FS=%s"
554
592
% (locale .getencoding (), sys .getfilesystemencoding ()))
555
593
556
594
if use_resources :
557
- print ( f"== resources ( { len ( use_resources )} ): "
558
- f" { ', ' . join ( sorted ( use_resources )) } " )
595
+ text = format_resources ( use_resources )
596
+ print ( f"== { text } " )
559
597
else :
560
- print ("== resources: (all disabled, use -u option)" )
598
+ print ("== resources: all test resources are disabled, "
599
+ "use -u option to unskip tests" )
561
600
562
601
cross_compile = is_cross_compiled ()
563
602
if cross_compile :
0 commit comments