Skip to content

Commit 0bf2324

Browse files
committed
Test: Fix unit test issues with "file-less" scripts.
Signed-off-by: kdesnos <[email protected]>
1 parent fa54d6a commit 0bf2324

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

modules/nextflow/src/main/groovy/nextflow/Session.groovy

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -873,19 +873,22 @@ class Session implements ISession {
873873
final ver = "dsl${NF.dsl1 ?'1' :'2'}"
874874
final processDefs = ScriptMeta.allProcessDefinitions()
875875
log.debug "Workflow process definitions [$ver]: ${processDefs.entrySet().collect{"${it.key} ${it.value}"}.join(', ')}"
876-
def resolvedNames = ScriptMeta.allResolvedProcessNames()
877876
// Add unaliased process names to the resolved names map
878-
final mainScriptMeta = ScriptMeta.get(script)
879-
mainScriptMeta.getLocalProcessNames().each { name ->
880-
// The processes defined in the main script cannot be included in
881-
// other scripts, as it would create a circular inclusion.
882-
// Hence, no need to check for the key existence in the map.
883-
def key = Map.entry(mainScriptMeta.getScriptPath(), name)
884-
def list = new ArrayList()
885-
list.add(name)
886-
resolvedNames.put(key, list)
877+
// Skip if script is undefined (for TESTING)
878+
if(script) {
879+
def resolvedNames = ScriptMeta.allResolvedProcessNames()
880+
final mainScriptMeta = ScriptMeta.get(script)
881+
mainScriptMeta.getLocalProcessNames().each { name ->
882+
// The processes defined in the main script cannot be included in
883+
// other scripts, as it would create a circular inclusion.
884+
// Hence, no need to check for the key existence in the map.
885+
def key = Map.entry(mainScriptMeta.getScriptPath(), name)
886+
def list = new ArrayList()
887+
list.add(name)
888+
resolvedNames.put(key, list)
889+
}
890+
log.debug "Resolved process names: ${resolvedNames.entrySet().join(', ')}"
887891
}
888-
log.debug "Resolved process names: ${resolvedNames.entrySet().join(', ')}"
889892

890893
validateConfig(names)
891894
}

modules/nextflow/src/main/groovy/nextflow/script/ProcessDef.groovy

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package nextflow.script
1818

19+
import java.nio.file.Paths
20+
1921
import groovy.transform.CompileStatic
2022
import groovy.util.logging.Slf4j
2123
import nextflow.Const
@@ -127,8 +129,9 @@ class ProcessDef extends BindableDef implements IterableDef, ChainableDef {
127129

128130
@Override
129131
ProcessDef cloneWithName(String name) {
130-
final path = ScriptMeta.get(owner).getScriptPath()
131-
ScriptMeta.addResolvedName(name, path, this.baseName)
132+
final path = ScriptMeta.get(owner)?.getScriptPath()
133+
final safePath = path?: Paths.get(".") // Default path for path-less scripts (for TESTING)
134+
ScriptMeta.addResolvedName(name, safePath, this.baseName)
132135
def result = clone()
133136
result.@processName = name
134137
result.@simpleName = stripScope(name)

0 commit comments

Comments
 (0)