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

Bug fix for file path patterns #132

Merged
merged 3 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
}
]
}