Skip to content
This repository was archived by the owner on Aug 20, 2024. It is now read-only.

Commit 975bc99

Browse files
authored
Merge pull request #132 from nvnieuwk/fix-file-path-patterns
Bug fix for file path patterns
2 parents 1a6bf69 + 4e4270d commit 975bc99

File tree

5 files changed

+78
-3
lines changed

5 files changed

+78
-3
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# nextflow-io/nf-validation: Changelog
22

3+
# Version 1.1.2 - Wakayama
4+
5+
## Bug fixes
6+
7+
- Fixed an issue with inputs using `file-path-pattern` where only one file was found (`Path` casting to `ArrayList` error) ([#132](https://github.com/nextflow-io/nf-validation/pull/132))
8+
39
# Version 1.1.1 - Shoyu
410

511
## Bug fixes

plugins/nf-validation/src/main/nextflow/validation/FormatValidators/FilePathPatternValidator.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class FilePathPatternValidator implements FormatValidator {
1515
log.debug("S3 paths are not supported by 'FilePathPatternValidator': '${subject}'")
1616
return Optional.empty()
1717
}
18-
ArrayList files = Nextflow.file(subject) as ArrayList
18+
ArrayList files = Nextflow.files(subject)
1919
ArrayList errors = []
2020

2121
if(files.size() == 0) {
@@ -26,7 +26,7 @@ public class FilePathPatternValidator implements FormatValidator {
2626
errors.add("'${file.toString()}' is not a file, but a directory" as String)
2727
}
2828
}
29-
if(errors.size > 0) {
29+
if(errors.size() > 0) {
3030
return Optional.of(errors.join('\n'))
3131
}
3232
return Optional.empty()
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Manifest-Version: 1.0
22
Plugin-Id: nf-validation
3-
Plugin-Version: 1.1.1
3+
Plugin-Version: 1.1.2
44
Plugin-Class: nextflow.validation.ValidationPlugin
55
Plugin-Provider: nextflow
66
Plugin-Requires: >=22.10.0

plugins/nf-validation/src/test/nextflow/validation/PluginExtensionMethodsTest.groovy

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,50 @@ class PluginExtensionMethodsTest extends Dsl2Spec{
401401
!stdout
402402
}
403403

404+
def 'correct validation of file-path-pattern - glob' () {
405+
given:
406+
def schema = Path.of('src/testResources/nextflow_schema_file_path_pattern.json').toAbsolutePath().toString()
407+
def SCRIPT_TEXT = """
408+
params.glob = 'src/testResources/*.csv'
409+
include { validateParameters } from 'plugin/nf-validation'
410+
411+
validateParameters(parameters_schema: '$schema')
412+
"""
413+
414+
when:
415+
dsl_eval(SCRIPT_TEXT)
416+
def stdout = capture
417+
.toString()
418+
.readLines()
419+
.findResults {it.contains('WARN nextflow.validation.SchemaValidator') || it.startsWith('* --') ? it : null }
420+
421+
then:
422+
noExceptionThrown()
423+
!stdout
424+
}
425+
426+
def 'correct validation of file-path-pattern - single file' () {
427+
given:
428+
def schema = Path.of('src/testResources/nextflow_schema_file_path_pattern.json').toAbsolutePath().toString()
429+
def SCRIPT_TEXT = """
430+
params.glob = 'src/testResources/correct.csv'
431+
include { validateParameters } from 'plugin/nf-validation'
432+
433+
validateParameters(parameters_schema: '$schema')
434+
"""
435+
436+
when:
437+
dsl_eval(SCRIPT_TEXT)
438+
def stdout = capture
439+
.toString()
440+
.readLines()
441+
.findResults {it.contains('WARN nextflow.validation.SchemaValidator') || it.startsWith('* --') ? it : null }
442+
443+
then:
444+
noExceptionThrown()
445+
!stdout
446+
}
447+
404448
def 'correct validation of numbers with lenient mode' () {
405449
given:
406450
def schema = Path.of('src/testResources/nextflow_schema.json').toAbsolutePath().toString()
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema",
3+
"$id": "https://raw.githubusercontent.com/nf-core/testpipeline/master/nextflow_schema.json",
4+
"title": "nf-core/testpipeline pipeline parameters",
5+
"description": "this is a test",
6+
"type": "object",
7+
"definitions": {
8+
"file_patterns": {
9+
"title": "Input/output options",
10+
"type": "object",
11+
"fa_icon": "fas fa-terminal",
12+
"properties": {
13+
"glob": {
14+
"type": "string",
15+
"format": "file-path-pattern"
16+
}
17+
}
18+
}
19+
},
20+
"allOf": [
21+
{
22+
"$ref": "#/definitions/file_patterns"
23+
}
24+
]
25+
}

0 commit comments

Comments
 (0)