19
19
20
20
import os
21
21
import sys
22
+ import re
22
23
23
24
class NativeLauncherTester :
24
25
@@ -46,16 +47,29 @@ def runLauncherTests ( self, target , source , env ) :
46
47
47
48
if testModuleName in alreadyExecuted : continue
48
49
49
- try :
50
- module = __import__ ( testModuleName )
51
- except ImportError , ie :
52
- print 'Error loading tests for ' , root , ' :: ' , ie
50
+ if self .runSingleTest ( testModuleName , env , item ) :
53
51
testsFailed = True
54
- else :
55
- print 'Running test ' , testModuleName
56
- if not module .runTests ( item .path , env [ 'PLATFORM' ] ) :
57
- print ' Tests failed.'
58
- testsFailed = True
59
52
60
53
alreadyExecuted .append ( testModuleName )
61
54
print
55
+
56
+ for testfile in os .listdir ( 'tests' ) :
57
+ testModuleName = re .sub ( '\.py\Z' , '' , testfile )
58
+ if testModuleName in alreadyExecuted or not re .search ( 'Test\Z' , testModuleName ) : continue
59
+ if self .runSingleTest ( testModuleName , env ) :
60
+ testsFailed = True
61
+
62
+ def runSingleTest ( self , testModuleName , env , item = None ) :
63
+ testFailed = False
64
+ try :
65
+ module = __import__ ( testModuleName )
66
+ except ImportError , ie :
67
+ print 'Error loading test file ' , testModuleName , ' :: ' , ie
68
+ testFailed = True
69
+ else :
70
+ print 'Running test ' , testModuleName
71
+ if not module .runTests ( item .path if item else None , env [ 'PLATFORM' ] ) :
72
+ print ' Tests failed.'
73
+ testsFailed = True
74
+ return testFailed
75
+
0 commit comments