Fix Issue #200: Generate command fails with workflow.onComplete/onError lifecycle hooks#363
Conversation
Co-authored-by: Copilot <copilot@github.com>
nvnieuwk
left a comment
There was a problem hiding this comment.
Thanks for your contribution! Could you also update the patterns for process (getProcessNames) and function (getFunctionNames) name fetching?
Co-authored-by: Copilot <copilot@github.com>
|
@nvnieuwk sure thing. I just pushed the requested changes, here is a summary:
Test Results:
All three regex patterns (process, function, workflow) now consistently:
|
nvnieuwk
left a comment
There was a problem hiding this comment.
LGTM, I'll merge once the tests pass
Thank you so much for this contribution!
Description
Fixes an issue where
nf-test generatecommand would fail when a workflow contains Nextflow lifecycle hook calls likeworkflow.onComplete,workflow.onError, orworkflow.onSuccess. The command would incorrectly identify these lifecycle hook blocks as separate named workflows, causing the generator to skip test file creation.Root Cause
The regex pattern in
NextflowScript.getWorkflowNames()was too greedy:When parsing a file with lifecycle hooks, it would match both the actual workflow definition and the lifecycle hook blocks, incorrectly counting them as multiple workflows. The generator would then skip generation because it expects exactly one named workflow per file.
Solution
Updated the regex pattern to only match valid workflow identifiers (not dot notation):
This pattern:
Changes
Core Fix:
NextflowScript.java- UpdatedgetWorkflowNames()regex patternTests:
NextflowScriptTest.java- Added 4 unit tests:testGetWorkflowNamesIgnoresOnComplete()testGetWorkflowNamesIgnoresOnError()testGetWorkflowNamesIgnoresOnSuccess()testGetWorkflowNamesIgnoresMultipleLifecycleHooks()Test Data:
lifecycle_hooks.nf- Example workflow with lifecycle hookslifecycle_hooks.nf.test- Test case for the workflowTesting
✅ Unit Tests: All 34 NextflowScriptTest tests pass (including 4 new tests for this fix)
✅ Integration Tests: GenerateTestsCommandTest passes (6/6)
✅ Manual Verification: Confirmed the generate command now successfully handles workflows with lifecycle hooks
Example
Before (would fail):
After (works):
Related Issues
Fixes #200