@@ -78,10 +78,11 @@ class ComplianceTestRunner(object):
78
78
self .tests = tests
79
79
self .jp_executable = exe
80
80
81
- def run_tests (self ):
81
+ def run_tests (self , stop_first_fail ):
82
82
for test_case in self ._test_cases ():
83
83
if self ._should_run (test_case ):
84
- self ._run_test (test_case )
84
+ if not self ._run_test (test_case ) and stop_first_fail :
85
+ return
85
86
86
87
def _should_run (self , test_case ):
87
88
if not self .tests :
@@ -143,17 +144,21 @@ class ComplianceTestRunner(object):
143
144
expected = test_case ['result' ]
144
145
if not actual == expected :
145
146
self ._show_failure (actual , test_case )
147
+ return False
146
148
else :
147
149
sys .stdout .write ('.' )
148
150
sys .stdout .flush ()
151
+ return True
149
152
else :
150
153
error_type = test_case ['error' ]
151
154
# For errors, we expect the error type on stderr.
152
155
if error_type not in stderr :
153
156
self ._show_failure_for_error (stderr , test_case )
157
+ return False
154
158
else :
155
159
sys .stdout .write ('.' )
156
160
sys .stdout .flush ()
161
+ return True
157
162
158
163
def _show_failure (self , actual , test_case ):
159
164
test_case ['actual' ] = json .dumps (actual )
@@ -218,13 +223,15 @@ def main():
218
223
'These values can then be used with the '
219
224
'"-t/--tests" argument. If this argument is '
220
225
'specified, no tests will actually be run.' ))
226
+ parser .add_argument ('-s' , '--stop-first-fail' , action = 'store_true' ,
227
+ help = 'Stop running tests after a single test fails.' )
221
228
args = parser .parse_args ()
222
229
runner = ComplianceTestRunner (args .exe , args .tests )
223
230
if args .list :
224
231
display_available_tests (runner .get_compliance_test_files ())
225
232
else :
226
233
try :
227
- runner .run_tests ()
234
+ runner .run_tests (args . stop_first_fail )
228
235
except Exception , e :
229
236
sys .stderr .write (str (e ))
230
237
sys .stderr .write ("\n " )
0 commit comments