1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
package mill.scalaplugin
import ammonite.ops.ImplicitWd._
import ammonite.ops._
import mill.Module
import mill.define.{Cross, Task}
import mill.discover.Discovered
import mill.eval.Result
import utest._
import mill.util.JsonFormatters._
object JawnBuild{
val Jawn = Cross("2.10.6", "2.11.11", "2.12.3").map(new Jawn(_))
class Jawn(crossVersion: String) extends Module{
trait JawnModule extends SbtScalaModule{ outer =>
def scalaVersion = crossVersion
override def scalacOptions = Seq(
"-deprecation",
"-optimize",
"-unchecked"
)
def testProjectDeps: Seq[TestScalaModule] = Nil
object test extends this.Tests{
override def projectDeps = super.projectDeps ++ testProjectDeps
override def ivyDeps = Seq(
Dep("org.scalatest", "scalatest", "3.0.3"),
Dep("org.scalacheck", "scalacheck", "1.13.5")
)
def testFramework = "org.scalatest.tools.Framework"
}
}
object Parser extends JawnModule{
def basePath = JawnTests.srcPath/"parser"
}
object Util extends JawnModule{
override def projectDeps = Seq(Parser)
override def testProjectDeps = Seq(Parser.test)
def basePath = JawnTests.srcPath/"util"
}
object Ast extends JawnModule{
override def projectDeps = Seq(Parser, Util)
override def testProjectDeps = Seq(Parser.test, Util.test)
def basePath = JawnTests.srcPath/"ast"
}
class Support(name: String, ivyDeps0: Dep*) extends JawnModule{
override def projectDeps = Seq[ScalaModule](Parser)
def basePath = JawnTests.srcPath/"support"/"argonaut"
override def ivyDeps = ivyDeps0
}
object Argonaut extends Support("argonaut", Dep("io.argonaut", "argonaut", "6.2"))
object Json4s extends Support("json4s", Dep("org.json4s", "json4s-ast", "3.5.2"))
object Play extends Support("play"){
override def ivyDeps = mill.T{
scalaBinaryVersion() match{
case "2.10" => Seq(Dep("com.typesafe.play", "play-json", "2.4.11"))
case "2.11" => Seq(Dep("com.typesafe.play", "play-json", "2.5.15"))
case _ => Seq(Dep("com.typesafe.play", "play-json", "2.6.0"))
}
}
}
object Rojoma extends Support("rojoma", Dep("com.rojoma", "rojoma-json", "2.4.3"))
object RojomaV3 extends Support("rojoma-v3", Dep("com.rojoma", "rojoma-json-v3", "3.7.2"))
object Spray extends Support("spray", Dep("io.spray", "spray-json", "1.3.3"))
}
}
object JawnTests extends TestSuite{
val workspacePath = pwd / 'target / 'workspace / "jawn"
val srcPath = pwd / 'scalaplugin / 'src / 'test / 'resource / "jawn"
val tests = Tests{
rm(workspacePath)
mkdir(workspacePath/up)
cp(srcPath, workspacePath)
val mapping = Discovered.mapping(JawnBuild)
def eval[T](t: Task[T]) = TestEvaluator.eval(mapping, workspacePath)(t)
'test - {
def compileOutput = workspacePath / 'jawn / "2.12.3" / 'Parser / 'compile
def testCompileOutput = workspacePath / 'jawn / "2.12.3" / 'Parser / 'test / 'compile
assert(!exists(compileOutput), !exists(testCompileOutput))
val Right(_) = eval(JawnBuild.Jawn("2.12.3").Parser.test.test())
assert(
ls.rec(compileOutput).exists(_.last == "AsyncParser.class"),
ls.rec(testCompileOutput).exists(_.last == "CharBuilderSpec.class")
)
}
}
}
|