1616
1717package nextflow.script
1818
19+ import java.nio.file.Path
1920import nextflow.Session
2021import spock.lang.Specification
2122
@@ -209,4 +210,43 @@ class ProcessEntryHandlerTest extends Specification {
209210 // tupleElements[1] should be a Path object (mocked)
210211 tupleElements[1 ]. toString(). contains(' file.fa' )
211212 }
212- }
213+
214+ def ' should parse file input correctly' () {
215+ given :
216+ def session = Mock (Session )
217+ def script = Mock (BaseScript )
218+ def meta = Mock (ScriptMeta )
219+ def handler = new ProcessEntryHandler (script, session, meta)
220+
221+ expect :
222+ handler. parseFileInput(INPUT ) == EXPECTED_FILES
223+
224+ where :
225+ INPUT | EXPECTED_FILES
226+ ' /path/to/file.txt' | Path . of(' /path/to/file.txt' )
227+ and :
228+ ' /path/to/file1.txt,/path/to/file2.txt,/path/to/file3.txt' | [Path . of(' /path/to/file1.txt' ), Path . of(' /path/to/file2.txt' ), Path . of(' /path/to/file3.txt' )]
229+ ' /path/to/file1.txt , /path/to/file2.txt , /path/to/file3.txt ' | [Path . of(' /path/to/file1.txt' ), Path . of(' /path/to/file2.txt' ), Path . of(' /path/to/file3.txt' )]
230+ ' /path/to/file1.txt,,/path/to/file2.txt, ,/path/to/file3.txt' | [Path . of(' /path/to/file1.txt' ), Path . of(' /path/to/file2.txt' ), Path . of(' /path/to/file3.txt' )]
231+ ' file1.txt,file2.txt' | [Path . of(' file1.txt' ). toAbsolutePath(), Path . of(' file2.txt' ). toAbsolutePath()]
232+ }
233+
234+ def ' should handle file input with GString' () {
235+ given :
236+ def session = Mock (Session )
237+ def script = Mock (BaseScript )
238+ def meta = Mock (ScriptMeta )
239+ def handler = new ProcessEntryHandler (script, session, meta)
240+ def inputDef = [name : ' input' , type : ' file' ]
241+ def complexParams = [input : " ${ '/path/to/file1.txt'} ,${ '/path/to/file2.txt'} " ]
242+
243+ when :
244+ def result = handler. getValueForInput(inputDef, complexParams)
245+
246+ then :
247+ result instanceof List
248+ result. size() == 2
249+ result[0 ]. toString(). contains(' file1.txt' )
250+ result[1 ]. toString(). contains(' file2.txt' )
251+ }
252+ }
0 commit comments