diff --git a/CHANGELOG.md b/CHANGELOG.md index b24659f8..e0077117 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # nextflow-io/nf-schema: Changelog +# Version 2.1.2 + +## Bug fixes + +1. The directory `nf_test_output` is now an ignored parameter during validation to support use of both `nf_test` and `nf_schema`. + # Version 2.1.1 ## Bug fixes diff --git a/docs/configuration/configuration.md b/docs/configuration/configuration.md index 55e98b70..13d72525 100644 --- a/docs/configuration/configuration.md +++ b/docs/configuration/configuration.md @@ -69,6 +69,7 @@ validation.showHiddenParams = // default: false ## ignoreParams This option can be used to turn off the validation for certain parameters. It takes a list of parameter names as input. +Currently, the parameter `nf_test_output` is added to `ignoreParams` by default. ```groovy validation.ignoreParams = ["param1", "param2"] // default: [] diff --git a/docs/parameters/validation.md b/docs/parameters/validation.md index 76719b48..0cfe3dc6 100644 --- a/docs/parameters/validation.md +++ b/docs/parameters/validation.md @@ -66,6 +66,10 @@ The function causes Nextflow to exit immediately with an error. --8<-- "examples/validateParameters/pipeline/nextflow_schema.json" ``` +## Ignoring Parameters + +Users can turn off validation for specific parameters using `validation.ignoreParams`, which accepts a list of parameter names. + ## Failing for unrecognized parameters When parameters which are not specified in the JSON Schema are provided, the parameter validation function returns a `WARNING`. diff --git a/plugins/nf-schema/src/main/nextflow/validation/config/ValidationConfig.groovy b/plugins/nf-schema/src/main/nextflow/validation/config/ValidationConfig.groovy index 4ba51aab..172eb23e 100644 --- a/plugins/nf-schema/src/main/nextflow/validation/config/ValidationConfig.groovy +++ b/plugins/nf-schema/src/main/nextflow/validation/config/ValidationConfig.groovy @@ -7,7 +7,7 @@ import groovy.transform.PackageScope /** * This class allows model an specific configuration, extracting values from a map and converting * - * We anotate this class as @PackageScope to restrict the access of their methods only to class in the + * We annotate this class as @PackageScope to restrict the access of their methods only to class in the * same package * * @author : nvnieuwk @@ -49,5 +49,7 @@ class ValidationConfig { throw new SchemaValidationException("Config value 'validation.defaultIgnoreParams' should be a list of String values") } ignoreParams += config.defaultIgnoreParams ?: [] + ignoreParams += 'nf_test_output' //ignore `nf_test_output` directory when using nf-test + } } \ No newline at end of file diff --git a/plugins/nf-schema/src/test/nextflow/validation/ValidateParametersTest.groovy b/plugins/nf-schema/src/test/nextflow/validation/ValidateParametersTest.groovy index 1f9fdb4a..6627c2ae 100644 --- a/plugins/nf-schema/src/test/nextflow/validation/ValidateParametersTest.groovy +++ b/plugins/nf-schema/src/test/nextflow/validation/ValidateParametersTest.groovy @@ -429,6 +429,31 @@ class ValidateParametersTest extends Dsl2Spec{ !stdout } + def 'should ignore nf_test_output param' () { + given: + def schema = Path.of('src/testResources/nextflow_schema.json').toAbsolutePath().toString() + def SCRIPT = """ + params.input = 'src/testResources/correct.csv' + params.outdir = 'src/testResources/testDir' + params.nf_test_output = '/some/path' + include { validateParameters } from 'plugin/nf-schema' + + validateParameters(parameters_schema: '$schema') + """ + + when: + def config = [:] + def result = new MockScriptRunner(config).setScript(SCRIPT).execute() + def stdout = capture + .toString() + .readLines() + .findResults {it.contains('WARN nextflow.validation.SchemaValidator') || it.startsWith('* --') ? it : null } + + then: + noExceptionThrown() + !stdout + } + def 'should ignore default unexpected param' () { given: def schema = Path.of('src/testResources/nextflow_schema.json').toAbsolutePath().toString()