Skip to content

Commit 7930429

Browse files
committed
Generated scalatest-matchers-core module for js.
1 parent b0d8a14 commit 7930429

File tree

4 files changed

+52
-5
lines changed

4 files changed

+52
-5
lines changed

build.sbt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,5 @@ lazy val scalatestFreeSpecJS = ScalatestBuild.scalatestFreeSpecJS
6767
lazy val scalatestFunSuiteJS = ScalatestBuild.scalatestFunSuiteJS
6868
lazy val scalatestPropSpecJS = ScalatestBuild.scalatestPropSpecJS
6969
lazy val scalatestWordSpecJS = ScalatestBuild.scalatestWordSpecJS
70-
lazy val scalatestDiagramsJS = ScalatestBuild.scalatestDiagramsJS
70+
lazy val scalatestDiagramsJS = ScalatestBuild.scalatestDiagramsJS
71+
lazy val scalatestMatchersCoreJS = ScalatestBuild.scalatestMatchersCoreJS

project/GenModulesJS.scala

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,18 @@ object GenModulesJS {
105105
copyDir("scalatest/src/main/scala/org/scalatest/diagrams", "org/scalatest/diagrams", targetDir, List.empty)
106106

107107
def genScalaTestMatchersCore(targetDir: File, version: String, scalaVersion: String): Seq[File] =
108-
copyDir("scalatest/src/main/scala/org/scalatest/matchers", "org/scalatest/matchers", targetDir, List.empty) ++
109-
copyDir("scalatest/src/main/scala/org/scalatest/matchers/dsl", "org/scalatest/matchers/dsl", targetDir, List.empty)
108+
GenScalaTestJS.genScalaPackages.filter { case (packagePath, skipList) =>
109+
List(
110+
"org/scalatest/matchers",
111+
"org/scalatest/matchers/dsl"
112+
).contains(packagePath)
113+
}.flatMap { case (packagePath, skipList) =>
114+
copyDir("scalatest/src/main/scala/" + packagePath, packagePath, targetDir,
115+
if (packagePath == "org/scalatest" || packagePath == "org/scalatest/fixture") skipList ++ List("package.scala") else skipList)
116+
}.toList
117+
118+
//copyDir("scalatest/src/main/scala/org/scalatest/matchers", "org/scalatest/matchers", targetDir, List.empty) ++
119+
//copyDir("scalatest/src/main/scala/org/scalatest/matchers/dsl", "org/scalatest/matchers/dsl", targetDir, List.empty)
110120

111121
def genScalaTestShouldMatchers(targetDir: File, version: String, scalaVersion: String): Seq[File] =
112122
copyDir("scalatest/src/main/scala/org/scalatest/matchers/should", "org/scalatest/matchers/should", targetDir, List.empty)

project/JsBuild.scala

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,41 @@ trait JsBuild { this: BuildCommons =>
712712
"Bundle-Vendor" -> "Artima, Inc.",
713713
"Main-Class" -> "org.scalatest.tools.Runner"
714714
)
715-
).dependsOn(scalacticMacroJS % "compile-internal, test-internal", scalatestCoreJS).enablePlugins(ScalaJSPlugin)
715+
).dependsOn(scalacticMacroJS % "compile-internal, test-internal", scalatestCoreJS).enablePlugins(ScalaJSPlugin)
716+
717+
lazy val scalatestMatchersCoreJS = Project("scalatestMatchersCoreJS", file("modules/js/scalatest-matchers-core.js"))
718+
.enablePlugins(SbtOsgi)
719+
.settings(sharedSettings: _*)
720+
.settings(
721+
projectTitle := "ScalaTest Matchers Core JS",
722+
organization := "org.scalatest",
723+
name := "scalatest-matchers-core",
724+
scalacOptions ++= Seq("-P:scalajs:mapSourceURI:" + rootProject.base.toURI + "->https://raw.githubusercontent.com/scalatest/scalatest/v" + version.value + "/"),
725+
Compile / sourceGenerators += {
726+
Def.task {
727+
GenModulesJS.genScalaTestMatchersCore((sourceManaged in Compile).value / "scala", version.value, scalaVersion.value) ++
728+
GenFactories.genMainJS((sourceManaged in Compile).value / "scala" / "org" / "scalatest" / "matchers", version.value, scalaVersion.value)
729+
}
730+
},
731+
scalacOptions ++= (if (scalaBinaryVersion.value == "2.10" || scalaVersion.value.startsWith("2.13")) Seq.empty[String] else Seq("-Ypartial-unification")),
732+
mimaPreviousArtifacts := Set(organization.value %%% moduleName.value % previousReleaseVersion),
733+
mimaCurrentClassfiles := (classDirectory in Compile).value.getParentFile / (moduleName.value + "_" + "sjs0.6_" + scalaBinaryVersion.value + "-" + releaseVersion + ".jar")
734+
).settings(osgiSettings: _*).settings(
735+
OsgiKeys.exportPackage := Seq(
736+
"org.scalatest.matchers",
737+
"org.scalatest.matchers.dsl"
738+
),
739+
OsgiKeys.importPackage := Seq(
740+
"org.scalatest.*",
741+
"*;resolution:=optional"
742+
),
743+
OsgiKeys.additionalHeaders:= Map(
744+
"Bundle-Name" -> "ScalaTest Matchers Core JS",
745+
"Bundle-Description" -> "ScalaTest.js is an open-source test framework for the Javascript Platform designed to increase your productivity by letting you write fewer lines of test code that more clearly reveal your intent.",
746+
"Bundle-DocURL" -> "http://www.scalatest.org/",
747+
"Bundle-Vendor" -> "Artima, Inc.",
748+
"Main-Class" -> "org.scalatest.tools.Runner"
749+
)
750+
).dependsOn(scalacticMacroJS % "compile-internal, test-internal", scalatestCoreJS).enablePlugins(ScalaJSPlugin)
716751

717752
}

scalatest/src/main/scala/org/scalatest/matchers/MatchersHelper.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ import java.lang.reflect.Method
2222
import java.lang.reflect.Modifier
2323
import scala.util.matching.Regex
2424
import java.lang.reflect.Field
25-
import org.scalactic.{FailureMessages => _, UnquotedString => _, Resources => _, _}
25+
import org.scalactic._
26+
import org.scalatest.UnquotedString
2627

2728
// TODO: drop generic support for be as an equality comparison, in favor of specific ones.
2829
// TODO: mention on JUnit and TestNG docs that you can now mix in ShouldMatchers or MustMatchers

0 commit comments

Comments
 (0)