|
16 | 16 |
|
17 | 17 | package nextflow.processor |
18 | 18 |
|
| 19 | +import java.nio.file.Files |
19 | 20 | import java.nio.file.Path |
20 | 21 |
|
21 | 22 | import nextflow.Session |
22 | 23 | import nextflow.script.ProcessConfig |
23 | 24 | import spock.lang.Specification |
| 25 | +import spock.lang.TempDir |
24 | 26 | /** |
25 | 27 | * |
26 | 28 | * @author Paolo Di Tommaso <paolo.ditommaso@gmail.com> |
27 | 29 | */ |
28 | 30 | class TaskHasherTest extends Specification { |
29 | 31 |
|
| 32 | + @TempDir |
| 33 | + Path tempDir |
| 34 | + |
30 | 35 | def 'should compute unique task hash' () { |
31 | 36 |
|
32 | 37 | given: |
@@ -94,6 +99,55 @@ class TaskHasherTest extends Specification { |
94 | 99 | result.contains(Path.of('/some/path/bar.sh')) |
95 | 100 | } |
96 | 101 |
|
| 102 | + def 'should include referenced module bin files in the task hash' () { |
| 103 | + |
| 104 | + given: |
| 105 | + def moduleBin = tempDir.resolve('resources/usr/bin') |
| 106 | + Files.createDirectories(moduleBin) |
| 107 | + def script = moduleBin.resolve('foo.sh') |
| 108 | + Files.writeString(script, 'echo first version\n') |
| 109 | + script.toFile().setExecutable(true) |
| 110 | + def session = Mock(Session) { |
| 111 | + getUniqueId() >> UUID.fromString('b69b6eeb-b332-4d2c-9957-c291b15f498c') |
| 112 | + getBinEntries() >> [:] |
| 113 | + } |
| 114 | + def config = Mock(ProcessConfig) { |
| 115 | + getHashMode() >> null |
| 116 | + } |
| 117 | + def processor = Mock(TaskProcessor) { |
| 118 | + getName() >> 'hello' |
| 119 | + getSession() >> session |
| 120 | + getConfig() >> config |
| 121 | + getBinDirs() >> [moduleBin] |
| 122 | + } |
| 123 | + def task = Mock(TaskRun) { |
| 124 | + getSource() >> 'foo.sh --version' |
| 125 | + isContainerEnabled() >> false |
| 126 | + getInputs() >> [:] |
| 127 | + getOutputEvals() >> null |
| 128 | + getConfig() >> Mock(TaskConfig) { |
| 129 | + getModule() >> null |
| 130 | + getStubBlock() >> null |
| 131 | + getArchitecture() >> null |
| 132 | + } |
| 133 | + getCondaEnv() >> null |
| 134 | + getSpackEnv() >> null |
| 135 | + getProcessor() >> processor |
| 136 | + } |
| 137 | + |
| 138 | + when: |
| 139 | + def firstHash = Spy(TaskHasher, constructorArgs: [task]) { |
| 140 | + getTaskGlobalVars() >> [:] |
| 141 | + }.compute() |
| 142 | + Files.writeString(script, 'echo second version\n') |
| 143 | + def secondHash = Spy(TaskHasher, constructorArgs: [task]) { |
| 144 | + getTaskGlobalVars() >> [:] |
| 145 | + }.compute() |
| 146 | + |
| 147 | + then: |
| 148 | + firstHash != secondHash |
| 149 | + } |
| 150 | + |
97 | 151 | def 'should get task directive vars' () { |
98 | 152 | given: |
99 | 153 | def processor = Spy(TaskProcessor) { |
|
0 commit comments