Skip to content

Commit

Permalink
Add config command yaml and json tests [ci fast]
Browse files Browse the repository at this point in the history
Signed-off-by: Paolo Di Tommaso <paolo.ditommaso@gmail.com>
  • Loading branch information
pditommaso committed Oct 18, 2024
1 parent 9220ce8 commit 589fdcc
Showing 1 changed file with 97 additions and 0 deletions.
97 changes: 97 additions & 0 deletions modules/nextflow/src/test/groovy/nextflow/cli/CmdConfigTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -490,4 +490,101 @@ class CmdConfigTest extends Specification {
folder?.deleteDir()
SysEnv.pop()
}

def 'should render json config output' () {
given:
def folder = Files.createTempDirectory('test')
def CONFIG = folder.resolve('nextflow.config')

CONFIG.text = '''
manifest {
author = 'me'
mainScript = 'foo.nf'
}
process {
cpus = 4
queue = 'cn-el7'
memory = { 10.GB }
ext.other = { 10.GB * task.attempt }
}
'''
def buffer = new ByteArrayOutputStream()
// command definition
def cmd = new CmdConfig(outputFormat: 'json')
cmd.launcher = new Launcher(options: new CliOptions(config: [CONFIG.toString()]))
cmd.stdout = buffer
cmd.args = [ '.' ]

when:
cmd.run()

then:
buffer.toString() == '''
{
"manifest": {
"author": "me",
"mainScript": "foo.nf"
},
"process": {
"cpus": 4,
"queue": "cn-el7",
"memory": "{ 10.GB }",
"ext": {
"other": "{ 10.GB * task.attempt }"
}
}
}
'''
.stripIndent().leftTrim()

cleanup:
folder.deleteDir()
}

def 'should render yaml config output' () {
given:
def folder = Files.createTempDirectory('test')
def CONFIG = folder.resolve('nextflow.config')

CONFIG.text = '''
manifest {
author = 'me'
mainScript = 'foo.nf'
}
process {
cpus = 4
queue = 'cn-el7'
memory = { 10.GB }
ext.other = { 10.GB * task.attempt }
}
'''
def buffer = new ByteArrayOutputStream()
// command definition
def cmd = new CmdConfig(outputFormat: 'yaml')
cmd.launcher = new Launcher(options: new CliOptions(config: [CONFIG.toString()]))
cmd.stdout = buffer
cmd.args = [ '.' ]

when:
cmd.run()

then:
buffer.toString() == '''
manifest:
author: me
mainScript: foo.nf
process:
cpus: 4
queue: cn-el7
memory: '{ 10.GB }'
ext:
other: '{ 10.GB * task.attempt }'
'''
.stripIndent().leftTrim()

cleanup:
folder.deleteDir()
}
}

0 comments on commit 589fdcc

Please sign in to comment.