@@ -68,6 +68,12 @@ def cmp(x, y): # Python 3
68
68
except NameError :
69
69
xrange = range # Python 3
70
70
71
+ try :
72
+ from urllib .parse import unquote # Python 3
73
+ except ImportError :
74
+ from urllib import unquote # Python 2
75
+
76
+
71
77
logger = logging .getLogger ('testrunner' )
72
78
skip_regex = re .compile (r'# SKIP\S*\s+(.*)' , re .IGNORECASE )
73
79
@@ -119,7 +125,7 @@ def Run(self, tasks):
119
125
# Spawn N-1 threads and then use this thread as the last one.
120
126
# That way -j1 avoids threading altogether which is a nice fallback
121
127
# in case of threading problems.
122
- for i in xrange (tasks - 1 ):
128
+ for i in range (tasks - 1 ):
123
129
thread = threading .Thread (target = self .RunSingle , args = [True , i + 1 ])
124
130
threads .append (thread )
125
131
thread .start ()
@@ -755,7 +761,7 @@ def Execute(args, context, timeout=None, env={}, faketty=False, disable_core_fil
755
761
del env_copy ["NODE_PATH" ]
756
762
757
763
# Extend environment
758
- for key , value in env .iteritems ():
764
+ for key , value in env .items ():
759
765
env_copy [key ] = value
760
766
761
767
preexec_fn = None
@@ -808,7 +814,7 @@ def __init__(self, context, root, section):
808
814
def Contains (self , path , file ):
809
815
if len (path ) > len (file ):
810
816
return False
811
- for i in xrange (len (path )):
817
+ for i in range (len (path )):
812
818
if not path [i ].match (NormalizePath (file [i ])):
813
819
return False
814
820
return True
@@ -1263,7 +1269,7 @@ def GetOutcomes(self, env, defs):
1263
1269
def Contains (self , path ):
1264
1270
if len (self .path ) > len (path ):
1265
1271
return False
1266
- for i in xrange (len (self .path )):
1272
+ for i in range (len (self .path )):
1267
1273
if not self .path [i ].match (path [i ]):
1268
1274
return False
1269
1275
return True
@@ -1330,7 +1336,7 @@ def BuildOptions():
1330
1336
help = 'write test output to file. NOTE: this only applies the tap progress indicator' )
1331
1337
result .add_option ("-p" , "--progress" ,
1332
1338
help = "The style of progress indicator (verbose, dots, color, mono, tap)" ,
1333
- choices = PROGRESS_INDICATORS .keys (), default = "mono" )
1339
+ choices = list ( PROGRESS_INDICATORS .keys () ), default = "mono" )
1334
1340
result .add_option ("--report" , help = "Print a summary of the tests to be run" ,
1335
1341
default = False , action = "store_true" )
1336
1342
result .add_option ("-s" , "--suite" , help = "A test suite" ,
@@ -1403,15 +1409,15 @@ def ProcessOptions(options):
1403
1409
options .mode = options .mode .split (',' )
1404
1410
options .run = options .run .split (',' )
1405
1411
# Split at commas and filter out all the empty strings.
1406
- options .skip_tests = filter ( bool , options .skip_tests .split (',' ))
1412
+ options .skip_tests = [ test for test in options .skip_tests .split (',' ) if test ]
1407
1413
if options .run == ["" ]:
1408
1414
options .run = None
1409
1415
elif len (options .run ) != 2 :
1410
1416
print ("The run argument must be two comma-separated integers." )
1411
1417
return False
1412
1418
else :
1413
1419
try :
1414
- options .run = map ( int , options .run )
1420
+ options .run = [ int ( level ) for level in options .run ]
1415
1421
except ValueError :
1416
1422
print ("Could not parse the integers from the run argument." )
1417
1423
return False
@@ -1479,10 +1485,9 @@ def ExpandCommand(args):
1479
1485
return args
1480
1486
return ExpandCommand
1481
1487
else :
1482
- pos = value .find ('@' )
1483
- import urllib
1484
- prefix = urllib .unquote (value [:pos ]).split ()
1485
- suffix = urllib .unquote (value [pos + 1 :]).split ()
1488
+ prefix , _ , suffix = value .partition ('@' )
1489
+ prefix = unquote (prefix ).split ()
1490
+ suffix = unquote (suffix ).split ()
1486
1491
def ExpandCommand (args ):
1487
1492
return prefix + args + suffix
1488
1493
return ExpandCommand
@@ -1531,8 +1536,8 @@ def PrintCrashed(code):
1531
1536
1532
1537
def ArgsToTestPaths (test_root , args , suites ):
1533
1538
if len (args ) == 0 or 'default' in args :
1534
- def_suites = filter ( lambda s : s not in IGNORED_SUITES , suites )
1535
- args = filter ( lambda a : a != 'default' , args ) + def_suites
1539
+ def_suites = [ s for s in suites if s not in IGNORED_SUITES ]
1540
+ args = [ a for a in args if a != 'default' ] + def_suites
1536
1541
subsystem_regex = re .compile (r'^[a-zA-Z-]*$' )
1537
1542
check = lambda arg : subsystem_regex .match (arg ) and (arg not in suites )
1538
1543
mapped_args = ["*/test*-%s-*" % arg if check (arg ) else arg for arg in args ]
@@ -1699,7 +1704,9 @@ def should_keep(case):
1699
1704
else :
1700
1705
return True
1701
1706
1702
- cases_to_run = filter (should_keep , all_cases )
1707
+ cases_to_run = [
1708
+ test_case for test_case in all_cases if should_keep (test_case )
1709
+ ]
1703
1710
1704
1711
if options .report :
1705
1712
print (REPORT_TEMPLATE % {
@@ -1716,7 +1723,7 @@ def should_keep(case):
1716
1723
# can be different in different machines
1717
1724
cases_to_run .sort (key = lambda c : (c .arch , c .mode , c .file ))
1718
1725
cases_to_run = [ cases_to_run [i ] for i
1719
- in xrange (options .run [0 ],
1726
+ in range (options .run [0 ],
1720
1727
len (cases_to_run ),
1721
1728
options .run [1 ]) ]
1722
1729
if len (cases_to_run ) == 0 :
0 commit comments