Support for channels as function output is not fully functional.
main.nf:
def defaultChannel(){
Channel.value(1)
}
with main.nf.test:
nextflow_function {
name "Test Functions"
script "main.nf"
test("Test Function defaultChannel") {
function "defaultChannel"
when {
function {
"""
// define inputs of the function here. Example:
// input[0] = 1
"""
}
}
then {
println function.properties
assert function.success
assert snapshot(function.result).match()
}
}
}
results in:
$ nf-test test tests/main.nf.test
Picked up JAVA_TOOL_OPTIONS: -XX:+UseContainerSupport -XX:ActiveProcessorCount=1
🚀 nf-test 0.8.4
https://code.askimed.com/nf-test
(c) 2021 - 2024 Lukas Forer and Sebastian Schoenherr
Test Functions
Test [a7c7feae] 'Test Function defaultChannel' [stderr:[], class:class com.askimed.nf.test.lang.function.Function, errorReport:, exitStatus:1, mapping:
// define inputs of the function here. Example:
// input[0] = 1
, failed:true, result:null, stdout:[ERROR ~ Cannot invoke "groovyx.gpars.serial.SerialContext.add(groovyx.gpars.serial.SerialHandle)" because "this.context" is null, , -- Check script 'meta/mock.nf' at line: 35 or see '/workspace/Nextflow_sandbox/.nf-test/tests/a7c7feae6c08f02d7cd531ca2156d60a/meta/nextflow.log' file for more details], errorMessage:, trace:com.askimed.nf.test.lang.WorkflowTrace@304b9f1a, name:null, success:false]
FAILED (8.337s)
Assertion failed:
assert function.success
| |
| false
com.askimed.nf.test.lang.function.Function@1059754c (toString() == null)
Nextflow stdout:
ERROR ~ Cannot invoke "groovyx.gpars.serial.SerialContext.add(groovyx.gpars.serial.SerialHandle)" because "this.context" is null
-- Check script 'meta/mock.nf' at line: 35 or see '/workspace/Nextflow_sandbox/.nf-test/tests/a7c7feae6c08f02d7cd531ca2156d60a/meta/nextflow.log' file for more details
Nextflow stderr:
FAILURE: Executed 1 tests in 8.346s (1 failed)
When using files in a channel as output, the test passes but the output is an empty map:
main.nf:
nextflow_function {
name "Test Functions"
script "main.nf"
test("Test Function defaultChannel") {
function "defaultChannel"
when {
function {
"""
// define inputs of the function here. Example:
// input[0] = 1
"""
}
}
then {
println function.properties
assert function.success
assert snapshot(function.result).match()
}
}
}
terminal:
$ nf-test test tests/main.nf.test
Picked up JAVA_TOOL_OPTIONS: -XX:+UseContainerSupport -XX:ActiveProcessorCount=1
🚀 nf-test 0.8.4
https://code.askimed.com/nf-test
(c) 2021 - 2024 Lukas Forer and Sebastian Schoenherr
Test Functions
Test [a7c7feae] 'Test Function defaultChannel' [stderr:[], class:class com.askimed.nf.test.lang.function.Function, errorReport:null, exitStatus:0, mapping:
// define inputs of the function here. Example:
// input[0] = 1
, failed:false, result:[:], stdout:[], errorMessage:null, trace:com.askimed.nf.test.lang.WorkflowTrace@5b56b654, name:null, success:true]
PASSED (14.31s)
Snapshots:
1 created [Test Function defaultChannel]
Snapshot Summary:
1 created
SUCCESS: Executed 1 tests in 14.321s
Support for channels as function output is not fully functional.
main.nf
:with
main.nf.test
:results in:
When using files in a channel as output, the test passes but the output is an empty map:
main.nf
:main.nf.test
:terminal
:main.nf.test.snap
:Additional context.
I use functions to wrap common channel manipulations to help with code readability.