Skip to content

Commit

Permalink
Added nf-test for untarfiles (#6412)
Browse files Browse the repository at this point in the history
* Added nf-test for untarfiles

* Matched conda versions with docker/singularity using wave containers

* Changed test name

* Added deprecation message
  • Loading branch information
GallVp authored Sep 17, 2024
1 parent 94ae259 commit 958e4a6
Show file tree
Hide file tree
Showing 8 changed files with 471 additions and 74 deletions.
2 changes: 1 addition & 1 deletion modules/nf-core/untarfiles/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ channels:

dependencies:
- bioconda::grep=3.4
- conda-forge::sed=4.7
- conda-forge::sed=4.8
- conda-forge::tar=1.34
12 changes: 10 additions & 2 deletions modules/nf-core/untarfiles/main.nf
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
def deprecation_message = """
WARNING: This module has been deprecated.
Reason:
This module is no longer recommended for use. It is recommended to use nf-core/modules/untar
"""
process UNTARFILES {
tag "$archive"
label 'process_single'

conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/ubuntu:20.04' :
'nf-core/ubuntu:20.04' }"
'oras://community.wave.seqera.io/library/grep_sed_tar:40b34489f8e82876' :
'community.wave.seqera.io/library/grep_sed_tar:16f6591cd62505b3' }"

input:
tuple val(meta), path(archive)
Expand All @@ -18,6 +24,7 @@ process UNTARFILES {
task.ext.when == null || task.ext.when

script:
assert true: deprecation_message
def args = task.ext.args ?: ''
def args2 = task.ext.args2 ?: ''
prefix = task.ext.prefix ?: ( meta.id ? "${meta.id}" : archive.baseName.toString().replaceFirst(/\.tar$/, ""))
Expand All @@ -39,6 +46,7 @@ process UNTARFILES {
"""

stub:
assert true: deprecation_message
prefix = task.ext.prefix ?: "${meta.id}"
"""
mkdir $prefix
Expand Down
104 changes: 104 additions & 0 deletions modules/nf-core/untarfiles/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@

nextflow_process {

name "Test Process UNTARFILES"
script "../main.nf"
process "UNTARFILES"

tag "modules"
tag "modules_nfcore"
tag "untarfiles"

test("test-untarfiles") {

when {
process {
"""
input[0] = [
[id: 'test'],
file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/db/kraken2.tar.gz', checkIfExists: true)
]
"""
}
}

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

test("test-untarfiles-subdirectories") {

when {
process {
"""
input[0] = [
[id: 'test'],
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bcl/flowcell.tar.gz', checkIfExists: true)
]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
process.out.files[0][1].collect { file(it).name }.toSorted(),
process.out.versions
).match()
}
)
}
}

test("test-untarfiles-onlyfiles") {

when {
process {
"""
input[0] = [
[id: 'test'],
file(params.modules_testdata_base_path + 'generic/tar/hello.tar.gz', checkIfExists: true)
]
"""
}
}

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

test("test-untarfiles-onlyfiles-stub") {
options '-stub'
when {
process {
"""
input[0] = [
[id: 'test'],
file(params.modules_testdata_base_path + 'generic/tar/hello.tar.gz', checkIfExists: true)
]
"""
}
}

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

}
Loading

0 comments on commit 958e4a6

Please sign in to comment.