summaryrefslogtreecommitdiff
path: root/scalajslib/test
diff options
context:
space:
mode:
authorNikolay Tatarinov <5min4eq.unity@gmail.com>2018-02-09 01:41:15 +0300
committerGitHub <noreply@github.com>2018-02-09 01:41:15 +0300
commit52f3e614181d158a82c166905f375924d2d6e046 (patch)
treea26bb94702d606340c664a6ee7096fb5eeb83f11 /scalajslib/test
parente381552b992a5ba4743fa54f5111db9a2e9d98e2 (diff)
downloadmill-52f3e614181d158a82c166905f375924d2d6e046.tar.gz
mill-52f3e614181d158a82c166905f375924d2d6e046.tar.bz2
mill-52f3e614181d158a82c166905f375924d2d6e046.zip
scala.js run (#127)
scala.js run command
Diffstat (limited to 'scalajslib/test')
-rw-r--r--scalajslib/test/src/mill/scalajslib/HelloJSWorldTests.scala76
1 files changed, 60 insertions, 16 deletions
diff --git a/scalajslib/test/src/mill/scalajslib/HelloJSWorldTests.scala b/scalajslib/test/src/mill/scalajslib/HelloJSWorldTests.scala
index 61e1671e..6738d7d3 100644
--- a/scalajslib/test/src/mill/scalajslib/HelloJSWorldTests.scala
+++ b/scalajslib/test/src/mill/scalajslib/HelloJSWorldTests.scala
@@ -6,8 +6,7 @@ import javax.script.{ScriptContext, ScriptEngineManager}
import ammonite.ops._
import mill._
-import mill.define.Discover
-import mill.eval.Result
+import mill.eval.{Evaluator, Result}
import mill.scalalib.{CrossScalaModule, DepSyntax, Lib, PublishModule, TestRunner}
import mill.scalalib.publish.{Developer, License, PomSettings, SCM}
import mill.util.{TestEvaluator, TestUtil}
@@ -121,9 +120,9 @@ object HelloJSWorldTests extends TestSuite {
assert(unchangedEvalCount == 0)
}
- 'fromScratch_2124_0621 - testCompileFromScratch("2.12.4", "0.6.22")
- 'fromScratch_2123_0621 - testCompileFromScratch("2.12.3", "0.6.22")
- 'fromScratch_2118_0621 - testCompileFromScratch("2.11.8", "0.6.22")
+ 'fromScratch_2124_0622 - testCompileFromScratch("2.12.4", "0.6.22")
+ 'fromScratch_2123_0622 - testCompileFromScratch("2.12.3", "0.6.22")
+ 'fromScratch_2118_0622 - testCompileFromScratch("2.11.8", "0.6.22")
'fromScratch_2124_100M2 - testCompileFromScratch("2.12.4", "1.0.0-M2")
}
@@ -140,15 +139,15 @@ object HelloJSWorldTests extends TestSuite {
}
'fullOpt - {
- 'run_2124_0621 - testRun("2.12.4", "0.6.22", FullOpt)
- 'run_2123_0621 - testRun("2.12.3", "0.6.22", FullOpt)
- 'run_2118_0621 - testRun("2.11.8", "0.6.22", FullOpt)
+ 'run_2124_0622 - testRun("2.12.4", "0.6.22", FullOpt)
+ 'run_2123_0622 - testRun("2.12.3", "0.6.22", FullOpt)
+ 'run_2118_0622 - testRun("2.11.8", "0.6.22", FullOpt)
'run_2124_100M2 - testRun("2.12.4", "1.0.0-M2", FullOpt)
}
'fastOpt - {
- 'run_2124_0621 - testRun("2.12.4", "0.6.22", FastOpt)
- 'run_2123_0621 - testRun("2.12.3", "0.6.22", FastOpt)
- 'run_2118_0621 - testRun("2.11.8", "0.6.22", FastOpt)
+ 'run_2124_0622 - testRun("2.12.4", "0.6.22", FastOpt)
+ 'run_2123_0622 - testRun("2.12.3", "0.6.22", FastOpt)
+ 'run_2118_0622 - testRun("2.11.8", "0.6.22", FastOpt)
'run_2124_100M2 - testRun("2.12.4", "1.0.0-M2", FastOpt)
}
'jar - {
@@ -166,7 +165,7 @@ object HelloJSWorldTests extends TestSuite {
val Right((result, evalCount)) = helloWorldEvaluator(HelloJSWorld.helloJsWorld(scalaVersion, scalaJSVersion).artifactMetadata)
assert(result.id == artifactId)
}
- 'artifactId_0621 - testArtifactId("2.12.4", "0.6.22", "hello-js-world_sjs0.6_2.12")
+ 'artifactId_0622 - testArtifactId("2.12.4", "0.6.22", "hello-js-world_sjs0.6_2.12")
'artifactId_100M2 - testArtifactId("2.12.4", "1.0.0-M2", "hello-js-world_sjs1.0.0-M2_2.12")
}
'test - {
@@ -213,17 +212,62 @@ object HelloJSWorldTests extends TestSuite {
)
}
- 'utest_2118_0621 - checkUtest("2.11.8", "0.6.22")
- 'utest_2124_0621 - checkUtest("2.12.4", "0.6.22")
+ 'utest_2118_0622 - checkUtest("2.11.8", "0.6.22")
+ 'utest_2124_0622 - checkUtest("2.12.4", "0.6.22")
'utest_2118_100M2 - checkUtest("2.11.8", "1.0.0-M2")
'utest_2124_100M2 - checkUtest("2.12.4", "1.0.0-M2")
- 'scalaTest_2118_0621 - checkScalaTest("2.11.8", "0.6.22")
- 'scalaTest_2124_0621 - checkScalaTest("2.12.4", "0.6.22")
+ 'scalaTest_2118_0622 - checkScalaTest("2.11.8", "0.6.22")
+ 'scalaTest_2124_0622 - checkScalaTest("2.12.4", "0.6.22")
// No scalatest artifact for scala.js 1.0.0-M2 published yet
// 'scalaTest_2118_100M2 - checkScalaTest("2.11.8", "1.0.0-M2")
// 'scalaTest_2124_100M2 - checkScalaTest("2.12.4", "1.0.0-M2")
}
+
+ def checkRun(scalaVersion: String, scalaJSVersion: String, mainClass: Option[String] = None): Unit = {
+ val task = mainClass match {
+ case Some(main) => HelloJSWorld.helloJsWorld(scalaVersion, scalaJSVersion).runMain(main)
+ case None => HelloJSWorld.helloJsWorld(scalaVersion, scalaJSVersion).run()
+ }
+
+ val Right((_, evalCount)) = helloWorldEvaluator(task)
+
+ val paths = Evaluator.resolveDestPaths(
+ helloWorldEvaluator.outPath,
+ task.ctx.segments
+ )
+ val log = read(paths.log)
+ assert(
+ evalCount > 0,
+ log.contains("node"),
+ log.contains("Scala.js")
+ )
+ }
+
+ 'runMain - {
+ val mainClass = Some("Main")
+ 'run_2118_0622 - checkRun("2.11.8", "0.6.22", mainClass)
+ 'run_2124_0622 - checkRun("2.12.4", "0.6.22", mainClass)
+ 'run_2118_100M2 - checkRun("2.11.8", "1.0.0-M2", mainClass)
+ 'run_2124_100M2 - checkRun("2.12.4", "1.0.0-M2", mainClass)
+
+ 'wrongMain - {
+ val wrongMainClass = "Foo"
+ val task = HelloJSWorld.helloJsWorld("2.12.4", "0.6.22").runMain(wrongMainClass)
+
+ val Left(Result.Exception(ex, _)) = helloWorldEvaluator(task)
+
+ assert(
+ ex.isInstanceOf[Exception]
+ )
+ }
+ }
+ 'run - {
+ 'run_2118_0622 - checkRun("2.11.8", "0.6.22")
+ 'run_2124_0622 - checkRun("2.12.4", "0.6.22")
+ 'run_2118_100M2 - checkRun("2.11.8", "1.0.0-M2")
+ 'run_2124_100M2 - checkRun("2.12.4", "1.0.0-M2")
+ }
}
def compileClassfiles(parentDir: Path) = Set(