diff --git a/src/main/resources/com/askimed/nf/test/lang/function/WorkflowMock.nf b/src/main/resources/com/askimed/nf/test/lang/function/WorkflowMock.nf index 75566acd..23224b24 100644 --- a/src/main/resources/com/askimed/nf/test/lang/function/WorkflowMock.nf +++ b/src/main/resources/com/askimed/nf/test/lang/function/WorkflowMock.nf @@ -20,10 +20,11 @@ include { ${include} } from '${script}' // define custom rules for JSON that will be generated. def jsonOutput = new JsonGenerator.Options() - .excludeNulls() // Do not include fields with value null.. .addConverter(Path) { value -> value.toAbsolutePath().toString() } // Custom converter for Path. Only filename .build() +def jsonWorkflowOutput = new JsonGenerator.Options().excludeNulls().build() + workflow { @@ -43,6 +44,6 @@ workflow.onComplete { errorMessage: workflow.errorMessage, errorReport: workflow.errorReport ] - new File("\${params.nf_test_output}/workflow.json").text = jsonOutput.toJson(result) + new File("\${params.nf_test_output}/workflow.json").text = jsonWorkflowOutput.toJson(result) } \ No newline at end of file diff --git a/src/main/resources/com/askimed/nf/test/lang/process/WorkflowMock.nf b/src/main/resources/com/askimed/nf/test/lang/process/WorkflowMock.nf index d006888e..232342e6 100644 --- a/src/main/resources/com/askimed/nf/test/lang/process/WorkflowMock.nf +++ b/src/main/resources/com/askimed/nf/test/lang/process/WorkflowMock.nf @@ -17,10 +17,11 @@ include { ${process} } from '${script}' // define custom rules for JSON that will be generated. def jsonOutput = new JsonGenerator.Options() - .excludeNulls() // Do not include fields with value null.. .addConverter(Path) { value -> value.toAbsolutePath().toString() } // Custom converter for Path. Only filename .build() +def jsonWorkflowOutput = new JsonGenerator.Options().excludeNulls().build() + workflow { @@ -83,6 +84,6 @@ workflow.onComplete { errorMessage: workflow.errorMessage, errorReport: workflow.errorReport ] - new File("\${params.nf_test_output}/workflow.json").text = jsonOutput.toJson(result) + new File("\${params.nf_test_output}/workflow.json").text = jsonWorkflowOutput.toJson(result) } diff --git a/src/main/resources/com/askimed/nf/test/lang/workflow/WorkflowMock.nf b/src/main/resources/com/askimed/nf/test/lang/workflow/WorkflowMock.nf index 126157ca..5004d612 100644 --- a/src/main/resources/com/askimed/nf/test/lang/workflow/WorkflowMock.nf +++ b/src/main/resources/com/askimed/nf/test/lang/workflow/WorkflowMock.nf @@ -17,10 +17,10 @@ include { ${workflow} } from '${script}' // define custom rules for JSON that will be generated. def jsonOutput = new JsonGenerator.Options() - .excludeNulls() // Do not include fields with value null.. .addConverter(Path) { value -> value.toAbsolutePath().toString() } // Custom converter for Path. Only filename .build() +def jsonWorkflowOutput = new JsonGenerator.Options().excludeNulls().build() workflow { @@ -83,6 +83,6 @@ workflow.onComplete { errorMessage: workflow.errorMessage, errorReport: workflow.errorReport ] - new File("\${params.nf_test_output}/workflow.json").text = jsonOutput.toJson(result) + new File("\${params.nf_test_output}/workflow.json").text = jsonWorkflowOutput.toJson(result) } diff --git a/src/test/java/com/askimed/nf/test/lang/ProcessTest.java b/src/test/java/com/askimed/nf/test/lang/ProcessTest.java index d72b34c4..103196a8 100644 --- a/src/test/java/com/askimed/nf/test/lang/ProcessTest.java +++ b/src/test/java/com/askimed/nf/test/lang/ProcessTest.java @@ -80,6 +80,15 @@ public void testDisableAutoSortTestSuiteAndOverwrite() throws Exception { } + @Test + public void testNullValuesInChannels() throws Exception { + + App app = new App(); + int exitCode = app.run(new String[] { "test", "test-data/channels/null-values/return_null.nf.test" }); + assertEquals(0, exitCode); + + } + @Test public void testWithNoOutputs() throws Exception { diff --git a/test-data/channels/null-values/return_null.nf b/test-data/channels/null-values/return_null.nf new file mode 100644 index 00000000..1a9ccdea --- /dev/null +++ b/test-data/channels/null-values/return_null.nf @@ -0,0 +1,8 @@ +process return_null { + + output: + val null_list, emit: null_list + + exec: + null_list = ["0", "1", "", null, "4"] +} \ No newline at end of file diff --git a/test-data/channels/null-values/return_null.nf.test b/test-data/channels/null-values/return_null.nf.test new file mode 100644 index 00000000..0077701f --- /dev/null +++ b/test-data/channels/null-values/return_null.nf.test @@ -0,0 +1,24 @@ +nextflow_process { + + name "Test Process return_null" + script "./return_null.nf" + process "return_null" + + test("Should run without failures") { + + when { + params {} + process {} + } + + then { + assert process.success + + with(process.out) { + assert null_list == [["0", "1", "", null, "4"]] + } + } + + } + +} \ No newline at end of file