Sometimes the pipeline outputs are not stable and thus snapshot(path("${outputDir}").list())
will not be enough since the md5sums created will be different. This snippet shows an alternative way to check if all files in your output folder exist, have the correct name and are in the right subfolders.
A recursive function is used to be able to get the correct paths to all files in the output folder. Paste this function at the end of your main.nf.test
file:
def getRecursiveFileNames(fileOrDir, outputDir) {
if(file(fileOrDir.toString()).isDirectory()) {
return fileOrDir.list().collect { getRecursiveFileNames(it, outputDir) }
}
return fileOrDir.toString().replace("${outputDir}/", "")
}
Apply the function in your assertions in the following way:
nextflow_pipeline {
name "Get all relative paths of the output directory without checking md5sums"
script "main.nf"
test("Get all relative paths of the output directory without checking md5sums") {
when {
params {
outdir = outputDir
}
}
then {
assert snapshot(
path("${outputDir}")
.list()
.collect { getRecursiveFileNames(it, outputDir) }
.flatten()
).match("relative paths")
}
}
}
An example snapshot is available at