I'm writing a new module for `csvtk mutate`. This ...
# nostupidquestions
a
I'm writing a new module for
csvtk mutate
. This is the process:
Copy code
process CSVTK_MUTATE {
    input:
    tuple val(meta), path(csv, name: 'inputs/csv*/*')
    val in_format
    val out_format

    output:
    tuple val(meta), path("${prefix}.${out_extension}"), emit: csv
    path "versions.yml"                                , emit: versions
    tuple val("${task.process}"), val('csvtk'), eval("csvtk version"), topic: versions, emit: versions_csvtk

    script:
    def args = task.ext.args   ?: ''
    prefix   = task.ext.prefix ?: "${meta.id}"
    def delimiter = in_format == "tsv" ? "\t" : (in_format == "csv" ? "," : in_format)
    def out_delimiter = out_format == "tsv" ? "\t" : (out_format == "csv" ? "," : out_format)
    out_extension = out_format == "tsv" ? 'tsv' : 'csv'

    """
    csvtk \\
        mutate \\
        ${args} \\
        --num-cpus $task.cpus \\
        --delimiter "${delimiter}" \\
        --out-delimiter "${out_delimiter}" \\
        --out-file ${prefix}.${out_extension} \\
        ${csv}
    """
I'm also writing a test. I have this`nextflow.config` within
tests/
Copy code
process {
    withName: CSVTK_MUTATE {
        ext.args  = params.csvtk_mutate_args
    }
}
and this `main.nf.test`:
Copy code
nextflow_process {

    name "Test Process CSVTK_MUTATE"
    script "../main.nf"
    process "CSVTK_MUTATE"

    tag "modules"
    tag "modules_"
    tag "csvtk"
    tag "csvtk/mutate"

    test("mutate") {
        config "nextflow.config"

        when {
            params {
                 csvtk_mutate_args = "--fields 1 --name 'newCol' --pattern '(\\d+).*'"
            }
            process {
                """
                input[0] = [
                    [ id:'test' ],
                    [
                        file("<https://github.com/nf-core/test-datasets/raw/bacass/bacass_hybrid.csv>", checkIfExists: true),
                    ]
                ]
                input[1] = "csv"
                input[2] = "csv"
                """
            }
        }

        then {
            assertAll(
                { assert process.success },
                { assert snapshot(process.out).match() }
                { assert path(process.out.csv).md5 == "9db267773e69cf5ba949963cf1d2eb38"}
            )
        }
    }
When I run
nf-test
I get an error related to
$args
not being filled with the params required to execute the command. Any idea what causes this issue?