Ticket #247 (closed defect: invalid)

Opened 22 months ago

Last modified 22 months ago

Variables are not expanded in addInFile method

Reported by: dumoulin Owned by: romain.reuillon
Priority: normal Milestone:
Component: core Version: 0.3
Severity: major Keywords:
Cc: romain.reuillon@…

Description

Test script:

import org.openmole.plugin.task.groovy.GroovyTask
import org.openmole.core.implementation.data.Parameter
import org.openmole.core.implementation.data.Variable
t = new GroovyTask("test")                           
t.addParameter(new Parameter(new Variable("filename","run.sh")))
t.addInFile('${filename}')
t.setCode('println new File(filename).text')                    
builder.buildMoleExecution(t).start()

Excepted result should be that the content of the file "run.sh" is printed out, but I've got this error:

Caused by: java.io.FileNotFoundException: ${filename} (No such file or directory)
        at java.io.FileInputStream.open(Native Method) ~[na:1.6.0_16]
        at java.io.FileInputStream.<init>(FileInputStream.java:106) ~[na:1.6.0_16]
        at org.openmole.commons.tools.io.FileUtil.copyFile(FileUtil.java:146) ~[na:na]
        at org.openmole.commons.tools.io.FileUtil.copy(FileUtil.java:139) ~[na:na]
        at org.openmole.plugin.task.external.ExternalSystemTask$$anonfun$prepareInputFiles$1.apply(ExternalSystemTask.scala:41) ~[na:na]
        at org.openmole.plugin.task.external.ExternalSystemTask$$anonfun$prepareInputFiles$1.apply(ExternalSystemTask.scala:38) ~[na:na]
        at scala.collection.Iterator$class.foreach(Iterator.scala:631) ~[na:na]
        at scala.collection.JavaConversions$JIteratorWrapper.foreach(JavaConversions.scala:474) ~[na:na]
        at scala.collection.IterableLike$class.foreach(IterableLike.scala:79) ~[na:na]
        at scala.collection.JavaConversions$JListWrapper.foreach(JavaConversions.scala:521) ~[na:na]
        at org.openmole.plugin.task.external.ExternalSystemTask.prepareInputFiles(ExternalSystemTask.scala:38) ~[na:na]
        at org.openmole.plugin.task.code.CodeTask.process(CodeTask.java:55) ~[na:na]

Change History

Changed 22 months ago by DefaultCC Plugin

  • cc romain.reuillon@… added

Changed 22 months ago by dumoulin

The workaround is to store the Variable created and use the getValue() method, like that:

filename=new Variable("filename","run.sh")
t.addParameter(new Parameter(filename))
t.addInFile(filename.getValue())

But the variable extension mechanism would give a more homogen way.

Changed 22 months ago by reuillon

  • status changed from new to closed
  • resolution set to invalid

Variables are not suposed to be expanded here.

Having variables here mean that we are not able to know the files used by the task before it is actualy executed. This prevent from delegating nested mole executions (mole tasks): what are the files used by the tasks of such a mole would unknow until we execute them. This is a key functionnaty of the platform therefore we should not allow such a thing.

Note: See TracTickets for help on using tickets.

logo cemagref

logo iscpif

logo lifegrid

logo region auvergne

logo patres project