Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Serializes null values in channel outputs #232

Merged
merged 1 commit into from
Jul 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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)

}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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)

}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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)

}
9 changes: 9 additions & 0 deletions src/test/java/com/askimed/nf/test/lang/ProcessTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
8 changes: 8 additions & 0 deletions test-data/channels/null-values/return_null.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
process return_null {

output:
val null_list, emit: null_list

exec:
null_list = ["0", "1", "", null, "4"]
}
24 changes: 24 additions & 0 deletions test-data/channels/null-values/return_null.nf.test
Original file line number Diff line number Diff line change
@@ -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"]]
}
}

}

}
Loading