Skip to content

Commit

Permalink
add checkProfileProvided to utils_nfcore_pipeline (nf-core#4891)
Browse files Browse the repository at this point in the history
  • Loading branch information
mirpedrol authored and jch-13 committed Mar 18, 2024
1 parent 8abb9e4 commit 7f0f5c7
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 1 deletion.
18 changes: 18 additions & 0 deletions subworkflows/nf-core/utils_nfcore_pipeline/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ import nextflow.extension.FilesEx

workflow UTILS_NFCORE_PIPELINE {

take:
nextflow_cli_args

main:
valid_config = checkConfigProvided()
checkProfileProvided(nextflow_cli_args)

emit:
valid_config
Expand Down Expand Up @@ -43,6 +47,20 @@ def checkConfigProvided() {
return valid_config
}

//
// Exit pipeline if --profile contains spaces
//
def checkProfileProvided(nextflow_cli_args) {
if (workflow.profile.endsWith(',')) {
error "The `-profile` option cannot end with a trailing comma, please remove it and re-run the pipeline!\n" +
"HINT: A common mistake is to provide multiple values separated by spaces e.g. `-profile test, docker`.\n"
}
if (nextflow_cli_args[0]) {
log.warn "nf-core pipelines do not accept positional arguments. The positional argument `${nextflow_cli_args[0]}` has been detected.\n" +
"HINT: A common mistake is to provide multiple values separated by spaces e.g. `-profile test, docker`.\n"
}
}

//
// Citation string for pipeline
//
Expand Down
6 changes: 5 additions & 1 deletion subworkflows/nf-core/utils_nfcore_pipeline/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ keywords:
- initialise
- version
components: []
input: []
input:
- nextflow_cli_args:
type: list
description: |
Nextflow CLI positional arguments
output:
- success:
type: boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,26 @@ nextflow_function {
}
}

test("Test Function checkProfileProvided") {

function "checkProfileProvided"

when {
function {
"""
input[0] = []
"""
}
}

then {
assertAll(
{ assert function.success },
{ assert snapshot(function.result).match() }
)
}
}

test("Test Function workflowCitation") {

function "workflowCitation"
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ nextflow_workflow {

test("Should run without failures") {

when {
workflow {
"""
input[0] = []
"""
}
}

then {
assertAll(
{ assert workflow.success },
Expand Down

0 comments on commit 7f0f5c7

Please sign in to comment.