Skip to content
Permalink
Browse files

WIP scalanative + utest - specs2

  • Loading branch information...
francisdb committed Feb 27, 2019
1 parent a8fd4c3 commit 1829e6c4c0b505eec4a9d512a50e011013956dfc
Showing with 1,373 additions and 1,188 deletions.
  1. +45 −12 build.sbt
  2. +174 −170 parboiled-core/src/test/scala/org/parboiled2/ActionSpec.scala
  3. +168 −158 parboiled-core/src/test/scala/org/parboiled2/BasicSpec.scala
  4. +62 −57 parboiled-core/src/test/scala/org/parboiled2/CalculatorSpec.scala
  5. +56 −45 parboiled-core/src/test/scala/org/parboiled2/CharPredicateSpec.scala
  6. +44 −21 parboiled-core/src/test/scala/org/parboiled2/CharUtilsSpec.scala
  7. +246 −241 parboiled-core/src/test/scala/org/parboiled2/CombinatorSpec.scala
  8. +21 −16 parboiled-core/src/test/scala/org/parboiled2/CustomCharAndStringExpansionSpec.scala
  9. +18 −13 parboiled-core/src/test/scala/org/parboiled2/CutSpec.scala
  10. +8 −5 parboiled-core/src/test/scala/org/parboiled2/DefaultArgumentsSpec.scala
  11. +249 −244 parboiled-core/src/test/scala/org/parboiled2/ErrorReportingSpec.scala
  12. +14 −9 parboiled-core/src/test/scala/org/parboiled2/MetaRuleSpec.scala
  13. +10 −7 parboiled-core/src/test/scala/org/parboiled2/ReductionTypeSpec.scala
  14. +21 −16 parboiled-core/src/test/scala/org/parboiled2/RunSubParserSpec.scala
  15. +23 −20 parboiled-core/src/test/scala/org/parboiled2/RunningSpec.scala
  16. +16 −11 parboiled-core/src/test/scala/org/parboiled2/TailrecSpec.scala
  17. +25 −16 parboiled-core/src/test/scala/org/parboiled2/TestParserSpec.scala
  18. +150 −111 parboiled-core/src/test/scala/org/parboiled2/ValueStackSpec.scala
  19. +7 −5 parboiled-core/src/test/scala/org/parboiled2/nestedpackage/AlienPackageParserSpec.scala
  20. +12 −11 parboiled-core/src/test/scala/org/parboiled2/util/Base64Spec.scala
  21. +4 −0 project/plugins.sbt
@@ -1,7 +1,9 @@
import com.typesafe.sbt.SbtScalariform.ScalariformKeys
import sbt.Keys.libraryDependencies
import scalariform.formatter.preferences._

import scala.xml.transform._
import scala.xml.{Node => XNode, NodeSeq}
import scala.xml.{NodeSeq, Node => XNode}
import sbtcrossproject.CrossPlugin.autoImport.{CrossType, crossProject}
import sbtcrossproject.CrossPlugin.autoImport._

@@ -76,16 +78,21 @@ val noPublishingSettings = Seq(
/////////////////////// DEPENDENCIES /////////////////////////

def scalaReflect(v: String) = "org.scala-lang" % "scala-reflect" % v % "provided"
val shapeless = Def.setting("com.chuusai" %%% "shapeless" % "2.3.3" % "compile")
val specs2Core = Def.setting("org.specs2" %%% "specs2-core" % "4.4.1" % "test")
val specs2ScalaCheck = Def.setting("org.specs2" %%% "specs2-scalacheck" % "4.4.1" % "test")
val shapeless = Def.setting("com.chuusai" %%% "shapeless" % "2.3.3" % "compile")
val utest = Def.setting("com.lihaoyi" %%% "utest" % "0.6.6" % Test)
val scalaCheck = Def.setting("org.scalacheck" %%% "scalacheck" % "1.14.0" % Test)
// since ScalaCheck native is not available from the original authors @lolgab made a release
// see https://github.com/rickynils/scalacheck/issues/396#issuecomment-467782592
val scalaCheckNative = Def.setting("com.github.lolgab" %%% "scalacheck" % "1.14.1" % Test)
val specs2Core = Def.setting("org.specs2" %%% "specs2-core" % "4.4.1" % Test)
val specs2ScalaCheck = Def.setting("org.specs2" %%% "specs2-scalacheck" % "4.4.1" % Test)

/////////////////////// PROJECTS /////////////////////////

lazy val root = project.in(file("."))
.aggregate(examples, jsonBenchmark)
.aggregate(parboiledJVM, parboiledJS)
.aggregate(parboiledCoreJVM, parboiledCoreJS)
.aggregate(parboiledJVM, parboiledJS, parboiledNative)
.aggregate(parboiledCoreJVM, parboiledCoreJS, parboiledCoreNative)
.settings(commonSettings)
.settings(noPublishingSettings)

@@ -121,45 +128,71 @@ lazy val parboiledOsgiSettings = osgiSettings ++ Seq(

lazy val parboiledJVM = parboiled.jvm
lazy val parboiledJS = parboiled.js
lazy val parboiled = crossProject(JSPlatform, JVMPlatform)
lazy val parboiledNative = parboiled.native
lazy val parboiled = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.crossType(CrossType.Pure)
.dependsOn(parboiledCore)
.settings(commonSettings)
.settings(formattingSettings)
.settings(publishingSettings)
.jvmSettings(
libraryDependencies ++= Seq(specs2Core.value),
mappings in (Compile, packageBin) ++= (mappings in (parboiledCoreJVM.project, Compile, packageBin)).value,
mappings in (Compile, packageSrc) ++= (mappings in (parboiledCoreJVM.project, Compile, packageSrc)).value,
mappings in (Compile, packageDoc) ++= (mappings in (parboiledCoreJVM.project, Compile, packageDoc)).value
)
.jsSettings(
libraryDependencies ++= Seq(specs2Core.value),
mappings in (Compile, packageBin) ++= (mappings in (parboiledCoreJS.project, Compile, packageBin)).value,
mappings in (Compile, packageSrc) ++= (mappings in (parboiledCoreJS.project, Compile, packageSrc)).value,
mappings in (Compile, packageDoc) ++= (mappings in (parboiledCoreJS.project, Compile, packageDoc)).value
)
.nativeSettings(
mappings in (Compile, packageBin) ++= (mappings in (parboiledCoreNative.project, Compile, packageBin)).value,
mappings in (Compile, packageSrc) ++= (mappings in (parboiledCoreNative.project, Compile, packageSrc)).value,
mappings in (Compile, packageDoc) ++= (mappings in (parboiledCoreNative.project, Compile, packageDoc)).value,
nativeLinkStubs := true,
crossScalaVersions := Seq("2.11.12")
)
.settings(
libraryDependencies ++= Seq(scalaReflect(scalaVersion.value), shapeless.value, specs2Core.value),
libraryDependencies ++= Seq(scalaReflect(scalaVersion.value), shapeless.value, utest.value),
mappings in (Compile, packageBin) ~= (_.groupBy(_._2).toSeq.map(_._2.head)), // filter duplicate outputs
mappings in (Compile, packageDoc) ~= (_.groupBy(_._2).toSeq.map(_._2.head)), // filter duplicate outputs
pomPostProcess := { // we need to remove the dependency onto the parboiledCore module from the POM
val filter = new RewriteRule {
override def transform(n: XNode) = if ((n \ "artifactId").text.startsWith("parboiledcore")) NodeSeq.Empty else n
}
new RuleTransformer(filter).transform(_).head
}
},
testFrameworks := Seq(new TestFramework("utest.runner.Framework"))
).
enablePlugins(SbtOsgi).settings(parboiledOsgiSettings:_*)

lazy val generateActionOps = taskKey[Seq[File]]("Generates the ActionOps boilerplate source file")

lazy val parboiledCore = crossProject(JSPlatform, JVMPlatform).crossType(CrossType.Pure).in(file("parboiled-core"))
lazy val parboiledCore = crossProject(JSPlatform, JVMPlatform, NativePlatform).crossType(CrossType.Pure).in(file("parboiled-core"))
.settings(commonSettings)
.settings(formattingSettings)
.settings(noPublishingSettings)
.settings(
libraryDependencies ++= Seq(scalaReflect(scalaVersion.value), shapeless.value, specs2Core.value, specs2ScalaCheck.value),
libraryDependencies ++= Seq(scalaReflect(scalaVersion.value), shapeless.value, utest.value),
generateActionOps := ActionOpsBoilerplate((sourceManaged in Compile).value, streams.value),
(sourceGenerators in Compile) += generateActionOps.taskValue)
(sourceGenerators in Compile) += generateActionOps.taskValue,
testFrameworks := Seq(new TestFramework("utest.runner.Framework"))
)
.jvmSettings(
libraryDependencies ++= Seq(scalaCheck.value)
)
.jsSettings(
libraryDependencies ++= Seq(scalaCheck.value)
)
.nativeSettings(
nativeLinkStubs := true,
scalaVersion := "2.11.12",
crossScalaVersions := Seq("2.11.12"),
libraryDependencies ++= Seq(scalaCheckNative.value)
)

lazy val parboiledCoreJVM = parboiledCore.jvm
lazy val parboiledCoreJS = parboiledCore.js
lazy val parboiledCoreNative = parboiledCore.native
Oops, something went wrong.

0 comments on commit 1829e6c

Please sign in to comment.
You can’t perform that action at this time.