Skip to content

Commit b480ee0

Browse files
Fix ParamsMap copyWith param aliases (#4188)
Signed-off-by: Ben Sherman <[email protected]> Signed-off-by: Paolo Di Tommaso <[email protected]> Co-authored-by: Paolo Di Tommaso <[email protected]>
1 parent 4d5bc21 commit b480ee0

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

modules/nextflow/src/main/groovy/nextflow/script/ScriptBinding.groovy

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,11 @@ class ScriptBinding extends WorkflowBinding {
239239
}
240240

241241
private ParamsMap allowNames(Set names) {
242-
readOnlyNames.removeAll(names)
242+
for( String name : names ) {
243+
final name2 = name.contains('-') ? hyphenToCamelCase(name) : camelCaseToHyphen(name)
244+
readOnlyNames.remove(name)
245+
readOnlyNames.remove(name2)
246+
}
243247
return this
244248
}
245249

modules/nextflow/src/test/groovy/nextflow/script/ScriptBindingTest.groovy

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,23 +144,31 @@ class ScriptBindingTest extends Specification {
144144
def map = new ScriptBinding.ParamsMap()
145145
map['alpha'] = 0
146146
map['alpha'] = 1
147+
map['alphaBeta'] = 0
148+
map['alphaBeta'] = 1
147149
map['delta'] = 2
148150
map['gamma'] = 3
149151
then:
150152
map.alpha == 0
153+
map.alphaBeta == 0
154+
map.'alpha-beta' == 0
151155
map.delta == 2
152156
map.gamma == 3
153157

154158
when:
155-
def copy = map.copyWith(foo:1, omega: 9)
159+
def copy = map.copyWith(foo:1, alphaBeta: 4, omega: 9)
156160
then:
157161
copy.foo == 1
162+
copy.alphaBeta == 4
163+
copy.'alpha-beta' == 4
158164
copy.delta == 2
159165
copy.gamma == 3
160166
copy.omega == 9
161167
and:
162168
// source does not change
163169
map.alpha == 0
170+
map.alphaBeta == 0
171+
map.'alpha-beta' == 0
164172
map.delta == 2
165173
map.gamma == 3
166174
!map.containsKey('omega')

validation/google_credentials.gpg

-1.69 KB
Binary file not shown.

0 commit comments

Comments
 (0)