Commit 7ec32826 authored by Romain Reuillon's avatar Romain Reuillon
Browse files

Fix tests

parent eebb1b84
Pipeline #37 failed with stages
in 14 minutes and 33 seconds
......@@ -2,4 +2,4 @@
-J-Xmx3G
-J-Xss2M
-J-Dfile.encoding=UTF-8
-J-XX:MaxMetaspaceSize=512m
-J-XX:MaxMetaspaceSize=1G
......@@ -865,7 +865,7 @@ lazy val site = crossProject.in(binDir / "org.openmole.site") settings (defaultS
Libraries.scalajsMarked
)
lazy val siteJS = site.js enablePlugins (ExecNpmPlugin)
lazy val siteJS = site.js enablePlugins (ExecNpmPlugin) settings (test := {})
lazy val siteJVM = site.jvm dependsOn(tools, project, serializer, buildinfo, marketIndex) settings (
libraryDependencies += Libraries.sourceCode)
......
......@@ -28,9 +28,9 @@ object TestHook {
}
@Lenses case class TestHook(
f: Context Context = identity[Context],
f: Context Unit = identity[Context],
config: InputOutputConfig = InputOutputConfig(),
info: InfoConfig = InfoConfig()
) extends Hook {
override protected def process(executionContext: MoleExecutionContext) = FromContext { p f(p.context) }
override protected def process(executionContext: MoleExecutionContext) = FromContext { p f(p.context); p.context }
}
......@@ -26,7 +26,7 @@ import org.openmole.core.workflow.job._
import org.openmole.core.workflow.mole._
import org.openmole.core.workflow.builder._
import org.openmole.core.workflow.dsl._
import org.openmole.core.workflow.test.{TestHook, TestTask}
import org.openmole.core.workflow.test.{ TestHook, TestTask }
import org.scalatest._
import org.scalatest.junit._
......@@ -49,7 +49,6 @@ class HookSpec extends FlatSpec with Matchers {
context.contains(p) should equal(true)
context(p) should equal("test")
executed.incrementAndGet()
context
}
val ex = t1 hook hook
......@@ -74,7 +73,6 @@ class HookSpec extends FlatSpec with Matchers {
context.contains(p) should equal(true)
context(p) should equal("test")
executed = true
context
}
val ex = Master(t1) hook hook
......
......@@ -17,7 +17,7 @@
package org.openmole.core.workflow.mole
import org.openmole.core.context.{Val, Variable}
import org.openmole.core.context.{ Val, Variable }
import org.openmole.core.workflow.dsl._
import org.openmole.core.workflow.sampling._
import org.openmole.core.workflow.task._
......
......@@ -17,7 +17,7 @@
package org.openmole.core.workflow.mole
import org.openmole.core.context.{Context, Val, Variable}
import org.openmole.core.context.{ Context, Val, Variable }
import org.openmole.core.workflow.task._
import org.openmole.core.workflow.transition._
import org.openmole.core.workflow.sampling._
......
......@@ -90,10 +90,7 @@ class PuzzleSpec extends FlatSpec with Matchers {
val container = DSLContainer(first, output = Some(first))
val h = TestHook { context
hookExecuted = true
context
}
val h = TestHook { context hookExecuted = true }
(container hook h) run ()
......
......@@ -22,7 +22,7 @@ import org.openmole.core.workflow.dsl._
import org.openmole.core.workflow.mole._
import org.openmole.core.workflow.sampling._
import org.openmole.core.workflow.task._
import org.openmole.core.workflow.test.{TestHook, TestSource, TestTask}
import org.openmole.core.workflow.test.{ TestHook, TestSource, TestTask }
import org.openmole.core.workflow.transition._
import org.openmole.core.workflow.validation.DataflowProblem._
import org.openmole.core.workflow.validation.TopologyProblem._
......
......@@ -19,14 +19,15 @@ package org.openmole.plugin.hook.file
import java.io.{ File, FileWriter }
import org.openmole.core.context.{ Context, Val, PrototypeSet }
import org.openmole.core.workflow.mole._
import org.openmole.core.workflow.task._
import org.openmole.core.workflow.tools.DefaultSet
import org.openmole.core.dsl._
import org.openmole.core.workflow.test.TestTask
import org.openmole.tool.hash._
import org.scalatest._
class CopyFileHookSpec extends FlatSpec with Matchers {
import org.openmole.core.workflow.test.Stubs._
"A copy file misc" should "copy a file after the execution of a capsule" in {
val f = File.createTempFile("test", ".tmp")
......@@ -36,26 +37,17 @@ class CopyFileHookSpec extends FlatSpec with Matchers {
val p = Val[File]("p")
val t1 = new Task {
val name = "Test"
val outputs = PrototypeSet(p)
val inputs = PrototypeSet.empty
val plugins = PluginSet.empty
val defaults = DefaultSet.empty
override def process(context: Context) = context + (p f)
}
val t1c = new MoleCapsule(t1)
val t1 = TestTask { context context + (p f) } set (outputs += p)
val fDest = File.createTempFile("test", ".tmp")
val hook = CopyFileHook(p, fDest.getAbsolutePath)
val ex = MoleExecution(Mole(t1c), hooks = List(t1c hook))
val ex = t1 hook hook
ex.start.waitUntilEnded
ex.run()
f.hash should equal(fDest.hash)
f.hash() should equal(fDest.hash())
f.delete
fDest.delete
}
......
......@@ -21,23 +21,4 @@ import java.io.{ File, PrintWriter }
object TemplateData {
lazy val templateFile: File = {
val template = File.createTempFile("file", ".test")
val writer = new PrintWriter(template)
writer.println("My first line")
writer.println("${2*3}")
writer.print("${\"I am ${6*5} year old\"}")
writer.close
template
}
lazy val targetFile: File = {
val target = File.createTempFile("target", ".test")
val writert = new PrintWriter(target)
writert.println("My first line")
writert.println("6")
writert.print("I am 30 year old")
writert.close
target
}
}
......@@ -17,20 +17,43 @@
package org.openmole.plugin.task.template
import java.io.File
import org.openmole.core.context.{ Context, Val }
import org.openmole.plugin.task.template.TemplateData._
import org.openmole.core.dsl._
import org.openmole.core.workflow.test.TestHook
import org.openmole.tool.hash._
import org.scalatest._
class TemplateFileGeneratorTaskSpec extends FlatSpec with Matchers {
implicit val plugins = PluginSet.empty
import org.openmole.core.workflow.test.Stubs._
"A template file generator task" should "parse a template file and evalutate the ${} expressions" in {
val outputP = Val[File]("file1")
val t1 = TemplateFileTask(templateFile, outputP)
t1.toTask.process(Context.empty)(outputP).hash should equal(targetFile.hash)
lazy val templateFile: File = {
val template = java.io.File.createTempFile("file", ".test")
template.content =
"""My first line
|${2*3}
|I am ${a*5} year old
|${s"I am ${a*5} year old"}""".stripMargin
template
}
lazy val targetFile: File = {
val target = java.io.File.createTempFile("target", ".test")
target.content =
"""My first line
|6
|I am 30 year old
|I am 30 year old""".stripMargin
target
}
val outputP = Val[File]
val a = Val[Int]
val t1 = TemplateFileTask(templateFile, outputP) set (a := 6)
val testHook = TestHook { c targetFile.hash() should equal(c(outputP).hash()) }
(t1 hook testHook).run()
}
}
\ No newline at end of file
......@@ -45,7 +45,7 @@ object Libraries {
lazy val htmlparser2 = libraryDependencies += "com.definitelyscala" %%% "scala-js-htmlparser2" % "1.0.2"
lazy val plotlyJS = libraryDependencies += "com.definitelyscala" %%% "scala-js-plotlyjs" % "1.1.9"
lazy val scalatest = "org.scalatest" %% "scalatest" % "3.0.1" % "test"
lazy val scalatest = "org.scalatest" %% "scalatest" % "3.0.5" % "test"
/** ------- Bundles -------------- */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment