Skip to content

Commit

Permalink
Fix Trace file option is not honoured #1217
Browse files Browse the repository at this point in the history
  • Loading branch information
pditommaso committed Jul 6, 2019
1 parent 8cef0e3 commit c84135d
Show file tree
Hide file tree
Showing 2 changed files with 160 additions and 19 deletions.
Expand Up @@ -508,36 +508,31 @@ class ConfigBuilder {
if( !(config.trace instanceof Map) )
config.trace = [:]
config.trace.enabled = true
if( !config.trace.file )
config.trace.file = cmdRun.withTrace

config.trace.file = cmdRun.withTrace
}

// -- sets report report options
if( cmdRun.withReport ) {
if( !(config.report instanceof Map) )
config.report = [:]
config.report.enabled = true
if( !config.report.file )
config.report.file = cmdRun.withReport
config.report.file = cmdRun.withReport
}

// -- sets timeline report options
if( cmdRun.withTimeline ) {
if( !(config.timeline instanceof Map) )
config.timeline = [:]
config.timeline.enabled = true
if( !config.timeline.file )
config.timeline.file = cmdRun.withTimeline
config.timeline.file = cmdRun.withTimeline
}

// -- sets DAG report options
if( cmdRun.withDag ) {
if( !(config.dag instanceof Map) )
config.dag = [:]
config.dag.enabled = true
if( !config.dag.file )
config.dag.file = cmdRun.withDag
config.dag.file = cmdRun.withDag
}

if( cmdRun.withNotification ) {
Expand All @@ -557,8 +552,7 @@ class ConfigBuilder {
if( !(config.weblog instanceof Map) )
config.weblog = [:]
config.weblog.enabled = true
if ( !config.weblog.url )
config.weblog.url = cmdRun.withWebLog
config.weblog.url = cmdRun.withWebLog
}


Expand Down
Expand Up @@ -610,49 +610,191 @@ class ConfigBuilderTest extends Specification {
given:
def env = [:]
def config = new ConfigObject()
def builder = [:] as ConfigBuilder
when:
config.trace.enabled = true
def config = new ConfigObject()
builder.configRunOptions(config, env, new CmdRun())
then:
config.trace instanceof Map
config.trace.enabled
!config.trace.enabled
!config.trace.file
when:
config = new ConfigObject()
builder.configRunOptions(config, env, new CmdRun(withTrace: 'some-file'))
then:
config.trace instanceof Map
config.trace.enabled
config.trace.file == 'some-file'
when:
config = new ConfigObject()
config.trace.file = 'foo.txt'
builder.configRunOptions(config, env, new CmdRun(withTrace: 'bar.txt'))
then: // command line should override the config file
config.trace instanceof Map
config.trace.enabled
config.trace.file == 'bar.txt'
}
def 'should set session timeline options' () {
def 'should set session report options' () {
given:
def env = [:]
def builder = [:] as ConfigBuilder
when:
def config = new ConfigObject()
builder.configRunOptions(config, env, new CmdRun())
then:
!config.report
when:
config = new ConfigObject()
config.report.file = 'foo.html'
builder.configRunOptions(config, env, new CmdRun())
then:
config.report instanceof Map
!config.report.enabled
config.report.file == 'foo.html'
when:
config = new ConfigObject()
builder.configRunOptions(config, env, new CmdRun(withReport: 'my-report.html'))
then:
config.report instanceof Map
config.report.enabled
config.report.file == 'my-report.html'
when:
config = new ConfigObject()
config.report.file = 'this-report.html'
builder.configRunOptions(config, env, new CmdRun(withReport: 'my-report.html'))
then:
config.report instanceof Map
config.report.enabled
config.report.file == 'my-report.html'
}
def 'should set session dag options' () {
given:
def env = [:]
def builder = [:] as ConfigBuilder
when:
def config = new ConfigObject()
builder.configRunOptions(config, env, new CmdRun())
then:
!config.dag
when:
config = new ConfigObject()
config.dag.file = 'foo-dag.html'
builder.configRunOptions(config, env, new CmdRun())
then:
config.dag instanceof Map
!config.dag.enabled
config.dag.file == 'foo-dag.html'
when:
config = new ConfigObject()
builder.configRunOptions(config, env, new CmdRun(withDag: 'my-dag.html'))
then:
config.dag instanceof Map
config.dag.enabled
config.dag.file == 'my-dag.html'
when:
config = new ConfigObject()
config.dag.file = 'this-dag.html'
builder.configRunOptions(config, env, new CmdRun(withDag: 'my-dag.html'))
then:
config.dag instanceof Map
config.dag.enabled
config.dag.file == 'my-dag.html'
}
def 'should set session weblog options' () {
given:
def env = [:]
def builder = [:] as ConfigBuilder
when:
def config = new ConfigObject()
builder.configRunOptions(config, env, new CmdRun())
then:
!config.weblog
when:
config = new ConfigObject()
config.weblog.url = 'http://bar.com'
builder.configRunOptions(config, env, new CmdRun())
then:
config.weblog instanceof Map
!config.weblog.enabled
config.weblog.url == 'http://bar.com'
when:
config = new ConfigObject()
builder.configRunOptions(config, env, new CmdRun(withWebLog: 'http://foo.com'))
then:
config.weblog instanceof Map
config.weblog.enabled
config.weblog.url == 'http://foo.com'
when:
config = new ConfigObject()
config.weblog.enabled = true
config.weblog.url = 'http://bar.com'
builder.configRunOptions(config, env, new CmdRun(withWebLog: 'http://foo.com'))
then:
config.weblog instanceof Map
config.weblog.enabled
config.weblog.url == 'http://foo.com'
}
def 'should set session timeline options' () {
given:
def env = [:]
def builder = [:] as ConfigBuilder
when:
def config = new ConfigObject()
builder.configRunOptions(config, env, new CmdRun())
then:
!config.timeline
when:
config.timeline.enabled = true
config = new ConfigObject()
config.timeline.file = 'my-file.html'
builder.configRunOptions(config, env, new CmdRun())
then:
config.timeline instanceof Map
!config.timeline.enabled
config.timeline.file == 'my-file.html'
when:
config = new ConfigObject()
builder.configRunOptions(config, env, new CmdRun(withTimeline: 'my-timeline.html'))
then:
config.timeline instanceof Map
config.timeline.enabled
!config.timeline.file
config.timeline.file == 'my-timeline.html'
when:
config = new ConfigObject()
config.timeline.enabled = true
config.timeline.file = 'this-timeline.html'
builder.configRunOptions(config, env, new CmdRun(withTimeline: 'my-timeline.html'))
then:
config.timeline instanceof Map
Expand All @@ -661,15 +803,14 @@ class ConfigBuilderTest extends Specification {
}
def 'SHOULD SET `RESUME` OPTION'() {
given:
def env = [:]
def config = new ConfigObject()
def builder = [:] as ConfigBuilder
when:
def config = new ConfigObject()
builder.configRunOptions(config, env, new CmdRun())
then:
!config.isSet('resume')
Expand All @@ -688,6 +829,12 @@ class ConfigBuilderTest extends Specification {
then:
config.resume == 'xxx-yyy'
when:
config = new ConfigObject()
config.resume ='this-that'
builder.configRunOptions(config, env, new CmdRun(resume: 'xxx-yyy'))
then:
config.resume == 'xxx-yyy'
}
def 'should set `workDir`' () {
Expand Down

0 comments on commit c84135d

Please sign in to comment.