From b283a6c6a62c9125e6199ea9e60471dc2e8e1c39 Mon Sep 17 00:00:00 2001 From: etorreborre Date: Sat, 1 May 2021 13:35:24 +0200 Subject: [PATCH] feature: remove the xml dependency from specs2-core --- build.sbt | 35 ++++++++++++--- .../org/specs2/collection/IterablexSpec.scala | 3 -- .../specs2/specification/process/Stats.scala | 43 ------------------- etorreborre.pub | 41 ++++++++++++++++++ project/depends.scala | 3 +- project/plugins.sbt | 2 +- version.sbt | 3 +- .../scala/org/specs2/xml/NodeFunctions.scala | 0 .../src/main/scala/org/specs2/xml/Nodex.scala | 0 .../test/scala/org/specs2/xml/NodexSpec.scala | 9 +++- 10 files changed, 80 insertions(+), 59 deletions(-) create mode 100644 etorreborre.pub rename {common => xml}/shared/src/main/scala/org/specs2/xml/NodeFunctions.scala (100%) rename {common => xml}/shared/src/main/scala/org/specs2/xml/Nodex.scala (100%) rename {core/jvm => xml/shared}/src/test/scala/org/specs2/xml/NodexSpec.scala (91%) diff --git a/build.sbt b/build.sbt index c7ab1c47b8..edad3cc117 100644 --- a/build.sbt +++ b/build.sbt @@ -17,12 +17,13 @@ lazy val specs2 = project.in(file(".")). name := "specs2", packagedArtifacts := Map.empty, ThisBuild / githubWorkflowArtifactUpload := false, + Global / onChangedBuildSource := ReloadOnSourceChanges, test := {} ).aggregate( fpJVM, catsJVM, commonJVM, matcherJVM, coreJVM, matcherExtraJVM, scalazJVM, html, - analysisJVM, shapelessJVM, formJVM, markdownJVM, gwtJVM, junitJVM, scalacheckJVM, mockJVM, + analysisJVM, shapelessJVM, formJVM, markdownJVM, gwtJVM, junitJVM, scalacheckJVM, mockJVM, xmlJVM, tests, fpJS, catsJS, commonJS, matcherJS, coreJS, matcherExtraJS, scalazJS, analysisJS, - shapelessJS, junitJS, scalacheckJS, mockJS + shapelessJS, junitJS, scalacheckJS, mockJS, xmlJS ) val scala211 = "2.11.12" @@ -119,7 +120,7 @@ lazy val common = crossProject(JSPlatform, JVMPlatform, NativePlatform).in(file( libraryDependencies ++= depends.paradise(scalaVersion.value) ++ Seq(depends.reflect(scalaOrganization.value, scalaVersion.value), - depends.scalaXML, depends.scalacheck.value % Test), + depends.scalacheck.value % Test), commonSettings, name := "specs2-common" ). @@ -199,7 +200,7 @@ lazy val form = crossProject(JSPlatform, JVMPlatform, NativePlatform). jvmSettings(depends.jvmTest, commonJvmSettings). jsSettings(depends.jsTest, commonJsSettings). nativeSettings(depends.nativeTest, commonNativeSettings). - dependsOn(core, markdown, matcherExtra, scalacheck % "test->test") + dependsOn(core, markdown, matcherExtra, scalacheck % "test->test", xml) lazy val formJVM = form.jvm lazy val formJS = form.js @@ -235,12 +236,13 @@ lazy val html = project.in(file("html")). commonSettings, name := "specs2-html"). settings(depends.jvmTest, commonJvmSettings). - dependsOn(formJVM, mockJVM % Test, matcherExtraJVM % Test, scalacheckJVM % Test) + dependsOn(formJVM, mockJVM % Test, matcherExtraJVM % Test, scalacheckJVM % Test, xmlJVM) lazy val junit = crossProject(JSPlatform, JVMPlatform, NativePlatform).in(file("junit")). settings( libraryDependencies ++= Seq( depends.junit, + depends.scalaXml, depends.mockito % Test), commonSettings, name := "specs2-junit"). @@ -256,7 +258,9 @@ lazy val markdown = crossProject(JSPlatform, JVMPlatform, NativePlatform). crossType(CrossType.Pure). in(file("markdown")). settings( - libraryDependencies += depends.pegdown, + libraryDependencies ++= Seq( + depends.pegdown, + depends.scalaXml), commonSettings, name := "specs2-markdown"). jvmSettings(depends.jvmTest, commonJvmSettings). @@ -290,7 +294,7 @@ lazy val matcherExtra = crossProject(JSPlatform, JVMPlatform, NativePlatform).in jsSettings(depends.jsTest, commonJsSettings). jvmSettings(depends.jvmTest, commonJvmSettings). nativeSettings(depends.nativeTest, commonNativeSettings). - dependsOn(analysis, matcher, core % "test->test") + dependsOn(analysis, matcher, xml, core % "test->test") lazy val matcherExtraJS = matcherExtra.js lazy val matcherExtraJVM = matcherExtra.jvm @@ -386,6 +390,22 @@ lazy val tests = Project(id = "tests", base = file("tests")). scalazJVM, catsJVM) +lazy val xml = crossProject(JSPlatform, JVMPlatform, NativePlatform).in(file("xml")). + settings( + libraryDependencies += depends.scalaXml, + commonSettings, + name := "xml" + ). + jsSettings(depends.jsTest, commonJsSettings). + jvmSettings(depends.jvmTest, commonJvmSettings). + nativeSettings(commonNativeSettings, depends.nativeTest). + platformsSettings(JSPlatform, NativePlatform)(commonJsNativeSettings). + dependsOn(core) + +lazy val xmlJS = xml.js +lazy val xmlJVM = xml.jvm +lazy val xmlNative = xml.native + lazy val specs2ShellPrompt = ThisBuild / shellPrompt := { state => val name = Project.extract(state).currentRef.project (if (name == "specs2") "" else name) + "> " @@ -500,6 +520,7 @@ lazy val publicationSettings = Seq( publishMavenStyle := true, Test / publishArtifact := false, pomIncludeRepository := { x => false }, + Global / pgpPassphrase := None, pomExtra := ( http://specs2.org/ diff --git a/core/jvm/src/test/scala/org/specs2/collection/IterablexSpec.scala b/core/jvm/src/test/scala/org/specs2/collection/IterablexSpec.scala index 2a284a6d00..0caab34e2f 100644 --- a/core/jvm/src/test/scala/org/specs2/collection/IterablexSpec.scala +++ b/core/jvm/src/test/scala/org/specs2/collection/IterablexSpec.scala @@ -17,9 +17,6 @@ class IterablexSpec extends Specification with IterableData with ScalaCheckResul "if deeply nested lists have the same elements but in a different order" >> { List(1, List(2, 3, List(4)), 5).sameElementsAs(List(5, List(List(4), 2, 3), 1)) } - "when comparing xml nodes in a different order" >> { - .child.sameElementsAs( .child) - } "for 2 iterables created with same elements in a different order" >> { implicit val iterables = arbitraryIterable Prop.forAll { i1: Iterable[Any] => diff --git a/core/shared/src/main/scala/org/specs2/specification/process/Stats.scala b/core/shared/src/main/scala/org/specs2/specification/process/Stats.scala index bfc84f5598..9ec089bb35 100644 --- a/core/shared/src/main/scala/org/specs2/specification/process/Stats.scala +++ b/core/shared/src/main/scala/org/specs2/specification/process/Stats.scala @@ -9,9 +9,7 @@ import org.specs2.fp.syntax._ import execute.StandardResults import text._ import Plural._ -import control.Exceptions._ import time.SimpleTimer -import scala.xml._ /** * The Stats class store results for the number of: @@ -77,27 +75,6 @@ case class Stats(specs: Int = 0, case DecoratedResult(_, r) => withResult(r) } - /** - * @return the xml representation of the statistics. Omit the attributes with 0 as a value for conciseness - */ - def toXml: Elem = { - val stats = {trend.map(t => {t.toXml}).getOrElse(NodeSeq.Empty)} - val attributes = Map( - "specs" -> specs.toString, - "examples" -> examples.toString, - "successes" -> successes.toString, - "expectations" -> expectations.toString, - "failures" -> failures.toString, - "errors" -> errors.toString, - "pending" -> pending.toString, - "skipped" -> skipped.toString, - "time" -> timer.totalMillis.toString) - attributes.foldLeft(stats) { (res, cur) => - if (cur._2 == "0") res - else res % new UnprefixedAttribute(cur._1, cur._2, Null) - } - } - override def toString = "Stats("+ "specs = " + specs +", "+ @@ -231,24 +208,4 @@ case object Stats { case DecoratedResult(_, r) => Stats(r) } - def fromXml(stats: scala.xml.Node): Option[Stats] = { - if (stats.label != Stats.empty.toXml.label) - None - else { - val map = stats.attributes.asAttrMap - def asInt(key: String, defaultValue: Int = 0) = tryOrElse(Integer.parseInt(map(key)))(defaultValue) - - Some(Stats( - asInt("specs" ), - asInt("examples" ), - asInt("successes" ), - asInt("expectations", 1), - asInt("failures" ), - asInt("errors" ), - asInt("pending" ), - asInt("skipped" ), - (stats \ "trend" \ "stats").headOption.flatMap(fromXml), - map.get("time").map(SimpleTimer.fromString).getOrElse(new SimpleTimer))) - } - } } diff --git a/etorreborre.pub b/etorreborre.pub new file mode 100644 index 0000000000..1be0310a3d --- /dev/null +++ b/etorreborre.pub @@ -0,0 +1,41 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- + +mQGNBGCBalABDADCpYxP2glZUYJKS/LKs5zqvOrCITt8cQ4u1KRaAZbyd6kP1Cfb +ZthNv9rjVK4txBNEcn6v145ATlyoEJn0M5pRmdr7zy4WhRw+qVWrYe/sMLF9uAlO +cNjFJi3+rMUZXdhgMxFEjELTdb/lKh8V4znbSHYMLZVOBRxv8mbCQaSFzOTh/jOA +pk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rBBpWP1nBSjZsibv +0g/2ums/UV+c7jEx8eh7UW7CF8jvOo/tsSnHlTxTDw== +=V4HB +-----END PGP PUBLIC KEY BLOCK----- diff --git a/project/depends.scala b/project/depends.scala index 540b432479..1330d26d65 100644 --- a/project/depends.scala +++ b/project/depends.scala @@ -12,7 +12,6 @@ object depends { def reflect(scalaOrganization: String, scalaVersion: String) = scalaOrganization % "scala-reflect" % scalaVersion - def scalaz(scalazVersion: String) = Seq("org.scalaz" %% "scalaz-core", "org.scalaz" %% "scalaz-effect").map(_ % scalazVersion) @@ -45,7 +44,7 @@ object depends { scalaParser.value } - def scalaXML = "org.scala-lang.modules" %% "scala-xml" % "1.3.0" + def scalaXml = "org.scala-lang.modules" %% "scala-xml" % "1.3.0" lazy val mockito = "org.mockito" % "mockito-core" % "3.9.0" lazy val junit = "junit" % "junit" % "4.13.2" diff --git a/project/plugins.sbt b/project/plugins.sbt index 0a5df02345..6359f95b32 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -7,7 +7,7 @@ addSbtPlugin("org.scala-js" % "sbt-scalajs" % scalaJSVer addSbtPlugin("org.scala-native" % "sbt-scala-native" % scalaNativeVersion) addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0") addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.0.0") -addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2") +addSbtPlugin("io.crashbox" % "sbt-gpg" % "0.2.1") addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3") addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.1") addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1") diff --git a/version.sbt b/version.sbt index 2b6e4e8bc6..cfeb9e691f 100644 --- a/version.sbt +++ b/version.sbt @@ -1 +1,2 @@ -ThisBuild / version := "4.10.6" +ThisBuild / version := "4.11.0" +ThisBuild / versionScheme := Some("semver-spec") diff --git a/common/shared/src/main/scala/org/specs2/xml/NodeFunctions.scala b/xml/shared/src/main/scala/org/specs2/xml/NodeFunctions.scala similarity index 100% rename from common/shared/src/main/scala/org/specs2/xml/NodeFunctions.scala rename to xml/shared/src/main/scala/org/specs2/xml/NodeFunctions.scala diff --git a/common/shared/src/main/scala/org/specs2/xml/Nodex.scala b/xml/shared/src/main/scala/org/specs2/xml/Nodex.scala similarity index 100% rename from common/shared/src/main/scala/org/specs2/xml/Nodex.scala rename to xml/shared/src/main/scala/org/specs2/xml/Nodex.scala diff --git a/core/jvm/src/test/scala/org/specs2/xml/NodexSpec.scala b/xml/shared/src/test/scala/org/specs2/xml/NodexSpec.scala similarity index 91% rename from core/jvm/src/test/scala/org/specs2/xml/NodexSpec.scala rename to xml/shared/src/test/scala/org/specs2/xml/NodexSpec.scala index e9b90c2a39..b69fd33fd3 100644 --- a/core/jvm/src/test/scala/org/specs2/xml/NodexSpec.scala +++ b/xml/shared/src/test/scala/org/specs2/xml/NodexSpec.scala @@ -4,6 +4,7 @@ package xml import Nodex._ import scala.xml._ import scala.xml.NodeSeq._ +import collection.Iterablex._ class NodexSpec extends Spec { def is = s2""" @@ -43,5 +44,9 @@ class NodexSpec extends Spec { def is = s2""" isEqualIgnoringSpaceOrdered returns true if 2 NodeSeqs are the same regardless of spaces and order ${ isEqualIgnoringSpaceOrdered } ${ !( isEqualIgnoringSpaceOrdered ) } - """ -} \ No newline at end of file + + when comparing xml nodes in a different order + ${ .child.sameElementsAs( .child) } + +""" +}