@@ -131,7 +131,7 @@ def RunSingle(self, parallel, thread_id):
131
131
test = self .sequential_queue .get_nowait ()
132
132
except Empty :
133
133
return
134
- case = test . case
134
+ case = test
135
135
case .thread_id = thread_id
136
136
self .lock .acquire ()
137
137
self .AboutToRun (case )
@@ -780,10 +780,10 @@ def CarCdr(path):
780
780
781
781
782
782
class TestConfiguration (object ):
783
-
784
- def __init__ (self , context , root ):
783
+ def __init__ (self , context , root , section ):
785
784
self .context = context
786
785
self .root = root
786
+ self .section = section
787
787
788
788
def Contains (self , path , file ):
789
789
if len (path ) > len (file ):
@@ -794,7 +794,9 @@ def Contains(self, path, file):
794
794
return True
795
795
796
796
def GetTestStatus (self , sections , defs ):
797
- pass
797
+ status_file = join (self .root , '%s.status' % self .section )
798
+ if exists (status_file ):
799
+ ReadConfigurationInto (status_file , sections , defs )
798
800
799
801
800
802
class TestSuite (object ):
@@ -934,6 +936,7 @@ def RunTestCases(cases_to_run, progress, tasks, flaky_tests_mode):
934
936
# -------------------------------------------
935
937
936
938
939
+ RUN = 'run'
937
940
SKIP = 'skip'
938
941
FAIL = 'fail'
939
942
PASS = 'pass'
@@ -963,8 +966,8 @@ def __init__(self, name):
963
966
self .name = name
964
967
965
968
def GetOutcomes (self , env , defs ):
966
- if self .name in env : return ListSet ([env [self .name ]])
967
- else : return Nothing ()
969
+ if self .name in env : return set ([env [self .name ]])
970
+ else : return set ()
968
971
969
972
970
973
class Outcome (Expression ):
@@ -976,45 +979,7 @@ def GetOutcomes(self, env, defs):
976
979
if self .name in defs :
977
980
return defs [self .name ].GetOutcomes (env , defs )
978
981
else :
979
- return ListSet ([self .name ])
980
-
981
-
982
- class Set (object ):
983
- pass
984
-
985
-
986
- class ListSet (Set ):
987
-
988
- def __init__ (self , elms ):
989
- self .elms = elms
990
-
991
- def __str__ (self ):
992
- return "ListSet%s" % str (self .elms )
993
-
994
- def Intersect (self , that ):
995
- if not isinstance (that , ListSet ):
996
- return that .Intersect (self )
997
- return ListSet ([ x for x in self .elms if x in that .elms ])
998
-
999
- def Union (self , that ):
1000
- if not isinstance (that , ListSet ):
1001
- return that .Union (self )
1002
- return ListSet (self .elms + [ x for x in that .elms if x not in self .elms ])
1003
-
1004
- def IsEmpty (self ):
1005
- return len (self .elms ) == 0
1006
-
1007
-
1008
- class Nothing (Set ):
1009
-
1010
- def Intersect (self , that ):
1011
- return self
1012
-
1013
- def Union (self , that ):
1014
- return that
1015
-
1016
- def IsEmpty (self ):
1017
- return True
982
+ return set ([self .name ])
1018
983
1019
984
1020
985
class Operation (Expression ):
@@ -1030,21 +995,23 @@ def Evaluate(self, env, defs):
1030
995
elif self .op == 'if' :
1031
996
return False
1032
997
elif self .op == '==' :
1033
- inter = self .left .GetOutcomes (env , defs ). Intersect ( self .right .GetOutcomes (env , defs ) )
1034
- return not inter . IsEmpty ( )
998
+ inter = self .left .GetOutcomes (env , defs ) & self .right .GetOutcomes (env , defs )
999
+ return bool ( inter )
1035
1000
else :
1036
1001
assert self .op == '&&'
1037
1002
return self .left .Evaluate (env , defs ) and self .right .Evaluate (env , defs )
1038
1003
1039
1004
def GetOutcomes (self , env , defs ):
1040
1005
if self .op == '||' or self .op == ',' :
1041
- return self .left .GetOutcomes (env , defs ). Union ( self .right .GetOutcomes (env , defs ) )
1006
+ return self .left .GetOutcomes (env , defs ) | self .right .GetOutcomes (env , defs )
1042
1007
elif self .op == 'if' :
1043
- if self .right .Evaluate (env , defs ): return self .left .GetOutcomes (env , defs )
1044
- else : return Nothing ()
1008
+ if self .right .Evaluate (env , defs ):
1009
+ return self .left .GetOutcomes (env , defs )
1010
+ else :
1011
+ return set ()
1045
1012
else :
1046
1013
assert self .op == '&&'
1047
- return self .left .GetOutcomes (env , defs ). Intersect ( self .right .GetOutcomes (env , defs ) )
1014
+ return self .left .GetOutcomes (env , defs ) & self .right .GetOutcomes (env , defs )
1048
1015
1049
1016
1050
1017
def IsAlpha (str ):
@@ -1223,15 +1190,6 @@ def ParseCondition(expr):
1223
1190
return ast
1224
1191
1225
1192
1226
- class ClassifiedTest (object ):
1227
-
1228
- def __init__ (self , case , outcomes ):
1229
- self .case = case
1230
- self .outcomes = outcomes
1231
- self .parallel = self .case .parallel
1232
- self .disable_core_files = self .case .disable_core_files
1233
-
1234
-
1235
1193
class Configuration (object ):
1236
1194
"""The parsed contents of a configuration file"""
1237
1195
@@ -1281,9 +1239,7 @@ def __init__(self, raw_path, path, value):
1281
1239
self .value = value
1282
1240
1283
1241
def GetOutcomes (self , env , defs ):
1284
- set = self .value .GetOutcomes (env , defs )
1285
- assert isinstance (set , ListSet )
1286
- return set .elms
1242
+ return self .value .GetOutcomes (env , defs )
1287
1243
1288
1244
def Contains (self , path ):
1289
1245
if len (self .path ) > len (path ):
@@ -1428,6 +1384,7 @@ def ProcessOptions(options):
1428
1384
options .mode = options .mode .split (',' )
1429
1385
options .run = options .run .split (',' )
1430
1386
options .skip_tests = options .skip_tests .split (',' )
1387
+ options .skip_tests .remove ("" )
1431
1388
if options .run == ["" ]:
1432
1389
options .run = None
1433
1390
elif len (options .run ) != 2 :
@@ -1450,7 +1407,7 @@ def ProcessOptions(options):
1450
1407
# tends to exaggerate the number of available cpus/cores.
1451
1408
cores = os .environ .get ('JOBS' )
1452
1409
options .j = int (cores ) if cores is not None else multiprocessing .cpu_count ()
1453
- if options .flaky_tests not in ["run" , "skip" , "dontcare" ]:
1410
+ if options .flaky_tests not in [RUN , SKIP , DONTCARE ]:
1454
1411
print "Unknown flaky-tests mode %s" % options .flaky_tests
1455
1412
return False
1456
1413
return True
@@ -1464,18 +1421,6 @@ def ProcessOptions(options):
1464
1421
* %(fail)4d tests are expected to fail that we should fix\
1465
1422
"""
1466
1423
1467
- def PrintReport (cases ):
1468
- def IsFailOk (o ):
1469
- return (len (o ) == 2 ) and (FAIL in o ) and (OKAY in o )
1470
- unskipped = [c for c in cases if not SKIP in c .outcomes ]
1471
- print REPORT_TEMPLATE % {
1472
- 'total' : len (cases ),
1473
- 'skipped' : len (cases ) - len (unskipped ),
1474
- 'pass' : len ([t for t in unskipped if list (t .outcomes ) == [PASS ]]),
1475
- 'fail_ok' : len ([t for t in unskipped if IsFailOk (t .outcomes )]),
1476
- 'fail' : len ([t for t in unskipped if list (t .outcomes ) == [FAIL ]])
1477
- }
1478
-
1479
1424
1480
1425
class Pattern (object ):
1481
1426
@@ -1534,6 +1479,14 @@ def FormatTime(d):
1534
1479
return time .strftime ("%M:%S." , time .gmtime (d )) + ("%03i" % millis )
1535
1480
1536
1481
1482
+ def FormatTimedelta (td ):
1483
+ if hasattr (td .total , 'total_seconds' ):
1484
+ d = td .total_seconds ()
1485
+ else : # python2.6 compat
1486
+ d = td .seconds + (td .microseconds / 10.0 ** 6 )
1487
+ return FormatTime (d )
1488
+
1489
+
1537
1490
def PrintCrashed (code ):
1538
1491
if utils .IsWindows ():
1539
1492
return "CRASHED"
@@ -1713,25 +1666,32 @@ def Main():
1713
1666
print "Could not create the temporary directory" , options .temp_dir
1714
1667
sys .exit (1 )
1715
1668
1716
- if options .report :
1717
- PrintReport (all_cases )
1718
-
1719
- result = None
1720
- def DoSkip (case ):
1721
- # A list of tests that should be skipped can be provided. This is
1722
- # useful for tests that fail in some environments, e.g., under coverage.
1723
- if options .skip_tests != ["" ]:
1724
- if [ st for st in options .skip_tests if st in case .case .file ]:
1725
- return True
1726
- if SKIP in case .outcomes or SLOW in case .outcomes :
1669
+ def should_keep (case ):
1670
+ if any ((s in case .file ) for s in options .skip_tests ):
1671
+ return False
1672
+ elif SKIP in case .outcomes :
1673
+ return False
1674
+ elif (options .flaky_tests == SKIP ) and (set ([FLAKY ]) & case .outcomes ):
1675
+ return False
1676
+ else :
1727
1677
return True
1728
- return FLAKY in case .outcomes and options .flaky_tests == SKIP
1729
- cases_to_run = [ c for c in all_cases if not DoSkip (c ) ]
1678
+
1679
+ cases_to_run = filter (should_keep , all_cases )
1680
+
1681
+ if options .report :
1682
+ print (REPORT_TEMPLATE % {
1683
+ 'total' : len (all_cases ),
1684
+ 'skipped' : len (all_cases ) - len (cases_to_run ),
1685
+ 'pass' : len ([t for t in cases_to_run if PASS in t .outcomes ]),
1686
+ 'fail_ok' : len ([t for t in cases_to_run if t .outcomes == set ([FAIL , OKAY ])]),
1687
+ 'fail' : len ([t for t in cases_to_run if t .outcomes == set ([FAIL ])])
1688
+ })
1689
+
1730
1690
if options .run is not None :
1731
1691
# Must ensure the list of tests is sorted before selecting, to avoid
1732
1692
# silent errors if this file is changed to list the tests in a way that
1733
1693
# can be different in different machines
1734
- cases_to_run .sort (key = lambda c : (c .case . arch , c .case . mode , c . case .file ))
1694
+ cases_to_run .sort (key = lambda c : (c .arch , c .mode , c .file ))
1735
1695
cases_to_run = [ cases_to_run [i ] for i
1736
1696
in xrange (options .run [0 ],
1737
1697
len (cases_to_run ),
@@ -1756,13 +1716,11 @@ def DoSkip(case):
1756
1716
# test output.
1757
1717
print
1758
1718
sys .stderr .write ("--- Total time: %s ---\n " % FormatTime (duration ))
1759
- timed_tests = [ t . case for t in cases_to_run if not t . case .duration is None ]
1719
+ timed_tests = [ t for t in cases_to_run if not t .duration is None ]
1760
1720
timed_tests .sort (lambda a , b : a .CompareTime (b ))
1761
- index = 1
1762
- for entry in timed_tests [:20 ]:
1763
- t = FormatTime (entry .duration .total_seconds ())
1764
- sys .stderr .write ("%4i (%s) %s\n " % (index , t , entry .GetLabel ()))
1765
- index += 1
1721
+ for i , entry in enumerate (timed_tests [:20 ], start = 1 ):
1722
+ t = FormatTimedelta (entry .duration )
1723
+ sys .stderr .write ("%4i (%s) %s\n " % (i , t , entry .GetLabel ()))
1766
1724
1767
1725
return result
1768
1726
0 commit comments