Repository: LUMC/pytest-workflow (language: python)

Issue:
Add test parametrization. Document code, add integration tests.
This defines the final structure of the plugin.
It provides comments on how to implement further testing.
Everything has integration tests that run on travis. Code quality is checked on codacy.
Also linting is done using flake.

Next up (so no complaints allowed about it not being here! ;-) ):
- Implementing some need to have features (md5sum checking, file content checking, stdout and stderr checking).
- User side documentation
- Specific WDL/Cromwell workflow testing.
- Specific Snakemake testing (not by me)



Discussion / hints:

Fix patch:
diff --git a/HISTORY.rst b/HISTORY.rst
index 0d72de4b..5d0a4804 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -9,6 +9,7 @@ Changelog
 
 version 1.7.0-dev
 ---------------------------
++ Add tests for nextflow.
 + Document the use of environment variables with pytest-workflow.
 + A minimum of pytest 7.0.0 is now a requirement for pytest-workflow.
   This fixes the deprecation warnings that started on the release of pytest
diff --git a/tox.ini b/tox.ini
index 6b75d6c2..23638e3e 100644
--- a/tox.ini
+++ b/tox.ini
@@ -59,3 +59,10 @@ commands =
 deps=miniwdl
 commands=
     python -m pytest tests/functional/test_functional.py::test_miniwdl
+    
+[testenv:nextflow]
+# Empty deps. Otherwise deps from default testenv are used.
+deps=
+commands =
+    python -m pytest tests/functional/test_functional.py::test_nextflow
+    


Test patch:
diff --git a/tests/functional/simple_nextflow_test_cases.yml b/tests/functional/simple_nextflow_test_cases.yml
new file mode 100644
index 00000000..17b8096d
--- /dev/null
+++ b/tests/functional/simple_nextflow_test_cases.yml
@@ -0,0 +1,35 @@
+- name: simple nextflow
+  command: >-
+    nextflow run nextflow_testpipeline.nf --N_LINES_TO_READ=10
+  files:
+    - path: results/rand/rand_0.txt
+    - path: results/rand/rand_1.txt
+    - path: results/rand/rand_2.txt
+    - path: results/rand/rand_3.txt
+    - path: results/rand/rand_4.txt
+    - path: results/rand/rand_5.txt
+    - path: results/rand/rand_6.txt
+    - path: results/rand/rand_7.txt
+    - path: results/rand/rand_8.txt
+    - path: results/rand/rand_9.txt
+    - path: results/b64/b64_0.txt
+    - path: results/b64/b64_1.txt
+    - path: results/b64/b64_2.txt
+    - path: results/b64/b64_3.txt
+    - path: results/b64/b64_4.txt
+    - path: results/b64/b64_5.txt
+    - path: results/b64/b64_6.txt
+    - path: results/b64/b64_7.txt
+    - path: results/b64/b64_8.txt
+    - path: results/b64/b64_9.txt
+    - path: results/randgz/randgz_0.txt.gz
+    - path: results/randgz/randgz_1.txt.gz
+    - path: results/randgz/randgz_2.txt.gz
+    - path: results/randgz/randgz_3.txt.gz
+    - path: results/randgz/randgz_4.txt.gz
+    - path: results/randgz/randgz_5.txt.gz
+    - path: results/randgz/randgz_6.txt.gz
+    - path: results/randgz/randgz_7.txt.gz
+    - path: results/randgz/randgz_8.txt.gz
+    - path: results/randgz/randgz_9.txt.gz
+    - path: results/all_data.gz
diff --git a/tests/functional/test_functional.py b/tests/functional/test_functional.py
index 58e2e4a6..44c0cff2 100644
--- a/tests/functional/test_functional.py
+++ b/tests/functional/test_functional.py
@@ -19,11 +19,13 @@
 
 SIMPLE_WDL_YAML = Path(__file__).parent / "simple_wdl_test_cases.yml"
 SNAKEFILE_YAML = Path(__file__).parent / "simple_snakefile_test_cases.yml"
+NEXTFLOW_YAML = Path(__file__).parent / "simple_nextflow_test_cases.yml"
 PIPELINE_DIR = Path(__file__).parent.parent / "pipelines"
 SIMPLE_WDL = Path(PIPELINE_DIR, "wdl", "simple.wdl")
 SIMPLE_WDL_JSON = Path(PIPELINE_DIR, "wdl", "simple.json")
 SIMPLE_WDL_OPTIONS_JSON = Path(PIPELINE_DIR, "wdl", "simple.options.json")
 SNAKEFILE = Path(PIPELINE_DIR, "snakemake", "SimpleSnakefile")
+NEXTFLOWFILE = Path(PIPELINE_DIR, "nextflow", "nextflow_testpipeline.nf")
 
 
 @pytest.mark.functional
@@ -57,3 +59,12 @@ def test_snakemake(pytester):
     result = pytester.runpytest("-v", "--keep-workflow-wd-on-fail")
     exit_code = result.ret
     assert exit_code == 0
+
+
+@pytest.mark.functional
+def test_nextflow(pytester):
+    pytester.makefile(ext=".nf",
+                      nextflow_testpipeline=NEXTFLOWFILE.read_text())
+    pytester.makefile(ext=".yml", test_nextflow=NEXTFLOW_YAML.read_text())
+    result = pytester.runpytest("-v", "--keep-workflow-wd-on-fail")
+    assert result.ret == 0
diff --git a/tests/pipelines/nextflow/nextflow_testpipeline.nf b/tests/pipelines/nextflow/nextflow_testpipeline.nf
new file mode 100644
index 00000000..6fd32eb8
--- /dev/null
+++ b/tests/pipelines/nextflow/nextflow_testpipeline.nf
@@ -0,0 +1,64 @@
+#!/usr/bin/env nextflow
+
+params.N_LINES_TO_READ = 5
+
+process read_random {
+	publishDir 'results/rand'
+
+	input:
+	val iter
+	output: 
+	val iter
+	path "rand_${iter}.txt"
+	script:
+	"""
+	head -n ${params.N_LINES_TO_READ} /dev/urandom > rand_${iter}.txt
+	"""
+}
+
+process base64_random {
+	publishDir 'results/b64'
+
+	input:
+	val iter
+	path "rand_${iter}.txt"
+	output:
+	val iter
+	path "b64_${iter}.txt"
+	script:
+	"""
+	cat rand_${iter}.txt | base64 > b64_${iter}.txt
+	"""
+}
+
+process gzip_b64 {
+	publishDir 'results/randgz'
+
+	input:
+	val iter
+	path "b64_${iter}.txt"
+	output:
+	path "randgz_${iter}.txt.gz"
+	script:
+	"""
+	cat b64_${iter}.txt | gzip -c > randgz_${iter}.txt.gz
+	"""
+}
+
+process concat_gzip {
+	publishDir 'results'
+
+	input:
+	path 'x'
+	output:
+	path "all_data.gz"
+	script:
+	"""
+	cat ${x} > all_data.gz
+	"""
+}
+
+workflow {
+	iterations = channel.from(0..9) | read_random | base64_random | gzip_b64
+	gzip_b64.out.collect() | concat_gzip
+}