2727
2828import test
2929import os
30- from os .path import join , dirname , exists , splitext
3130import re
32- import ast
33-
34- try :
35- reduce
36- except NameError :
37- from functools import reduce
31+ from functools import reduce
3832
3933
4034FLAGS_PATTERN = re .compile (r"//\s+Flags:(.*)" )
41-
35+ LS_RE = re . compile ( r'^test-.*\.m?js$' )
4236
4337class SimpleTestCase (test .TestCase ):
4438
@@ -107,15 +101,15 @@ def __init__(self, context, root, section, additional=None):
107101 self .additional_flags = []
108102
109103 def Ls (self , path ):
110- return [f for f in os .listdir (path ) if re .match ('^test-.*\.m?js$' , f )]
104+ return [f for f in os .listdir (path ) if LS_RE .match (f )]
111105
112106 def ListTests (self , current_path , path , arch , mode ):
113- all_tests = [current_path + [t ] for t in self .Ls (join (self .root ))]
107+ all_tests = [current_path + [t ] for t in self .Ls (os . path . join (self .root ))]
114108 result = []
115- for test in all_tests :
116- if self .Contains (path , test ):
117- file_path = join (self .root , reduce (join , test [1 :], "" ))
118- test_name = test [:- 1 ] + [splitext (test [- 1 ])[0 ]]
109+ for tst in all_tests :
110+ if self .Contains (path , tst ):
111+ file_path = os . path . join (self .root , reduce (os . path . join , tst [1 :], "" ))
112+ test_name = tst [:- 1 ] + [os . path . splitext (tst [- 1 ])[0 ]]
119113 result .append (SimpleTestCase (test_name , file_path , arch , mode ,
120114 self .context , self , self .additional_flags ))
121115 return result
@@ -131,8 +125,8 @@ def __init__(self, context, root, section, additional=None):
131125 def ListTests (self , current_path , path , arch , mode ):
132126 result = super (ParallelTestConfiguration , self ).ListTests (
133127 current_path , path , arch , mode )
134- for test in result :
135- test .parallel = True
128+ for tst in result :
129+ tst .parallel = True
136130 return result
137131
138132class AddonTestConfiguration (SimpleTestConfiguration ):
@@ -145,20 +139,20 @@ def SelectTest(name):
145139
146140 result = []
147141 for subpath in os .listdir (path ):
148- if os .path .isdir (join (path , subpath )):
149- for f in os .listdir (join (path , subpath )):
142+ if os .path .isdir (os . path . join (path , subpath )):
143+ for f in os .listdir (os . path . join (path , subpath )):
150144 if SelectTest (f ):
151145 result .append ([subpath , f [:- 3 ]])
152146 return result
153147
154148 def ListTests (self , current_path , path , arch , mode ):
155- all_tests = [current_path + t for t in self .Ls (join (self .root ))]
149+ all_tests = [current_path + t for t in self .Ls (os . path . join (self .root ))]
156150 result = []
157- for test in all_tests :
158- if self .Contains (path , test ):
159- file_path = join (self .root , reduce (join , test [1 :], "" ) + ".js" )
151+ for tst in all_tests :
152+ if self .Contains (path , tst ):
153+ file_path = os . path . join (self .root , reduce (os . path . join , tst [1 :], "" ) + ".js" )
160154 result .append (
161- SimpleTestCase (test , file_path , arch , mode , self .context , self , self .additional_flags ))
155+ SimpleTestCase (tst , file_path , arch , mode , self .context , self , self .additional_flags ))
162156 return result
163157
164158class AbortTestConfiguration (SimpleTestConfiguration ):
@@ -169,6 +163,6 @@ def __init__(self, context, root, section, additional=None):
169163 def ListTests (self , current_path , path , arch , mode ):
170164 result = super (AbortTestConfiguration , self ).ListTests (
171165 current_path , path , arch , mode )
172- for test in result :
173- test .disable_core_files = True
166+ for tst in result :
167+ tst .disable_core_files = True
174168 return result
0 commit comments