-
Notifications
You must be signed in to change notification settings - Fork 621
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix unqualified usage of stdin and stdout declarations
- Loading branch information
1 parent
644e3fc
commit bcdcaab
Showing
3 changed files
with
208 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
200 changes: 200 additions & 0 deletions
200
modules/nextflow/src/test/groovy/nextflow/script/params/ParamsDsl2Test.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,200 @@ | ||
package nextflow.script.params | ||
|
||
import nextflow.Session | ||
import nextflow.ast.NextflowDSL | ||
import nextflow.script.BaseScript | ||
import nextflow.script.ScriptBinding | ||
import nextflow.script.ScriptMeta | ||
import org.codehaus.groovy.control.CompilerConfiguration | ||
import org.codehaus.groovy.control.customizers.ASTTransformationCustomizer | ||
import spock.lang.Timeout | ||
import test.Dsl2Spec | ||
import test.MockScriptRunner | ||
/** | ||
* | ||
* @author Paolo Di Tommaso <[email protected]> | ||
*/ | ||
@Timeout(5) | ||
class ParamsDsl2Test extends Dsl2Spec { | ||
|
||
def 'should not allow unqualified input file' () { | ||
given: | ||
def SCRIPT = ''' | ||
process foo { | ||
input: | ||
tuple 'x' | ||
/touch x/ | ||
} | ||
workflow { | ||
foo() | ||
} | ||
''' | ||
|
||
when: | ||
new MockScriptRunner() .setScript(SCRIPT).execute() | ||
then: | ||
def e = thrown(DeprecationException) | ||
e.message == "Unqualified input file declaration has been deprecated - replace `tuple 'x',..` with `tuple path('x'),..`" | ||
} | ||
|
||
def 'should not allow unqualified input val' () { | ||
given: | ||
def SCRIPT = ''' | ||
process foo { | ||
input: | ||
tuple X | ||
/echo $X/ | ||
} | ||
workflow { | ||
foo() | ||
} | ||
''' | ||
|
||
when: | ||
new MockScriptRunner() .setScript(SCRIPT).execute() | ||
then: | ||
def e = thrown(DeprecationException) | ||
e.message == "Unqualified input value declaration has been deprecated - replace `tuple X,..` with `tuple val(X),..`" | ||
} | ||
|
||
|
||
def 'should not allow unqualified output file' () { | ||
given: | ||
def SCRIPT = ''' | ||
process foo { | ||
output: | ||
tuple 'x' | ||
/touch x/ | ||
} | ||
workflow { | ||
foo() | ||
} | ||
''' | ||
|
||
when: | ||
new MockScriptRunner() .setScript(SCRIPT).execute() | ||
then: | ||
def e = thrown(DeprecationException) | ||
e.message == "Unqualified output path declaration has been deprecated - replace `tuple 'x',..` with `tuple path('x'),..`" | ||
} | ||
|
||
def 'should not allow unqualified output value' () { | ||
given: | ||
def SCRIPT = ''' | ||
process foo { | ||
output: | ||
tuple X | ||
/echo hello/ | ||
} | ||
workflow { | ||
foo() | ||
} | ||
''' | ||
|
||
when: | ||
new MockScriptRunner() .setScript(SCRIPT).execute() | ||
then: | ||
def e = thrown(DeprecationException) | ||
e.message == "Unqualified output value declaration has been deprecated - replace `tuple X,..` with `tuple val(X),..`" | ||
} | ||
|
||
|
||
def 'should allow unqualified stdin and stdout' () { | ||
|
||
given: | ||
new Session() | ||
and: | ||
def config = new CompilerConfiguration() | ||
config.setScriptBaseClass(BaseScript.class.name) | ||
config.addCompilationCustomizers( new ASTTransformationCustomizer(NextflowDSL)) | ||
|
||
def SCRIPT = ''' | ||
process alpha { | ||
input: | ||
stdin | ||
output: | ||
stdout | ||
/echo foo/ | ||
} | ||
workflow { true } | ||
''' | ||
|
||
when: | ||
def binding = new ScriptBinding().setSession(Mock(Session)) | ||
def script = (BaseScript)new GroovyShell(binding,config).parse(SCRIPT); script.run() | ||
and: | ||
def process = ScriptMeta.get(script).getProcess('alpha'); process.initialize() | ||
|
||
then: | ||
def inputs = process.processConfig.getInputs() | ||
def outputs = process.processConfig.getOutputs() | ||
and: | ||
inputs.size() == 1 | ||
inputs[0] instanceof StdInParam | ||
and: | ||
outputs.size() == 1 | ||
outputs[0] instanceof StdOutParam | ||
|
||
} | ||
|
||
def 'should allow unqualified tuple stdin and stdout' () { | ||
|
||
given: | ||
new Session() | ||
and: | ||
def config = new CompilerConfiguration() | ||
config.setScriptBaseClass(BaseScript.class.name) | ||
config.addCompilationCustomizers( new ASTTransformationCustomizer(NextflowDSL)) | ||
|
||
def SCRIPT = ''' | ||
process beta { | ||
input: | ||
tuple stdin, val(x) | ||
output: | ||
tuple stdout, path('z') | ||
/echo foo/ | ||
} | ||
workflow { true } | ||
''' | ||
|
||
when: | ||
def binding = new ScriptBinding().setSession(Mock(Session)) | ||
def script = (BaseScript)new GroovyShell(binding,config).parse(SCRIPT); script.run() | ||
and: | ||
def process = ScriptMeta.get(script).getProcess('beta'); process.initialize() | ||
|
||
then: | ||
def inputs = process.processConfig.getInputs() | ||
def outputs = process.processConfig.getOutputs() | ||
and: | ||
inputs.size() == 1 | ||
and: | ||
def in_tuple = (TupleInParam) inputs.get(0) | ||
and: | ||
in_tuple.inner.size() == 2 | ||
in_tuple.inner[0] instanceof StdInParam | ||
in_tuple.inner[1] instanceof ValueInParam | ||
|
||
and: | ||
def out_tuple = (TupleOutParam) outputs.get(0) | ||
and: | ||
out_tuple.inner.size() == 2 | ||
out_tuple.inner[0] instanceof StdOutParam | ||
out_tuple.inner[1] instanceof FileOutParam | ||
|
||
} | ||
} |
102 changes: 0 additions & 102 deletions
102
modules/nextflow/src/test/groovy/nextflow/script/params/TupleDeprecationTest.groovy
This file was deleted.
Oops, something went wrong.