nf-core / nft-utils

nf-test utility functions
MIT License
9 stars 7 forks source link

Function to recursively check all detected files for a specific string #23

Open jfy133 opened 1 month ago

jfy133 commented 1 month ago

Currently there are two helper methods for checking output files:

While the of unstability fallback is good e.g. binary files, it's not as good as checking inside a file for consistent contents (E.g. when maybe it's only a single timestamp inside the file is unstable).

An intermediate check is to check for certain strings, e.g. maybe 'SUCCESSFUL RUN' at the end of a log.

It would be nice to have a function that does the same as the two existing methods, but with the string checking functionality.

tom-seqera commented 2 weeks ago

For simple cases, I think this can actually be done without any new functions using groovy to iterate the files returned by the existing getAllFilesFromDir and the existing nf-test file support:

then {
  def files = getAllFilesFromDir(...)
  files.each { file ->
    assert file.text.contains('SUCCESSFUL RUN')
  }
}
jfy133 commented 2 weeks ago

@TCLamnidis Tom wrote a load of code, and then deleted it because apparently a whole separate function might be overkill... maybe you can try the above with the eager tests?