Skip to content

Commit 4303aca

Browse files
committed
tests: updated tests and added unittest for non-int exitcode fails.
1 parent 5af2481 commit 4303aca

1 file changed

Lines changed: 87 additions & 7 deletions

File tree

tests/pipelines/test_pipeline.py

Lines changed: 87 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def test_eval_exit_status_should_pass(pipeline, trace_file):
104104
)
105105
def test_eval_exit_status_should_fail(pipeline, trace_file, caplog):
106106
assert pipeline.evaluate_exit_status(trace_file) is False
107-
assert "WARNING" in caplog.text
107+
assert "ERROR" in caplog.text
108108

109109

110110
@pytest.mark.parametrize(
@@ -165,7 +165,7 @@ def test_eval_exit_status__fail_then_complete_should_pass(
165165
)
166166
def test_eval_exit_status__one_fails(pipeline, trace_file, caplog):
167167
assert pipeline.evaluate_exit_status(trace_file) is False
168-
assert "WARNING" in caplog.text
168+
assert "ERROR" in caplog.text
169169

170170

171171
@pytest.mark.parametrize(
@@ -274,15 +274,15 @@ def test_eval_exit_status_proc_names_completes_invalid_exitcode(
274274
pipeline_proc_names, trace_file, caplog
275275
):
276276
assert pipeline_proc_names.evaluate_exit_status(trace_file) is False
277-
assert "WARNING" in caplog.text
277+
assert "ERROR" in caplog.text
278278

279279

280280
def test_eval_exit_status__entirely_empty_trace_file(
281281
pipeline_proc_names, empty_trace_file, caplog
282282
):
283283
"""Check that entirely empty file returns false and logs warning."""
284284
assert pipeline_proc_names.evaluate_exit_status(empty_trace_file) is False
285-
assert "WARNING" in caplog.text
285+
assert "ERROR" in caplog.text
286286

287287

288288
@pytest.mark.parametrize(
@@ -292,9 +292,11 @@ def test_eval_exit_status__entirely_empty_trace_file(
292292
def test_eval_exit_status__empty_trace_file(
293293
pipeline_proc_names, trace_file, caplog
294294
):
295-
"""Check that file just with header and newline returns false and logs warning."""
295+
"""
296+
Check that file just with header and newline returns false and logs error.
297+
"""
296298
assert pipeline_proc_names.evaluate_exit_status(trace_file) is False
297-
assert "WARNING" in caplog.text
299+
assert "ERROR" in caplog.text
298300

299301

300302
@pytest.mark.parametrize(
@@ -321,7 +323,7 @@ def test_eval_exit_status__empty_rows_then_rows(
321323
Check that a csv with an empty line (with columns though) is handled.
322324
"""
323325
assert pipeline_proc_names.evaluate_exit_status(trace_file) is False
324-
assert "WARNING" in caplog.text
326+
assert "ERROR" in caplog.text
325327

326328

327329
@pytest.mark.parametrize(
@@ -339,4 +341,82 @@ def test_eval_exit_status__bad_exitcodes(
339341
pipeline_proc_names, trace_file, caplog
340342
):
341343
assert pipeline_proc_names.evaluate_exit_status(trace_file) is False
344+
# should get warning about non-int exitcode and error about failing exitcode.
345+
assert "WARNING" in caplog.text
346+
assert "got not a real exitcode" in caplog.text
347+
assert "ERROR" in caplog.text
348+
assert "failed with exit code" in caplog.text
349+
350+
351+
@pytest.mark.parametrize(
352+
"content",
353+
[
354+
(
355+
"1\t82/cac9ec\tnf-82cac7edfcf0128514abf5f17718a8af-b277c\t"
356+
"NFCORE_DEMO:DEMO:FASTQC (SAMPLE1_PE)\tFAILED\t1\t"
357+
"2025-09-24 12:16:37.439\t13.6s\t9s\t164.1%\t526.8 MB\t7.1 GB\t"
358+
"19.5 MB\t4.6 MB\n"
359+
"2\t82/cac9ed\tnf-82cac7edfcf0128514abf5f17718a8af-b277e\t"
360+
"NFCORE_DEMO:DEMO:FASTQC (SAMPLE1_PE)\tCOMPLETED\t5\t"
361+
"2025-09-24 12:17:37.439\t13.6s\t9s\t164.1%\t526.8 MB\t7.1 GB\t"
362+
"19.5 MB\t4.6 MB\n"
363+
"3\t82/cac9ee\tnf-82cac7edfcf0128514abf5f17718a8af-b277e\t"
364+
"NFCORE_DEMO:DEMO:FASTQC (SAMPLE1_PE)\tCOMPLETED\t0\t"
365+
"2025-09-24 12:18:37.439\t13.6s\t9s\t164.1%\t526.8 MB\t7.1 GB\t"
366+
"19.5 MB\t4.6 MB\n"
367+
"4\t83/cacfff\tnf-83cac7edfcf0128514abf5f17718a8af-bffff\t"
368+
"NFCORE_DEMO:DEMO:FASTQC (SAMPLE2_PE)\tFAILED\t-\t"
369+
"2025-09-24 12:20:37.439\t13.6s\t9s\t164.1%\t526.8 MB\t7.1 GB\t"
370+
"19.5 MB\t4.6 MB\n"
371+
),
372+
],
373+
)
374+
def test_eval_exit_status__fails_nonint_exitcode(
375+
pipeline_proc_names, trace_file, caplog
376+
):
377+
"""If one process fails with non-integer exitcode and doesn't complete at
378+
all, it should fail overall."""
379+
assert pipeline_proc_names.evaluate_exit_status(trace_file) is False
380+
# should get warning about non-int exitcode and error about failing exitcode.
381+
assert "WARNING" in caplog.text
382+
assert "got -" in caplog.text
383+
assert "ERROR" in caplog.text
384+
assert "failed with exit code" in caplog.text
385+
386+
387+
@pytest.mark.parametrize(
388+
"content",
389+
[
390+
(
391+
"1\t80/cac7ed\tnf-80cac7edfcf0128514abf5f17718a8af-b277e\t"
392+
"NFCORE_DEMO:DEMO:FASTQC (SAMPLE1_PE)\tCOMPLETED\t0\t"
393+
"2025-09-24 12:17:37.439\t13.6s\t9s\t164.1%\t526.8 MB\t7.1 GB\t"
394+
"19.5 MB\t4.6 MB\n"
395+
"2\t80/cac7ef\tnf-80cac7edfcf0128514abf5f17718a8af-b277f\t"
396+
"NFCORE_DEMO:DEMO:FASTQC (SAMPLE2_PE)\tFAILED\t1\t"
397+
"2025-09-24 12:18:37.440\t13.6s\t9s\t164.1%\t526.8 MB\t7.1 GB\t"
398+
"19.5 MB\t4.6 MB\n"
399+
"3\t80/cac7eg\tnf-80cac7edfcf0128514abf5f17718a8af-b277g\t"
400+
"NFCORE_DEMO:DEMO:FASTQC (SAMPLE2_PE)\tCOMPLETED\t0\t"
401+
"2025-09-24 12:19:37.441\t13.6s\t9s\t164.1%\t526.8 MB\7.1 GB\t"
402+
"19.5 MB\t4.6 MB\n"
403+
"4\t80/cac7eh\tnf-80cac7edfcf0128514abf5f17718a8af-b277h\t"
404+
"NFCORE_DEMO:DEMO:FASTQC (SAMPLE3_PE)\tCOMPLETED\t0\t"
405+
"2025-09-24 12:20:37.442\t13.6s\t9s\t164.1%\t526.8 MB\t7.1 GB\t"
406+
"19.5 MB\t4.6 MB\n"
407+
"5\t80/cac7ex\tnf-80cac7edfcf0128514abf5f17718a8af-b277x\t"
408+
"NFCORE_DEMO:DEMO:FASTQC (SAMPLE4_PE)\tFAILED\t-\t"
409+
"2025-09-24 12:20:37.443\t13.6s\t9s\t164.1%\t526.8 MB\t7.1 GB\t"
410+
"19.5 MB\t4.6 MB\n"
411+
),
412+
],
413+
)
414+
def test_eval_exit_status__one_failswith_noninteger_exitcode(
415+
pipeline, trace_file, caplog
416+
):
417+
assert pipeline.evaluate_exit_status(trace_file) is False
418+
# should get warning about non-int exitcode and error about non-zero exitcode.
419+
assert "WARNING" in caplog.text
420+
assert "got -" in caplog.text
342421
assert "ERROR" in caplog.text
422+
assert "failed with exit code" in caplog.text

0 commit comments

Comments
 (0)