nf-test icon indicating copy to clipboard operation
nf-test copied to clipboard

[Feature] snapshot.matchStub()

Open GallVp opened this issue 1 year ago • 0 comments

Hi Team

Thank you for the amazing work on nf-test.

Would it be possible to add automated output matching of a test against its own stub version where the only difference is that the stub version runs with the -stub option?

I have tried to do this manually for the nf-core/FASTP module here: https://github.com/nf-core/modules/pull/4637 by create a snapshot out of the list of process outputs:

{
    assert snapshot(
        (
            [process.out.reads[0][0].toString()] + // meta
            process.out.reads.collect { file(it[1]).getName() } +
            process.out.json.collect { file(it[1]).getName() } +
            process.out.html.collect { file(it[1]).getName() } +
            process.out.log.collect { file(it[1]).getName() } +
            process.out.reads_fail.collect { file(it[1]).getName() } +
            process.out.reads_merged.collect { file(it[1]).getName() }
        ).sort()
    ).match("test_fastp_single_end-for_stub_match")
}

This can be abstracted into a function such as snapshot.matchStub(). It may also enable nf-test to partially auto generate stub code and suggest it to the tester. Such as:

touch ${prefix}.gff3
touch ${prefix}.report.html

...versions.yml...

GallVp avatar Dec 21 '23 02:12 GallVp