Skip to content

Commit 4de7cf5

Browse files
feature: new allowNull attribute in input/output path
add integration test for input and output nullable path Signed-off-by: Jorge Aguilera <jorge.aguilera@seqera.io>
1 parent 3826dc7 commit 4de7cf5

9 files changed

Lines changed: 77 additions & 12 deletions

File tree

Makefile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,7 @@ refresh:
7474
#
7575
test:
7676
ifndef class
77-
./gradlew ${mm}test -PexcludeTests='nextflow.script.OutputNullablePathTest.class,nextflow.script.InputNullablePathTest.class'
78-
./gradlew nextflow:test --tests nextflow.script.InputNullablePathTest
79-
./gradlew nextflow:test --tests nextflow.script.OutputNullablePathTest
77+
./gradlew ${mm}test
8078
else
8179
./gradlew ${mm}test --tests ${class}
8280
endif

modules/nextflow/build.gradle

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ dependencies {
6060
test {
6161
minHeapSize = "512m"
6262
maxHeapSize = "2048m"
63-
if (project.hasProperty('excludeTests')) {
64-
exclude project.findProperty('excludeTests').split(',')
65-
}
6663
}
6764

6865
application {

modules/nextflow/src/main/groovy/nextflow/processor/TaskProcessor.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,13 +1483,13 @@ class TaskProcessor {
14831483

14841484
protected void collectOutFiles( TaskRun task, FileOutParam param, Path workDir, Map context ) {
14851485

1486-
final List<Object> allFiles = []
1486+
final List<Path> allFiles = []
14871487
// type file parameter can contain a multiple files pattern separating them with a special character
14881488
def entries = param.getFilePatterns(context, task.workDir)
14891489
boolean inputsRemovedFlag = false
14901490
// for each of them collect the produced files
14911491
for( String filePattern : entries ) {
1492-
List<Object> result = null
1492+
List<Path> result = null
14931493

14941494
def splitter = param.glob ? FilePatternSplitter.glob().parse(filePattern) : null
14951495
if( splitter?.isPattern() ) {

modules/nextflow/src/test/groovy/nextflow/script/InputNullablePathTest.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import test.MockScriptRunner
1414
*
1515
* @author Jorge Aguilera <jorge.aguilera@seqera.io>
1616
*/
17+
@IgnoreIf({System.getenv('NXF_INPUTNULLABLE')})
1718
class InputNullablePathTest extends Dsl2Spec {
1819

1920
def 'should fails if allowNull is allowed as output but expected as input'() {

modules/nextflow/src/test/groovy/nextflow/script/OutputNullablePathTest.groovy

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,14 @@ package nextflow.script
22

33

44
import nextflow.Session
5-
import nextflow.exception.MissingFileException
6-
import nextflow.exception.ProcessUnrecoverableException
75
import spock.lang.IgnoreIf
8-
import spock.lang.Timeout
9-
import test.BaseSpec
106
import test.Dsl2Spec
117

128
/**
139
*
1410
* @author Jorge Aguilera <jorge.aguilera@seqera.io>
1511
*/
12+
@IgnoreIf({System.getenv('NXF_INPUTNULLABLE')})
1613
class OutputNullablePathTest extends Dsl2Spec {
1714

1815
def 'should fails if allowNull output is not set'() {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
set +e
2+
3+
#
4+
# run normal mode
5+
#
6+
echo ''
7+
$NXF_RUN
8+
[[ $? == 0 ]] && exit 1
9+
10+
11+
#
12+
# RESUME mode
13+
#
14+
echo ''
15+
$NXF_RUN -resume
16+
[[ $? == 0 ]] && exit 1
17+
18+
exit 0
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
set +e
2+
3+
#
4+
# run normal mode
5+
#
6+
echo ''
7+
$NXF_RUN
8+
[[ $? == 0 ]] && exit 1
9+
10+
11+
#
12+
# RESUME mode
13+
#
14+
echo ''
15+
$NXF_RUN -resume
16+
[[ $? == 0 ]] && exit 1
17+
18+
exit 0

tests/input-nullablepath-fails.nf

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
nextflow.enable.dsl=2
2+
process test_process1 {
3+
input:
4+
val id
5+
output:
6+
path("output.txt", allowNull:true)
7+
exec:
8+
println id
9+
}
10+
11+
process test_process2 {
12+
input:
13+
path(file)
14+
output:
15+
val file
16+
exec:
17+
sleep 1000L
18+
println file
19+
}
20+
21+
workflow {
22+
channel.of('foo') | test_process1 | test_process2 | view()
23+
}

tests/output-nullablepath-fails.nf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
nextflow.enable.dsl=2
2+
3+
process test_process1 {
4+
input:
5+
val id
6+
output:
7+
path("output.txt")
8+
exec:
9+
println 'hi'
10+
}
11+
workflow {
12+
test_process1('foo').out
13+
}

0 commit comments

Comments
 (0)