summaryrefslogtreecommitdiff
path: root/scalalib/test/src/mill/scalalib/HelloWorldTests.scala
diff options
context:
space:
mode:
authorLi Haoyi <haoyi.sg@gmail.com>2018-02-17 13:11:36 -0800
committerLi Haoyi <haoyi.sg@gmail.com>2018-02-17 13:12:40 -0800
commit75a45f9163034ca9ba126cf07b3f87f3f24b1249 (patch)
tree463d82ba1ab192699017a6294883d5fbbad2e0e4 /scalalib/test/src/mill/scalalib/HelloWorldTests.scala
parent865045540bd80bebb1655005abf32bc089c33895 (diff)
downloadmill-75a45f9163034ca9ba126cf07b3f87f3f24b1249.tar.gz
mill-75a45f9163034ca9ba126cf07b3f87f3f24b1249.tar.bz2
mill-75a45f9163034ca9ba126cf07b3f87f3f24b1249.zip
Add unit test for main method discovery
Diffstat (limited to 'scalalib/test/src/mill/scalalib/HelloWorldTests.scala')
-rw-r--r--scalalib/test/src/mill/scalalib/HelloWorldTests.scala34
1 files changed, 25 insertions, 9 deletions
diff --git a/scalalib/test/src/mill/scalalib/HelloWorldTests.scala b/scalalib/test/src/mill/scalalib/HelloWorldTests.scala
index 945bec27..7a788b1f 100644
--- a/scalalib/test/src/mill/scalalib/HelloWorldTests.scala
+++ b/scalalib/test/src/mill/scalalib/HelloWorldTests.scala
@@ -122,7 +122,7 @@ object HelloWorldTests extends TestSuite {
"Person$.class"
)
- def workspaceTest[T, M <: TestUtil.BaseModule: Discover](m: M)
+ def workspaceTest[T, M <: TestUtil.BaseModule: Discover](m: M, resourcePath: Path = resourcePath)
(t: TestEvaluator[M] => T)
(implicit tp: TestPath): T = {
val eval = new TestEvaluator(m)
@@ -300,11 +300,27 @@ object HelloWorldTests extends TestSuite {
read(runResult) == "hello rockjam, your age is: 25"
)
}
- 'notRunWithoutMainClass - workspaceTest(HelloWorldWithoutMain){eval =>
- val Left(Result.Exception(err, _)) = eval.apply(HelloWorldWithoutMain.core.run())
+ 'notRunWithoutMainClass - workspaceTest(
+ HelloWorldWithoutMain,
+ pwd / 'scalalib / 'test / 'resources / "hello-world-no-main"
+ ){eval =>
+ val Left(Result.Failure(_, None)) = eval.apply(HelloWorldWithoutMain.core.run())
+ }
+
+ 'runDiscoverMainClass - workspaceTest(HelloWorldWithoutMain){eval =>
+ // Make sure even if there isn't a main class defined explicitly, it gets
+ // discovered by Zinc and used
+ val runResult = eval.outPath / 'core / 'run / 'dest / "hello-mill"
+ val Right((_, evalCount)) = eval.apply(
+ HelloWorldWithoutMain.core.run(runResult.toString)
+ )
+
+ assert(evalCount > 0)
+
assert(
- err.isInstanceOf[RuntimeException]
+ exists(runResult),
+ read(runResult) == "hello rockjam, your age is: 25"
)
}
}
@@ -337,12 +353,12 @@ object HelloWorldTests extends TestSuite {
read(runResult) == "hello rockjam, your age is: 25"
)
}
- 'notRunWithoutMainClass - workspaceTest(HelloWorldWithoutMain){eval =>
- val Left(Result.Exception(err, _)) = eval.apply(HelloWorldWithoutMain.core.runLocal())
+ 'notRunWithoutMainClass - workspaceTest(
+ HelloWorldWithoutMain,
+ pwd / 'scalalib / 'test / 'resources / "hello-world-no-main"
+ ){eval =>
+ val Left(Result.Failure(_, None)) = eval.apply(HelloWorldWithoutMain.core.runLocal())
- assert(
- err.isInstanceOf[RuntimeException]
- )
}
}
'jar - {