diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2018-04-08 15:46:22 -0700 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2018-04-08 15:46:22 -0700 |
commit | d94bb5eae6cd5f75d3cac1b69518b80c0a90169b (patch) | |
tree | c21749c35fdc5b193ad16c6ea9c01ac4c1da2cc9 /scalalib/test | |
parent | bcdb1aaf941a00a52fc854a5fbced81b2fda96d9 (diff) | |
download | mill-d94bb5eae6cd5f75d3cac1b69518b80c0a90169b.tar.gz mill-d94bb5eae6cd5f75d3cac1b69518b80c0a90169b.tar.bz2 mill-d94bb5eae6cd5f75d3cac1b69518b80c0a90169b.zip |
Properly support test frameworks which spawn child tasks
Needed to fix https://github.com/lihaoyi/mill/issues/286
Diffstat (limited to 'scalalib/test')
3 files changed, 60 insertions, 0 deletions
diff --git a/scalalib/test/resources/hello-scalacheck/foo/src/Main.scala b/scalalib/test/resources/hello-scalacheck/foo/src/Main.scala new file mode 100644 index 00000000..c98908d3 --- /dev/null +++ b/scalalib/test/resources/hello-scalacheck/foo/src/Main.scala @@ -0,0 +1,3 @@ +object Main extends App { + println("Hello world!") +}
\ No newline at end of file diff --git a/scalalib/test/resources/hello-scalacheck/foo/test/src/MainProps.scala b/scalalib/test/resources/hello-scalacheck/foo/test/src/MainProps.scala new file mode 100644 index 00000000..e405a965 --- /dev/null +++ b/scalalib/test/resources/hello-scalacheck/foo/test/src/MainProps.scala @@ -0,0 +1,21 @@ +import org.scalacheck._ + +object MainProps extends Properties("String") { + import Prop.forAll + + property("startsWith") = forAll { (a: String, b: String) => + (a+b).startsWith(a) + } + + property("endsWith") = forAll { (a: String, b: String) => + (a+b).endsWith(b) + } + + property("substring") = forAll { (a: String, b: String) => + (a+b).substring(a.length) == b + } + + property("substring") = forAll { (a: String, b: String, c: String) => + (a+b+c).substring(a.length, a.length+b.length) == b + } +}
\ No newline at end of file diff --git a/scalalib/test/src/mill/scalalib/HelloWorldTests.scala b/scalalib/test/src/mill/scalalib/HelloWorldTests.scala index 10f936f0..a52ab7a1 100644 --- a/scalalib/test/src/mill/scalalib/HelloWorldTests.scala +++ b/scalalib/test/src/mill/scalalib/HelloWorldTests.scala @@ -130,6 +130,16 @@ object HelloWorldTests extends TestSuite { } } + object HelloScalacheck extends HelloBase{ + object foo extends ScalaModule { + def scalaVersion = "2.12.4" + object test extends Tests { + def ivyDeps = Agg(ivy"org.scalacheck::scalacheck:1.13.5") + def testFrameworks = Seq("org.scalacheck.ScalaCheckFramework") + } + } + } + val resourcePath = pwd / 'scalalib / 'test / 'resources / "hello-world" def jarMainClass(jar: JarFile): Option[String] = { @@ -182,6 +192,7 @@ object HelloWorldTests extends TestSuite { ) } } + 'scalacOptions - { 'emptyByDefault - workspaceTest(HelloWorld){eval => val Right((result, evalCount)) = eval.apply(HelloWorld.core.scalacOptions) @@ -200,6 +211,7 @@ object HelloWorldTests extends TestSuite { ) } } + 'compile - { 'fromScratch - workspaceTest(HelloWorld){eval => val Right((result, evalCount)) = eval.apply(HelloWorld.core.compile) @@ -260,6 +272,7 @@ object HelloWorldTests extends TestSuite { } } + 'runMain - { 'runMainObject - workspaceTest(HelloWorld){eval => val runResult = eval.outPath / 'core / 'runMain / 'dest / "hello-mill" @@ -351,6 +364,7 @@ object HelloWorldTests extends TestSuite { ) } } + 'run - { 'runIfMainClassProvided - workspaceTest(HelloWorldWithMain){eval => val runResult = eval.outPath / 'core / 'run / 'dest / "hello-mill" @@ -388,6 +402,7 @@ object HelloWorldTests extends TestSuite { } } + 'jar - { 'nonEmpty - workspaceTest(HelloWorldWithMain){eval => val Right((result, evalCount)) = eval.apply(HelloWorldWithMain.core.jar) @@ -413,6 +428,7 @@ object HelloWorldTests extends TestSuite { val mainClass = jarMainClass(jarFile) assert(mainClass.contains("Main")) } + 'logOutputToFile - workspaceTest(HelloWorld){eval => val outPath = eval.outPath eval.apply(HelloWorld.core.compile) @@ -439,6 +455,7 @@ object HelloWorldTests extends TestSuite { val mainClass = jarMainClass(jarFile) assert(mainClass.contains("Main")) } + 'run - workspaceTest(HelloWorldWithMain){eval => val Right((result, evalCount)) = eval.apply(HelloWorldWithMain.core.assembly) @@ -470,6 +487,7 @@ object HelloWorldTests extends TestSuite { !result2.exists(_.path.last == "sourcecode_2.12-0.1.3.jar") ) } + 'typeLevel - workspaceTest(HelloWorldTypeLevel){ eval => val classPathsToCheck = Seq( HelloWorldTypeLevel.foo.runClasspath, @@ -489,6 +507,7 @@ object HelloWorldTests extends TestSuite { ) } } + 'macros - { // make sure macros are applied when compiling/running 'runMain - workspaceTest( @@ -507,5 +526,22 @@ object HelloWorldTests extends TestSuite { assert(evalCount > 0) } } + + 'scalacheck - workspaceTest( + HelloScalacheck, + resourcePath = pwd / 'scalalib / 'test / 'resources / "hello-scalacheck" + ){ eval => + val Right((res, evalCount)) = eval.apply(HelloScalacheck.foo.test.test()) + assert( + evalCount > 0, + res._2.map(_.selector) == Seq( + "String.startsWith", + "String.endsWith", + "String.substring", + "String.substring" + ) + ) + } + } } |