withTrace nf-test option redundant with nextflow.config
Hello! As always, thank you for the excellent work on this tool. It's really taken Nextflow development to the next level (😝).
However, I'd like to suggest a change to the config. Currently, it supports a boolean option, withTrace, to indicate whether to perform tracing. It seems that the option was added in response to #9 to support situations when procps is not available. When set to true, nf-test sets --with-trace trace.csv on the Nextflow CLI command.
This causes two issues, one is that it overrides the trace settings in the project nextflow.config and test nextflow.config (i.e., the one pointed to by nf-test.config). So even if the trace file is expected to have a different name or location, since CLI options have the highest priority the trace is saved as trace.csv (which is actually a misnomer since it's tab-separated by default). In my case, I have custom logic in an onComplete closure that expects a specific filename and structure for the trace file as defined in nextflow.config, which throws an error when the file isn't found (although the tests still pass since a failing event closure doesn't cause the workflow to fail).
Relatedly, the withTrace option is redundant since you can put the same config in the test-specific nextflow.config. When #9 was raised, I think this would have been a more natural solution. Although, I believe that the current behavior was designed so that nf-test knows where to find and how to parse the trace file so that workflow.trace works.
My suggestion is to deprecate this option in favor of recommending users use the test folder nextflow.config to configure tracing for tests differently from production runs. And rather than hardcoding the trace file name and location, let users specify the name to look for in nf-test.config and/or allow per test specification. Then, throw an error if a test tries to access workflow.trace when no trace file was found.
For my onComplete closure testing problem, I know of two workarounds:
- Disable the
onCompleteclosure by settingworkflow.onComplete = {}. This kind of works, but makes it impossible to test aspects of theonCompletebehavior. - Set
withTrace = falseinnf-test.config. This allows the includednextflow.configfrom the project to control tracing, which then allows theonCompleteclosure to run successfully. However, this disablesworkflow.trace, which makes other kinds of testing more challenging.