Skip to content

Commit

Permalink
adding cmdEvalParams outputs in the hash
Browse files Browse the repository at this point in the history
e <[email protected]>
x test

Signed-off-by: jorgee <[email protected]>
  • Loading branch information
jorgee committed Nov 18, 2024
1 parent f0a4c52 commit d605b2b
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2203,6 +2203,13 @@ class TaskProcessor {
keys.add( it.value )
}

// add all eval statements in outputs
for( Map.Entry<OutParam,Object> it : task.outputs ) {
if( it.key instanceof CmdEvalParam ) {
keys.add(((CmdEvalParam) it.key).getTarget(task.context))
}
}

// add all variable references in the task script but not declared as input/output
def vars = getTaskGlobalVars(task)
if( vars ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package nextflow.processor

import nextflow.script.params.CmdEvalParam

import java.nio.file.FileSystems
import java.nio.file.Files
import java.nio.file.Path
Expand Down Expand Up @@ -1172,4 +1174,51 @@ class TaskProcessorTest extends Specification {

}

def 'should use eval outputs in hash' () {
given:
def session = Mock(Session) {
getDumpHashes() >> 'json'
getUniqueId() >> UUID.fromString('b69b6eeb-b332-4d2c-9957-c291b15f498c')
getBinEntries() >> ['foo.sh': Paths.get('/some/path/foo.sh'), 'bar.sh': Paths.get('/some/path/bar.sh')]
}
def outParam = Mock(CmdEvalParam) {
getTarget( _ as Map) >> 'foo --version'
}
def task1 = Spy(TaskRun) {
getSource() >> 'hello world'
lazyName() >> 'hello'
isContainerEnabled() >> false
getContainer() >> null
getSpackEnv() >> null
getCondaEnv() >> null
getConfig() >> Mock(TaskConfig)
getContext() >> [:]
}
def task2 = Spy(TaskRun) {
getSource() >> 'hello world'
lazyName() >> 'hello'
isContainerEnabled() >> false
getContainer() >> null
getSpackEnv() >> null
getCondaEnv() >> null
getConfig() >> Mock(TaskConfig)
getContext() >> [:]
}
task2.setOutput(outParam)

def processor = Spy(TaskProcessor){
getTaskGlobalVars( _ as TaskRun) >> [foo:'a', bar:'b']
}
processor.@session = session
processor.@config = Mock(ProcessConfig)

when:
def uuid1 = processor.createTaskHashKey(task1)
def uuid2 = processor.createTaskHashKey(task2)

then:
uuid1 != uuid2

}

}

0 comments on commit d605b2b

Please sign in to comment.