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

Commit

Permalink
Merge pull request #132 from nvnieuwk/fix-file-path-patterns
Browse files Browse the repository at this point in the history
Bug fix for file path patterns
  • Loading branch information
nvnieuwk authored Nov 16, 2023
2 parents 1a6bf69 + 4e4270d commit 975bc99
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# nextflow-io/nf-validation: Changelog

# Version 1.1.2 - Wakayama

## Bug fixes

- 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))

# Version 1.1.1 - Shoyu

## Bug fixes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class FilePathPatternValidator implements FormatValidator {
log.debug("S3 paths are not supported by 'FilePathPatternValidator': '${subject}'")
return Optional.empty()
}
ArrayList files = Nextflow.file(subject) as ArrayList
ArrayList files = Nextflow.files(subject)
ArrayList errors = []

if(files.size() == 0) {
Expand All @@ -26,7 +26,7 @@ public class FilePathPatternValidator implements FormatValidator {
errors.add("'${file.toString()}' is not a file, but a directory" as String)
}
}
if(errors.size > 0) {
if(errors.size() > 0) {
return Optional.of(errors.join('\n'))
}
return Optional.empty()
Expand Down
2 changes: 1 addition & 1 deletion plugins/nf-validation/src/resources/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Manifest-Version: 1.0
Plugin-Id: nf-validation
Plugin-Version: 1.1.1
Plugin-Version: 1.1.2
Plugin-Class: nextflow.validation.ValidationPlugin
Plugin-Provider: nextflow
Plugin-Requires: >=22.10.0
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,50 @@ class PluginExtensionMethodsTest extends Dsl2Spec{
!stdout
}

def 'correct validation of file-path-pattern - glob' () {
given:
def schema = Path.of('src/testResources/nextflow_schema_file_path_pattern.json').toAbsolutePath().toString()
def SCRIPT_TEXT = """
params.glob = 'src/testResources/*.csv'
include { validateParameters } from 'plugin/nf-validation'
validateParameters(parameters_schema: '$schema')
"""

when:
dsl_eval(SCRIPT_TEXT)
def stdout = capture
.toString()
.readLines()
.findResults {it.contains('WARN nextflow.validation.SchemaValidator') || it.startsWith('* --') ? it : null }

then:
noExceptionThrown()
!stdout
}

def 'correct validation of file-path-pattern - single file' () {
given:
def schema = Path.of('src/testResources/nextflow_schema_file_path_pattern.json').toAbsolutePath().toString()
def SCRIPT_TEXT = """
params.glob = 'src/testResources/correct.csv'
include { validateParameters } from 'plugin/nf-validation'
validateParameters(parameters_schema: '$schema')
"""

when:
dsl_eval(SCRIPT_TEXT)
def stdout = capture
.toString()
.readLines()
.findResults {it.contains('WARN nextflow.validation.SchemaValidator') || it.startsWith('* --') ? it : null }

then:
noExceptionThrown()
!stdout
}

def 'correct validation of numbers with lenient mode' () {
given:
def schema = Path.of('src/testResources/nextflow_schema.json').toAbsolutePath().toString()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"$schema": "http://json-schema.org/draft-07/schema",
"$id": "https://raw.githubusercontent.com/nf-core/testpipeline/master/nextflow_schema.json",
"title": "nf-core/testpipeline pipeline parameters",
"description": "this is a test",
"type": "object",
"definitions": {
"file_patterns": {
"title": "Input/output options",
"type": "object",
"fa_icon": "fas fa-terminal",
"properties": {
"glob": {
"type": "string",
"format": "file-path-pattern"
}
}
}
},
"allOf": [
{
"$ref": "#/definitions/file_patterns"
}
]
}

0 comments on commit 975bc99

Please sign in to comment.