Skip to content

Commit cac11f9

Browse files
committed
Update e2e test
Signed-off-by: Ben Sherman <[email protected]>
1 parent c816360 commit cac11f9

File tree

7 files changed

+85
-11
lines changed

7 files changed

+85
-11
lines changed

modules/nextflow/src/main/groovy/nextflow/config/ConfigBuilder.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ class ConfigBuilder {
461461
* @param file The source config file/snippet
462462
* @return
463463
*/
464-
protected validate(ConfigObject config, file, String parent=null, List stack = new ArrayList()) {
464+
protected void validate(ConfigObject config, file, String parent=null, List stack = new ArrayList()) {
465465
for( String key : new ArrayList<>(config.keySet()) ) {
466466
final value = config.get(key)
467467
if( value instanceof ConfigObject ) {

modules/nextflow/src/main/groovy/nextflow/config/parser/v1/ConfigParserV1.groovy

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ class ConfigParserV1 implements ConfigParser {
110110

111111
private Grengine grengine
112112

113+
private Map<String,Object> declaredParams
114+
113115
@Override
114116
ConfigParser setProfiles(List<String> profiles) {
115117
final blockName = 'profiles'
@@ -129,7 +131,7 @@ class ConfigParserV1 implements ConfigParser {
129131

130132
@Override
131133
Map<String,Object> getDeclaredParams() {
132-
[:]
134+
declaredParams
133135
}
134136

135137
private Grengine getGrengine() {
@@ -469,6 +471,11 @@ class ConfigParserV1 implements ConfigParser {
469471
script.binding = binding
470472
script.run()
471473
config.merge(overrides)
474+
declaredParams = config.params as Map ?: [:]
475+
476+
// prevent error thrown by ConfigBuilder::validate()
477+
if( !config.params )
478+
config.remove('params')
472479

473480
return config
474481
}

modules/nextflow/src/main/groovy/nextflow/config/parser/v2/ConfigParserV2.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ class ConfigParserV2 implements ConfigParser {
140140
script.run()
141141

142142
final target = script.getTarget()
143+
// prevent error thrown by ConfigBuilder::validate()
143144
if( !target.params )
144145
target.remove('params')
145146
declaredProfiles = script.getDeclaredProfiles()

modules/nextflow/src/test/groovy/nextflow/config/parser/v1/ConfigParserV1Test.groovy

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ class ConfigParserV1Test extends Specification {
399399

400400
}
401401

402-
def 'should return the set of visited block names' () {
402+
def 'should return the set of declared profiles' () {
403403

404404
given:
405405
def text = '''
@@ -426,6 +426,35 @@ class ConfigParserV1Test extends Specification {
426426
slurper.getDeclaredProfiles() == ['alpha','beta'] as Set
427427
}
428428

429+
def 'should return the map of declared params' () {
430+
431+
given:
432+
def text = '''
433+
params {
434+
a = 1
435+
b = 2
436+
}
437+
438+
profiles {
439+
alpha {
440+
params.a = 3
441+
}
442+
}
443+
'''
444+
445+
when:
446+
def slurper = new ConfigParserV1().setProfiles(['standard'])
447+
slurper.parse(text)
448+
then:
449+
slurper.getDeclaredParams() == [a: 1, b: 2]
450+
451+
when:
452+
slurper = new ConfigParserV1().setProfiles(['alpha'])
453+
slurper.parse(text)
454+
then:
455+
slurper.getDeclaredParams() == [a: 3, b: 2]
456+
}
457+
429458
def 'should disable includeConfig parsing' () {
430459
given:
431460
def text = '''

modules/nextflow/src/test/groovy/nextflow/config/parser/v2/ConfigParserV2Test.groovy

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ class ConfigParserV2Test extends Specification {
374374

375375
}
376376

377-
def 'should return the set of parsed profiles' () {
377+
def 'should return the set of declared profiles' () {
378378

379379
given:
380380
def text = '''
@@ -401,6 +401,35 @@ class ConfigParserV2Test extends Specification {
401401
slurper.getDeclaredProfiles() == ['alpha','beta'] as Set
402402
}
403403

404+
def 'should return the map of declared params' () {
405+
406+
given:
407+
def text = '''
408+
params {
409+
a = 1
410+
b = 2
411+
}
412+
413+
profiles {
414+
alpha {
415+
params.a = 3
416+
}
417+
}
418+
'''
419+
420+
when:
421+
def slurper = new ConfigParserV2().setParams([c: 4])
422+
slurper.parse(text)
423+
then:
424+
slurper.getDeclaredParams() == [a: 1, b: 2]
425+
426+
when:
427+
slurper = new ConfigParserV2().setParams([c: 4]).setProfiles(['alpha'])
428+
slurper.parse(text)
429+
then:
430+
slurper.getDeclaredParams() == [a: 3, b: 2]
431+
}
432+
404433
def 'should ignore config includes when specified' () {
405434
given:
406435
def text = '''

tests/checks/params-dsl.nf/.checks

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
11

22
echo "Test successful run"
3-
$NXF_RUN --input ./data | tee stdout
3+
$NXF_RUN --input ./data &> stdout
4+
5+
[[ $(grep -c 'params.input = [./data]' stdout) == 1 ]] || false
6+
[[ $(grep -c 'params.save_intermeds = false' stdout) == 1 ]] || false
47

5-
echo
68
echo "Test missing required param"
7-
$NXF_RUN | tee stdout
9+
$NXF_RUN &> stdout
10+
11+
[[ $(grep -c 'Parameter `input` is required' stdout) == 1 ]] || false
812

9-
echo
1013
echo "Test overwrite script param from config profile"
11-
$NXF_RUN -c ../../params-dsl.config -profile test | tee stdout
14+
$NXF_RUN -c ../../params-dsl.config -profile test &> stdout
15+
16+
[[ $(grep -c 'params.input = [alpha, beta, delta]' stdout) == 1 ]] || false
17+
[[ $(grep -c 'params.save_intermeds = true' stdout) == 1 ]] || false
1218

13-
echo
1419
echo "Test invalid param"
15-
$NXF_RUN --inputs ./data | tee stdout
20+
$NXF_RUN --inputs ./data &> stdout
21+
22+
[[ $(grep -c 'Parameter `inputs` was specified' stdout) == 1 ]] || false

tests/params-dsl.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ params.outdir = 'results'
44
profiles {
55
test {
66
params.input = 'alpha,beta,delta'
7+
params.save_intermeds = true
78
}
89
}

0 commit comments

Comments
 (0)