Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simplify assertion for stable files in a folder #7462

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions modules/nf-core/catpack/prepare/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ nextflow_process {
tag "catpack"
tag "catpack/prepare"

test("metagenome -sarscov2 - fasta") {
test("metagenome - sarscov2 - fasta") {

when {
process {
Expand All @@ -24,24 +24,27 @@ nextflow_process {
}

then {
def stablefiles = []
file(process.out.db.get(0).get(1)).eachFileRecurse{ file -> if (!file.isDirectory() && !["database.dmnd", "database.log", "database.fastaid2LCAtaxid", "database.taxids_with_multiple_offspring"].find {file.toString().endsWith(it)}) {stablefiles.add(file)} }
def unstablefiles = []
file(process.out.db.get(0).get(1)).eachFileRecurse{ file -> if (["database.dmnd", "database.log", "database.fastaid2LCAtaxid", "database.taxids_with_multiple_offspring"].find {file.toString().endsWith(it)}) {unstablefiles.add(file.getName().toString())} }
def allFiles = file(process.out.db.get(0).get(1)).listFiles().sort()
// Filter out all files that have unstable content (ie: timestamp, non-deterministic or any other variable content)
def unstableNames = ["database.dmnd", "database.fastaid2LCAtaxid", "database.log", "database.taxids_with_multiple_offspring"]
// Filter out the unstable files
def stableFiles = allFiles.grep { file -> !unstableNames.contains(file.name) }
// Collect the stable file names
def stableNames = allFiles.grep { file -> unstableNames.contains(file.name) }.collect { file -> file.name }

assertAll(
{ assert process.success },
{ assert snapshot(
stablefiles.sort(),
unstablefiles.sort(),
stableFiles,
stableNames,
process.out.taxonomy,
process.out.versions
).match() }
)
}

}

test("metagenome -sarscov2 - fasta - stub") {
test("metagenome - sarscov2 - fasta - stub") {

options "-stub"

Expand All @@ -62,7 +65,5 @@ nextflow_process {
{ assert snapshot(process.out).match() }
)
}

}

}
12 changes: 6 additions & 6 deletions modules/nf-core/catpack/prepare/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"metagenome -sarscov2 - fasta": {
"metagenome - sarscov2 - fasta": {
"content": [
[

Expand Down Expand Up @@ -28,9 +28,9 @@
"nf-test": "0.9.2",
"nextflow": "24.10.4"
},
"timestamp": "2025-01-25T16:19:17.838393903"
"timestamp": "2025-02-10T17:04:51.995020979"
},
"metagenome -sarscov2 - fasta - stub": {
"metagenome - sarscov2 - fasta - stub": {
"content": [
{
"0": [
Expand Down Expand Up @@ -88,9 +88,9 @@
}
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.10.2"
"nf-test": "0.9.2",
"nextflow": "24.10.4"
},
"timestamp": "2025-01-19T07:53:12.595910196"
"timestamp": "2025-02-10T16:13:53.612506113"
}
}
50 changes: 34 additions & 16 deletions modules/nf-core/krakenuniq/build/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,33 @@ nextflow_process {
}

then {
def stablefiles = []
file(process.out.db.get(0).get(1)).eachFileRecurse{ file -> if (!file.isDirectory() && !["database-build.log", "database.report.tsv", "timestamp", "taxdump.tar.gz", "names.dmp", "nodes.dmp"].find {file.toString().endsWith(it)}) {stablefiles.add(file)} }
def unstablefiles = []
file(process.out.db.get(0).get(1)).eachFileRecurse{ file -> if (["database-build.log", "database.report.tsv", "timestamp", "taxdump.tar.gz", "names.dmp", "nodes.dmp"].find {file.toString().endsWith(it)}) {unstablefiles.add(file.getName().toString())} }
def allFiles = []
file(process.out.db.get(0).get(1)).eachFileRecurse{ file -> if (!file.isDirectory()) {allFiles.add(file)} }

def allFolders = []
file(process.out.db.get(0).get(1)).eachFileRecurse{ folder -> if (folder.isDirectory()) {allFolders.add(folder)} }

// Defile all files that have unstable content (ie: timestamp, non-deterministic or any other variable content)
def unstableNames = ["database-build.log", "database.report.tsv", "names.dmp", "nodes.dmp", "taxdump.tar.gz", "timestamp"]
// Filter out the unstable files
def stableFiles = allFiles.grep { file -> !unstableNames.contains(file.name) }.sort()
// Collect the stable file names
def stableNames = allFiles.grep { file -> unstableNames.contains(file.name) }.collect { file -> file.name }
stableNames = (stableNames + allFolders.collect { file -> file.name }).sort()

assertAll(
{ assert process.success },
{ assert snapshot(
stablefiles.sort(),
unstablefiles.sort(),
stableFiles,
stableNames,
process.out.versions
).match()
}
)
}

}

test("sarscov2 - fasta - nocleanup") {
test("sarscov2 - fasta - nocleanup") {

when {
process {
Expand All @@ -87,21 +96,30 @@ test("sarscov2 - fasta - nocleanup") {
}

then {
def stablefiles = []
file(process.out.db.get(0).get(1)).eachFileRecurse{ file -> if (!file.isDirectory() && !["database-build.log", "database.report.tsv", "timestamp", "taxdump.tar.gz", "names.dmp", "nodes.dmp"].find {file.toString().endsWith(it)}) {stablefiles.add(file)} }
def unstablefiles = []
file(process.out.db.get(0).get(1)).eachFileRecurse{ file -> if (["database-build.log", "database.report.tsv", "timestamp", "taxdump.tar.gz", "names.dmp", "nodes.dmp"].find {file.toString().endsWith(it)}) {unstablefiles.add(file.getName().toString())} }
def allFiles = []
file(process.out.db.get(0).get(1)).eachFileRecurse{ file -> if (!file.isDirectory()) {allFiles.add(file)} }

def allFolders = []
file(process.out.db.get(0).get(1)).eachFileRecurse{ folder -> if (folder.isDirectory()) {allFolders.add(folder)} }

// Defile all files that have unstable content (ie: timestamp, non-deterministic or any other variable content)
def unstableNames = ["database-build.log", "database.report.tsv", "names.dmp", "nodes.dmp", "taxdump.tar.gz", "timestamp"]
// Filter out the unstable files
def stableFiles = allFiles.grep { file -> !unstableNames.contains(file.name) }.sort()
// Collect the stable file names
def stableNames = allFiles.grep { file -> unstableNames.contains(file.name) }.collect { file -> file.name }
stableNames = (stableNames + allFolders.collect { file -> file.name }).sort()

assertAll(
{ assert process.success },
{ assert snapshot(
stablefiles.sort(),
unstablefiles.sort(),
stableFiles,
stableNames,
process.out.versions
).match()
}
)
}

}

test("sarscov2 - fasta - stub") {
Expand All @@ -120,7 +138,7 @@ test("sarscov2 - fasta - nocleanup") {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
)
}
}
}
21 changes: 12 additions & 9 deletions modules/nf-core/krakenuniq/build/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -60,45 +60,48 @@
"library-files.txt:md5,8a9817d2de8465eb436aa3aa8696a717",
"genome.fasta:md5,6e9fe4042a72f2345f644f239272b7e6",
"seqid2taxid.map:md5,fe738f2333d57dde0db32239c04a93b8",
"taxDB:md5,37ea954363803b13c2c9f6ae36fc81c7"
"taxDB:md5,f9969245ac82fa42682289f5b0b6c67a"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, so I'm concerned that taxDB is actually not stable

],
[
"database-build.log",
"database.report.tsv",
"library",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I rescued library as a folder name

"names.dmp",
"nodes.dmp",
"taxdump.tar.gz",
"taxonomy",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and taxonomy

"timestamp"
],
[
"versions.yml:md5,b7fb6c70957b2e6b6b810757928d0325"
]
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.10.2"
"nf-test": "0.9.2",
"nextflow": "24.10.4"
},
"timestamp": "2025-01-17T08:29:04.791324194"
"timestamp": "2025-02-10T18:41:57.14608044"
},
"sarscov2 - fasta": {
"content": [
[
"database.idx:md5,f5298aa4215c956d2f737b5988721a24",
"database.kdb:md5,46542be19979e867075f9e455a314e00",
"database0.kdb:md5,46542be19979e867075f9e455a314e00",
"taxDB:md5,37ea954363803b13c2c9f6ae36fc81c7"
"taxDB:md5,f9969245ac82fa42682289f5b0b6c67a"
],
[

"library",
"taxonomy"
],
[
"versions.yml:md5,b7fb6c70957b2e6b6b810757928d0325"
]
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.10.2"
"nf-test": "0.9.2",
"nextflow": "24.10.4"
},
"timestamp": "2025-01-17T08:28:18.051752599"
"timestamp": "2025-02-10T18:44:37.662290616"
}
}
Loading