Skip to content

Commit dcffb25

Browse files
committed
fix wrong output selected from produce when suffix matches
1 parent 31531cf commit dcffb25

File tree

4 files changed

+34
-1
lines changed

4 files changed

+34
-1
lines changed

src/main/groovy/bpipe/SelectFromPredefinedFileNameMapper.groovy

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ class SelectFromPredefinedFileNameMapper implements FileNameMapper {
2727

2828
final String name = segments[-1]
2929
final String dotName = '.' + name
30-
final endExt = segments.join('.')
30+
31+
// note: without the leading dot, can result in incorrect substring matches,
32+
// eg: .gvcf matches .vcf
33+
final endExt = '.' + segments.join('.')
3134

3235
String result = this.overrideOutputs.find {
3336
String.valueOf(it).endsWith(endExt)

tests/multiext/cleanup.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rm -f *.world.* foo.gvcf.gz foo.vcf.gz

tests/multiext/run.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
source ../testsupport.sh
2+
3+
run
4+
5+
grep -q 'foo.vcf.gz .* foo.vcf.world.txt' test.out || err "Selected wrong output from produce when only partial suffix matches"
6+
7+
exists foo.vcf.world.txt
8+
9+

tests/multiext/test.groovy

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
3+
hello = {
4+
produce('foo.gvcf.gz', 'foo.vcf.gz') {
5+
exec """
6+
touch $output.gvcf.gz $output.vcf.gz
7+
"""
8+
}
9+
}
10+
11+
world = {
12+
exec """
13+
cp -v $input.vcf.gz $output.txt
14+
"""
15+
}
16+
17+
run {
18+
hello + world
19+
}
20+

0 commit comments

Comments
 (0)