Skip to content

Commit

Permalink
Merge pull request #69 from gagnonanthony/betcatcherror
Browse files Browse the repository at this point in the history
#40 - Catch exit code in stub of `betcrop/fslbetcrop`
  • Loading branch information
arnaudbore authored Dec 18, 2024
2 parents 8702891 + 4314d85 commit 68cde77
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 7 deletions.
20 changes: 13 additions & 7 deletions modules/nf-neuro/betcrop/fslbetcrop/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,9 @@ process BETCROP_FSLBETCROP {
"""

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"

"""
scil_dwi_extract_b0.py -h
bet -h
scil_volume_math.py -h
mrcalc -h
scil_volume_crop.py -h
touch ${prefix}__image_bet.nii.gz
touch ${prefix}__image_bet_mask.nii.gz
touch ${prefix}__image_boundingBox.pkl
Expand All @@ -89,5 +82,18 @@ process BETCROP_FSLBETCROP {
mrtrix: \$(mrcalc -version 2>&1 | sed -n 's/== mrcalc \\([0-9.]\\+\\).*/\\1/p')
fsl: \$(flirt -version 2>&1 | sed -n 's/FLIRT version \\([0-9.]\\+\\)/\\1/p')
END_VERSIONS
function handle_code () {
local code=\$?
ignore=( 1 )
exit \$([[ " \${ignore[@]} " =~ " \$code " ]] && echo 0 || echo \$code)
}
trap 'handle_code' ERR
bet
scil_dwi_extract_b0.py -h
scil_volume_math.py -h
mrcalc -h
scil_volume_crop.py -h
"""
}
28 changes: 28 additions & 0 deletions modules/nf-neuro/betcrop/fslbetcrop/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,32 @@ nextflow_process {

}

test("betcrop - fslbetcrop - stub-run") {

options "-stub-run"

when {
process {
"""
input[0] = LOAD_DATA.out.test_data_directory.map{
test_data_directory -> [
[ id:'test', single_end:false ], // meta map
file("\${test_data_directory}/dwi/dwi.nii.gz"),
file("\${test_data_directory}/dwi/dwi.bval"),
file("\${test_data_directory}/dwi/dwi.bvec")
]
}
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out.versions).match() }
)
}

}

}
12 changes: 12 additions & 0 deletions modules/nf-neuro/betcrop/fslbetcrop/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
{
"betcrop - fslbetcrop - stub-run": {
"content": [
[
"versions.yml:md5,cc45ab23921525536874337c1c88e5cf"
]
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.10.1"
},
"timestamp": "2024-12-12T10:33:04.50811"
},
"betcrop - fslbetcrop - dwi": {
"content": [
{
Expand Down

0 comments on commit 68cde77

Please sign in to comment.