Skip to content

Commit 1139434

Browse files
committed
Fix failing tests
Signed-off-by: Ben Sherman <bentshermann@gmail.com>
1 parent 881d13b commit 1139434

8 files changed

Lines changed: 21 additions & 13 deletions

File tree

docs/process-typed.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ process cat_opt {
7575
input: Path?
7676
7777
stage:
78-
stageAs 'input.txt', input
78+
stageAs input, 'input.txt'
7979
8080
output:
8181
stdout()

modules/nextflow/src/test/groovy/nextflow/script/dsl/ProcessDslV2Test.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class ProcessDslV2Test extends Specification {
4040
dsl._input_('infile', Path, false)
4141
dsl._input_('x', String, false)
4242
dsl._input_('y', String, false)
43-
dsl.stageAs('filename.fa', { infile })
43+
dsl.stageAs({ -> infile }, 'filename.fa')
4444
dsl.stdin { y }
4545

4646
then:
@@ -112,7 +112,7 @@ class ProcessDslV2Test extends Specification {
112112
dsl.memory '10 GB'
113113
dsl._input_('foo', String, false)
114114
dsl._input_('sample', Path, false)
115-
dsl.stageAs('sample.txt', { sample })
115+
dsl.stageAs({ -> sample }, 'sample.txt')
116116
dsl._output_('result', Path, { file('$file0') })
117117
dsl._unstage_files('$file0', 'result.txt')
118118

modules/nf-lang/src/main/java/nextflow/script/control/ProcessToGroovyVisitorV2.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ private void visitProcessDirectives(Statement directives) {
120120
private void visitProcessStagers(Statement directives) {
121121
asDirectives(directives).forEach((call) -> {
122122
var arguments = asMethodCallArguments(call).stream()
123-
.map(arg -> sgh.transformToLazy(arg))
123+
.map(arg -> sgh.transformToLazy(arg, false))
124124
.toList();
125125
call.setArguments(args(arguments));
126126
});

modules/nf-lang/src/main/java/nextflow/script/control/ScriptToGroovyHelper.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.Set;
2222

2323
import org.codehaus.groovy.ast.CodeVisitorSupport;
24+
import org.codehaus.groovy.ast.Parameter;
2425
import org.codehaus.groovy.ast.Variable;
2526
import org.codehaus.groovy.ast.expr.ClosureExpression;
2627
import org.codehaus.groovy.ast.expr.Expression;
@@ -119,16 +120,23 @@ private static String asPropertyChain(PropertyExpression node) {
119120
* wrapping it in a closure if it references variables.
120121
*
121122
* @param node
123+
* @param implicitParam
122124
*/
123-
public Expression transformToLazy(Expression node) {
125+
public Expression transformToLazy(Expression node, boolean implicitParam) {
124126
if( node instanceof ClosureExpression )
125127
return node;
126128
var vars = new VariableCollector().collect(node);
127-
if( !vars.isEmpty() )
128-
return closureX(null, stmt(node));
129+
if( !vars.isEmpty() ) {
130+
var parameters = implicitParam ? Parameter.EMPTY_ARRAY : null;
131+
return closureX(parameters, stmt(node));
132+
}
129133
return node;
130134
}
131135

136+
public Expression transformToLazy(Expression node) {
137+
return transformToLazy(node, true);
138+
}
139+
132140
private class VariableCollector extends CodeVisitorSupport {
133141

134142
private Set<Variable> vars;

modules/nf-lang/src/test/groovy/nextflow/script/formatter/ScriptFormatterTest.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ class ScriptFormatterTest extends Specification {
207207
nextflow.preview.types=true
208208
209209
process hello{
210-
debug(true) ; input: (id,infile):Tuple<String,Path> ; index:Path ; stage: stageAs('input.txt',infile) ; output: result=tuple(id,file('output.txt')) ; script: 'cat input.txt > output.txt'
210+
debug(true) ; input: (id,infile):Tuple<String,Path> ; index:Path ; stage: stageAs(infile,'input.txt') ; output: result=tuple(id,file('output.txt')) ; script: 'cat input.txt > output.txt'
211211
}
212212
''',
213213
'''\
@@ -221,7 +221,7 @@ class ScriptFormatterTest extends Specification {
221221
index: Path
222222
223223
stage:
224-
stageAs 'input.txt', infile
224+
stageAs infile, 'input.txt'
225225
226226
output:
227227
result = tuple(id, file('output.txt'))

tests/collect-tuple-typed.nf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ process merge {
3232
(barcode, seq_ids, bam, bai): Tuple<String, Bag<String>, Bag<Path>, Bag<Path>>
3333

3434
stage:
35-
stageAs 'bam?', bam
36-
stageAs 'bai?', bai
35+
stageAs bam, 'bam?'
36+
stageAs bai, 'bai?'
3737

3838
script:
3939
"""

tests/dynamic-filename-typed.nf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ process foo {
2727
(name, txt): Tuple<String, Path>
2828

2929
stage:
30-
stageAs "${params.prefix}_${name}.txt", txt
30+
stageAs txt, "${params.prefix}_${name}.txt"
3131

3232
output:
3333
file("${params.prefix}_${name}.txt")

tests/nullable-path.nf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ process bar {
2020
input: Path?
2121

2222
stage:
23-
stageAs 'input.txt', input
23+
stageAs input, 'input.txt'
2424

2525
output:
2626
stdout()

0 commit comments

Comments
 (0)