We have a default.nf.test with the standard `stabl...
# nf-test
j
We have a default.nf.test with the standard
stable_name = getAllFilesFromDir...
from the template in the snapshot, and when one of our team members added some bits to the pipeline and updated the snapshot, a directory that should have been included in the
stable_name
list was missing and replaced by this:
Copy code
[
    "versions.yml:md5,2153811135866cc22a3f13c74568305f"
],
It looks really wrong since all the other entries in the
stable_name
list are simple strings, and just this one is a nested list with a string:hash. On my machine and on the Github Actions runner, the expected output with the directory name gets produced instead. Does anyone have any idea why this happens? I found this seemingly related question in #tools but I couldn't find any followup in here: https://nfcore.slack.com/archives/CE5LG7WMB/p1752845131146539
The snapshot error diff looks like this, for more context:
Copy code
expected                                                                        observed                                                                       
        "registration/ashlar",                                                          "registration/ashlar",                                                 
        "registration/ashlar/TEST1.ome.tif",                                            "registration/ashlar/TEST1.ome.tif",                                   
        "segmentation",                                                                 "segmentation",                                                        
        "segmentation/deepcell_mesmer",                                                 "segmentation/deepcell_mesmer",                                        
        "segmentation/deepcell_mesmer/mask_TEST1.tif",                                  "segmentation/deepcell_mesmer/mask_TEST1.tif",                         
        [                                                                               "summary",                                                             
            "versions.yml:md5,2153811135866cc22a3f13c74568305f"                                                                                                
        ],                                                                                                                                                     
        "summary/TEST1_samplesheet_mqc.tsv",                                            "summary/TEST1_samplesheet_mqc.tsv",                                   
        "summary/TEST1_xml_mqc.tsv",                                                    "summary/TEST1_xml_mqc.tsv",                                           
        "summary/markers_markersheet_mqc.tsv"                                           "summary/markers_markersheet_mqc.tsv"                                  
    ],                                                                              ],
m
versions.yml
should not be published
to be honest, the way I see it, for now nf-test is really meant to be run on local executor only
We would need to have some better testing and improvment on the nf-test side to make sure that other executors work as expected
(I might be totally wrong, as I said it's my own opinion)
Anyway could you share a PR or a repo to check the snapshots?
j
We can't reproduce this anymore, which might mean there was some unrelated issue that got cleared up locally on the machine in question. We'll keep any eye out for it returning and hopefully anyone else encountering the issue will be able to find this thread... πŸ™ƒ
m
I'll keep an eye out
j
Figured it out more or less, here’s a minimal reproducer: https://github.com/jmuhlich/nf-test-issue-293
Pretty sure it’s the same cause as the existing issue 293.
m
I think your repo is private
j
Quite right! Fixed.
This simulates a scenario where the snapshot has a list containing just "foo.txt", but the code under test fails to create that file. The desired result is mismatched snapshot with [ "foo.txt" ] expected and [ ] actual.
But I placed a trick foo.txt at the top level which causes the expected snapshot to contain [ "foo.txt:md5,..." ] instead.
πŸ‘€ 1
Files outside the nf-test outputDir and certainly outside the launchDir should not have any effect on the test run or snapshot evaluation
βž• 1
m
oh yeah, I think you NEED to put in the outdir to be at a specific location, so that it's empty when the test is run
j
I don't think that's it, the nf-test test execution harness defines its own temp outdir
the pipeline (and nextflow itself) concept of params.outdir is irrelevant
m
Yeah, but you're doing a pipeline test, so if you don't define the publishDir properly it will mess things up
j
Note the test doesn't actually generate any files, this it only evaluating snapshots
m
output of pipelines are file or stderr/stdout, you cannot capture channels at the pipeline level
so I think the issue belongs there
j
I mean the pipeline is empty
main.nf is
workflow { }
The test case is snapshotting a literal string path to simulate the file path a pipeline would have created.
m
yeah, but that's not the way it would be produce by a pipeline
j
I watched what
nft-utils
getAllFilesFromDir
returns and it's just a list of
java.lang.String
So I cut out the middleman and hard-coded a list of a single string
Copy code
then {
            assert snapshot(['foo.txt']).match()
        }
m
yeah, I think that's too smart
j
That create the same snapshot as when I had an actual foo.txt being generated by the pipeline
Which exhibited this same problem.. I kept cutting things back to see what the minimal boundary of the problem was
I can rework this into a "real" minimal pipeline with a module and publishdir and all, but it does the same thing
m
that's what I did for the test for `getAllFilesFromDir`: https://github.com/nf-core/nft-utils/blob/main/tests/getAllFilesFromDir/main.nf
that's my minimal pipeline
j
OK let me borrow that
m
and then the tests in https://github.com/nf-core/nft-utils/blob/main/tests/getAllFilesFromDir/main.nf.test, you'll see I use:
Copy code
params {
                outdir = "$outputDir"
            }
I do like your approach of cutting short, and I think it'll work great for modules/subworkflows tests but not pipeline ones
j
The problem reproduces with your test too πŸ™‚
(and your main.nf)
I just updated my repo with a copy of the nft-utils getAllFilesFromDir test and it also shows the issue
I just removed the second test from main.nf.test to simplify a bit, then changed main.nf to disable writing
stable_name.txt
. With only that change, the test run shows the expected snapshot difference with
stable_name
missing from the expected output.
m
Oooh
j
However I also checked in a rogue
stable_name.txt
at the top level, which breaks things
m
Very interesting
j
Copy code
Test [ba5e77af] 'getAllFilesFromDir' FAILED (1.488s)

  java.lang.RuntimeException: Different Snapshot:
  expected                                                                        observed                                                                       
  [                                                                               [                                                                              
      [                                                                               [                                                                          
          "pipeline_info",                                                                "pipeline_info",                                                       
          "stable",                                                                       "stable",                                                              
          "stable_content.txt",                                                           "stable_content.txt"                                                   
          "stable_name.txt:md5,d41d8cd98f00b204e9800998ecf8427e"                                                                                                 
      ],                                                                              ],                                                                         
      [                                                                               [                                                                          
          "stable_content.txt",                                                           "stable_content.txt"                                                   
          "stable_name.txt:md5,d41d8cd98f00b204e9800998ecf8427e"                                                                                                 
      ],                                                                              ],                                                                         
      [                                                                               [                                                                          
          "stable_content.txt:md5,f6d73f703cda1c725ea78369a6c3a48d"                       "stable_content.txt:md5,f6d73f703cda1c725ea78369a6c3a48d"              
      ]                                                                               ]                                                                          
  ]                                                                               ]
But again, this has nothing to do with nft-utils and getFilesFromDir since it reproduces the same way in my original super-minimal test.
m
yeah, so definitively an nf-test issue
good catch
j
I commented on nf-test issue 293 with a link to my reproduction and some explanation
m
Thanks a lot