Skip to content

Commit

Permalink
Also check per process container when specifying '-with-docker' comma…
Browse files Browse the repository at this point in the history
…nd line option. Fixes #39.
  • Loading branch information
emi80 committed Mar 26, 2015
1 parent 6b00962 commit ea802f9
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/main/groovy/nextflow/script/ConfigBuilder.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,15 @@ class ConfigBuilder {
}

if( ! config.process.container ) {
throw new AbortOperationException("You request to run with Docker but no image has been specified")
def subProcs = config.process.findAll { it.key.startsWith('$') }
if ( ! subProcs )
throw new AbortOperationException("You request to run with Docker but no image has been specified")
subProcs.each { name, value ->
if ( ! value.container ) {
throw new AbortOperationException("You request to run with Docker but no image has been specified")
}
}

}
}
}
Expand Down
51 changes: 51 additions & 0 deletions src/test/groovy/nextflow/script/ConfigBuilderTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,57 @@ class ConfigBuilderTest extends Specification {

}

def 'run with docker 3'() {
given:
def file = Files.createTempFile('test','config')
file.deleteOnExit()

when:
file.text =
'''
process.$test.container = 'busybox'
'''
def opt = new CliOptions(config: [file.toFile().canonicalPath])
def run = new CmdRun(withDocker: '-')
def config = new ConfigBuilder().setOptions(opt).setCmdRun(run).build()
then:
config.docker.enabled
config.process.$test.container == 'busybox'

when:
file.text =
'''
process.container = 'busybox'
'''
opt = new CliOptions(config: [file.toFile().canonicalPath])
run = new CmdRun(withDocker: '-')
config = new ConfigBuilder().setOptions(opt).setCmdRun(run).build()
then:
config.docker.enabled
config.process.container == 'busybox'

when:
opt = new CliOptions()
run = new CmdRun(withDocker: '-')
config = new ConfigBuilder().setOptions(opt).setCmdRun(run).build()
then:
def e = thrown(AbortOperationException)
e.message == 'You request to run with Docker but no image has been specified'

when:
file.text =
'''
process.$test.tag = 'tag'
'''
opt = new CliOptions(config: [file.toFile().canonicalPath])
run = new CmdRun(withDocker: '-')
config = new ConfigBuilder().setOptions(opt).setCmdRun(run).build()
then:
e = thrown(AbortOperationException)
e.message == 'You request to run with Docker but no image has been specified'

}

def 'run without docker'() {

given:
Expand Down

0 comments on commit ea802f9

Please sign in to comment.