@@ -198,3 +198,35 @@ def task_dummy(depends_on, produces):
198198
199199 session = main ({"paths" : tmp_path })
200200 assert session .exit_code == 0
201+
202+
203+ @pytest .mark .parametrize ("n_failures" , [1 , 2 , 3 ])
204+ def test_execution_stops_after_n_failures (tmp_path , n_failures ):
205+ source = """
206+ def task_1(): raise Exception
207+ def task_2(): raise Exception
208+ def task_3(): raise Exception
209+ """
210+ tmp_path .joinpath ("task_dummy.py" ).write_text (textwrap .dedent (source ))
211+
212+ session = main ({"paths" : tmp_path , "max_failures" : n_failures })
213+
214+ assert len (session .tasks ) == 3
215+ assert len (session .execution_reports ) == n_failures
216+
217+
218+ @pytest .mark .parametrize ("stop_after_first_failure" , [False , True ])
219+ def test_execution_stop_after_first_failure (tmp_path , stop_after_first_failure ):
220+ source = """
221+ def task_1(): raise Exception
222+ def task_2(): raise Exception
223+ def task_3(): raise Exception
224+ """
225+ tmp_path .joinpath ("task_dummy.py" ).write_text (textwrap .dedent (source ))
226+
227+ session = main (
228+ {"paths" : tmp_path , "stop_after_first_failure" : stop_after_first_failure }
229+ )
230+
231+ assert len (session .tasks ) == 3
232+ assert len (session .execution_reports ) == 1 if stop_after_first_failure else 3
0 commit comments