Dear all, is it possible to write plain java/groov...
# nf-test
p
Dear all, is it possible to write plain java/groovy in the setup section instead of a nf code ? Something like:
Copy code
setup {
script:
"""
Files.writeString(Paths.get("test1.bed"), "chr1\t10\t100\n");
"""
}
Thank you
m
I put lots of things in a utils folder
so I'd say that you should be able to do something along these lines
@Sateesh_Peri might have more insight than me on that, given his initial code in #CP3RJSMF0 was my inspiration for what I put in #CGFUX04HZ : https://github.com/nf-core/sarek/blob/dev/tests/lib/UTILS.groovy https://github.com/nf-core/sarek/blob/dev/tests/aligner-bwa-mem.nf.test
s
no script needed in the setup block and also groovy outside setup is also cool party groovy
🙏 1
n
Yes it's pretty flexible 🙂 I don't remember who anymore but someone made setup blocks entirely using groovy code
🙏 1
p
@Maxime Garcia Thank you , I'll try this !
j
Yes, you can write whatever arbitrary Groovy you want. I use it to stage database files prior to the test: https://github.com/sanger-tol/metagenomeassembly/blob/main/tests/default.nf.test
👍 1
p
@Jim Downie thanks !
j
One suggestion - if you're writing any files for the test, you can use the variable
$launchDir
which points to the directory
.nf-test/tests/<hash>/
, which makes sure that the files stay contained to the specific test and makes cleanup nice and easy.
Note also the undocumented
cleanup {}
block that runs after the test that you can use to clean up anything you did that you don't want to persist!
🙇 1
✅ 1
m
PR to docs, please 🙏 😉