Comments (14)
This answer can help as well, and probably more flexible.
from nf-test.
We are considering the following approach:
- We will leave
$outputDir
unchanged to maintain compatibility. - Users can continue using this pre-created folder, ensuring existing tests remain unaffected.
- Instead, we will introduce
$launchDir
, which will point to the directory where the Nextflow process was initiated. - As a result, the following variables will be available:
$baseDir -> /home/maxime/workspace/nf-core_sarek
(we will also support$projectDir
as an alias like in Nextflow)$launchDir -> /home/maxime/workspace/nf-core_sarek/.nf-test/tests/6b4fc92d7235947cf7ae249c9cd9ebf
$outputDir -> /home/maxime/workspace/nf-core_sarek/.nf-test/tests/6b4fc92d7235947cf7ae249c9cd9ebf/output
Since the Nextflow process is now started in the directory $launchDir
, you can set param.outdir = "results"
in the when
block and access the folder in the then
closure using path("$launchDir/results").
Your example:
nextflow_workflow {
name "Test workflow in main.nf"
script "main.nf"
workflow "MAIN"
test("MAIN: default test") {
when {
workflow {
"""
"""
}
params {
outdir = "results"
}
}
then {
assertAll(
{ assert workflow.success },
{ assert snapshot(path("$launchDir/results").list()).match("outputPath") }
)
}
}
}
The content of themd5sum.csv
file:
cat results/csv/md5sum.csv
results/test_1.fastq.gz.md5
We believe that this approach and the chosen variable names are consistent with Nextflow. Happy to hear your feedback.
from nf-test.
BTW, solved it for now with:
params {
outdir = baseDir.toURI().relativize(outputDir.toURI()).toString()
}
EDIT:
> cat /home/maxime/workspace/nf-core_sarek/.nf-test/tests/6b4fc92d7235947cf7ae249c9cd9ebf/meta/params.json
{"baseDir":"/home/maxime/workspace/nf-core_sarek","outputDir":"/home/maxime/workspace/nf-core_sarek/.nf-test/tests/6b4fc92d7235947cf7ae249c9cd9ebf/output","outdir":".nf-test/tests/6b4fc92d7235947cf7ae249c9cd9ebf/output"}%
from nf-test.
We could probably update the docs:
This part lead me to believe the path would be relative:
This variable points to the directory within the temporary test directory (
.nf-test/tests/<test-dir>/output/
).
from nf-test.
Hi,
Here's a tiny reproducible example: https://github.com/maxulysse/nf-test_66
When I run locally with nextflow run . --outdir results
I get:
$ cat results/csv/md5sum.csv
results/test_1.fastq.gz.md5
When I run with nf-test, since I can't use a relative outdir, I get:
cat .nf-test/tests/ed6d3e4396651c8a5a3aca14e4dce26f/output/csv/md5sum.csv
/home/max/workspace/nf-test_paths/.nf-test/tests/ed6d3e4396651c8a5a3aca14e4dce26f/output/test_1.fastq.gz.md5
from nf-test.
wonderful, I love it
from nf-test.
I would also add $moduleDir
(which points to the location of the module script) and $moduleTestDir
(which points to the location of the test script).
Potential use case: If a module contains its own test data in the modules folder, it would be possible to load the data via:
inputs[0]=file("$moduleTestDir/sample.fastq.gz"). // --> modules/local/my_module/tests/sample.fastq.gz
or
inputs[0]=file("$moduleDir/sample.fastq.gz"). // --> modules/local/my_module/sample.fastq.gz
from nf-test.
Can you remove the baseDir
from the outputDir
? This would have the desired effect, right?
from nf-test.
Hi,
Any update on that issue?
My tiny fix solves some issues for me, but not all of them
from nf-test.
Thanks 🙏
To be sure I got it right. the following output would fit?
cat .nf-test/tests/ed6d3e4396651c8a5a3aca14e4dce26f/output/csv/md5sum.csv
.nf-test/tests/ed6d3e4396651c8a5a3aca14e4dce26f/output/test_1.fastq.gz.md5
or did you prefer:
cat .nf-test/tests/ed6d3e4396651c8a5a3aca14e4dce26f/output/csv/md5sum.csv
output/test_1.fastq.gz.md5
ATM I am not sure what the best solution is: (a) update outputDir
to relative path or (b) add a new variable with the relative path. If (a) breaks existing testcases, it could be tricky for users to find the cause.
from nf-test.
option a
would be good if we're sure that the path is reproducible in a different environment (let's say my computer and GHA).
option b
would be closer to what we have in reality.
We're using a --outdir
params in nf-core to specify the output folder, so the issue was also to get --outdir
to point to a relative path within the nf-test framework.
from nf-test.
we usually have the test data in a separate repo, but I like where this is going
from nf-test.
We have just released RC1 of version 0.8.0 🎉
This is a pre-release and can be installed using the following command:
curl -fsSL https://code.askimed.com/install/nf-test | bash -s 0.8.0-rc1
If everything works as expected, please feel free to close this issue. Thanks for your support! 🙏
from nf-test.
Works as expected, thank you so much
from nf-test.
Related Issues (20)
- Weird behaviour when Gzipped files are empty HOT 4
- [Docs] Broken link for navigating to getting started HOT 1
- Automatic staging of `assets` `bin` and `lib` folders broken HOT 1
- Repeated 'permission denied' when running `nf-test clean` or `rm -rf .nf-test` HOT 2
- Add --target option to nf-test list HOT 2
- is there a way we can allow for deliberate snapshot matching? HOT 3
- Only run tests for changed files HOT 3
- Test file not created for workflow when workflow.onComplete is in main.nf HOT 1
- Can snapshots entries be made unique by `test-name + id` instead of just the `id` ?
- Problem when pipeline param is the same as nf-test param
- Broken link HOT 2
- bug: When an input is passed to output with no modification it causes the snapshot to have the absolute path HOT 1
- Access to output channels of unnamed/implicit workflow
- Keyword Arguments
- Allow capture and assertion of `.command.{err,out,log}`
- Conda environment reuse HOT 1
- Need the ability to skip md5 check for some files in snapshot HOT 1
- All tests' meta/output/work directories are deleted and recreated unnecessarily
- Caching of setup fixtures' results HOT 1
- nextflow.config required in my nf-test directory
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nf-test.