Skip to content

Commit

Permalink
add a test for the help message
Browse files Browse the repository at this point in the history
  • Loading branch information
nvnieuwk committed Aug 5, 2024
1 parent dd24d07 commit 2d457f8
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ class SchemaValidator extends PluginExtensionPoint {
if (paramNames.size() > 1) {
paramNames.remove(0)
paramNames.each {
paramOptions = (Map) paramOptions.properties[it] ?: [:]
paramOptions = (Map) paramOptions?.properties?[it] ?: [:]
}
}
if (!paramOptions) {
Expand Down Expand Up @@ -471,7 +471,7 @@ class SchemaValidator extends PluginExtensionPoint {
" ." + it[4..it.length()-1]
}
.join("\n")
helpMessage += " " + colors.dim + "options: " + colors.reset + "\n" + subParamsHelpString + "\n"
helpMessage += " " + colors.dim + "options".padRight(11) + ": " + colors.reset + "\n" + subParamsHelpString + "\n"
continue
}
def String value = option.value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class ParamsHelpTest extends Dsl2Spec{
.toString()
.readLines()
.findResults {it.contains('publish_dir_mode') &&
it.contains('(accepted: symlink, rellink, link, copy, copyNoFollow')
it.contains('(accepted: symlink, rellink')
? it : null }

then:
Expand Down Expand Up @@ -178,4 +178,33 @@ class ParamsHelpTest extends Dsl2Spec{
error.message == "Specified param 'no_exist' does not exist in JSON schema."
!stdout
}

def 'should print a help message of nested parameter' () {
given:
def schema = Path.of('src/testResources/nextflow_schema_nested_parameters.json').toAbsolutePath().toString()
def SCRIPT = """
include { paramsHelp } from 'plugin/nf-schema'
params.help = 'this.is'
def command = "nextflow run <pipeline> --input samplesheet.csv --outdir <OUTDIR> -profile docker"
def help_msg = paramsHelp(command, parameters_schema: '$schema')
log.info help_msg
"""

when:
def result = new MockScriptRunner([:]).setScript(SCRIPT).execute()
def stdout = capture
.toString()
.readLines()
.findResults {it.startsWith('--this.is') ||
it.contains('description:') ||
it.contains('options :') ||
it.contains('.so')
? it : null }

then:
noExceptionThrown()
stdout.size() == 4
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,19 @@
"required": ["this"],
"properties": {
"this": {
"description": "this is this",
"type": "object",
"properties": {
"is":{
"description": "is this is?",
"type": "object",
"properties": {
"so": {
"description": "so so so",
"type": "object",
"properties": {
"deep": {
"description": "so deep",
"type": "boolean"
}
}
Expand Down

0 comments on commit 2d457f8

Please sign in to comment.