From 358224fc7be7a9245e5dd29b318061b4e304fbb3 Mon Sep 17 00:00:00 2001 From: Paolo Di Tommaso Date: Wed, 1 Nov 2023 15:00:22 +0100 Subject: [PATCH] Add tests [ci fast] Signed-off-by: Paolo Di Tommaso --- .../nextflow/script/params/OutParam.groovy | 2 + .../script/params/ParamsOutTest.groovy | 80 +++++++++++++++++++ 2 files changed, 82 insertions(+) diff --git a/modules/nextflow/src/main/groovy/nextflow/script/params/OutParam.groovy b/modules/nextflow/src/main/groovy/nextflow/script/params/OutParam.groovy index 7f17a5ea3b..2a1570a2f3 100644 --- a/modules/nextflow/src/main/groovy/nextflow/script/params/OutParam.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/script/params/OutParam.groovy @@ -51,4 +51,6 @@ interface OutParam extends Cloneable { String getChannelEmitName() + String getChannelTopicName() + } diff --git a/modules/nextflow/src/test/groovy/nextflow/script/params/ParamsOutTest.groovy b/modules/nextflow/src/test/groovy/nextflow/script/params/ParamsOutTest.groovy index ce75d7508e..f907d61e11 100644 --- a/modules/nextflow/src/test/groovy/nextflow/script/params/ParamsOutTest.groovy +++ b/modules/nextflow/src/test/groovy/nextflow/script/params/ParamsOutTest.groovy @@ -1197,4 +1197,84 @@ class ParamsOutTest extends Dsl2Spec { outs[2].inner[1].name == 'bar' } + + + def 'should define out with topic' () { + setup: + def text = ''' + process hola { + output: + val x, topic: ch0 + env FOO, topic: ch1 + path '-', topic: ch2 + stdout topic: ch3 + /return/ + } + + workflow { hola() } + ''' + + def binding = [:] + def process = parseAndReturnProcess(text, binding) + + when: + def outs = process.config.getOutputs() as List + then: + outs[0].name == 'x' + outs[0].channelTopicName == 'ch0' + and: + outs[1].name == 'FOO' + outs[1].channelTopicName == 'ch1' + and: + outs[2] instanceof StdOutParam // <-- note: declared as `path`, turned into a `stdout` + outs[2].name == '-' + outs[2].channelTopicName == 'ch2' + and: + outs[3] instanceof StdOutParam + outs[3].name == '-' + outs[3].channelTopicName == 'ch3' + } + + def 'should define out tuple with topic'() { + + setup: + def text = ''' + process hola { + output: + tuple val(x), val(y), topic: ch1 + tuple path('foo'), topic: ch2 + tuple stdout,env(bar), topic: ch3 + + /return/ + } + + workflow { hola() } + ''' + + def binding = [:] + def process = parseAndReturnProcess(text, binding) + + when: + def outs = process.config.getOutputs() as List + + then: + outs[0].name == 'tupleoutparam<0>' + outs[0].channelTopicName == 'ch1' + outs[0].inner[0] instanceof ValueOutParam + outs[0].inner[0].name == 'x' + outs[0].inner[1] instanceof ValueOutParam + outs[0].inner[1].name == 'y' + and: + outs[1].name == 'tupleoutparam<1>' + outs[1].channelTopicName == 'ch2' + outs[1].inner[0] instanceof FileOutParam + and: + outs[2].name == 'tupleoutparam<2>' + outs[2].channelTopicName == 'ch3' + outs[2].inner[0] instanceof StdOutParam + outs[2].inner[0].name == '-' + outs[2].inner[1] instanceof EnvOutParam + outs[2].inner[1].name == 'bar' + + } }