Skip to content

Commit 9cafc74

Browse files
szeigerretronym
authored andcommitted
Build speclib/instrumented.jar for partest
- Build automatically from sources instead of fetching a pre-built binary which can get out of date and needs to be updated manually - Remove outdated build script (from the ant days)
1 parent 58dfe16 commit 9cafc74

File tree

5 files changed

+35
-1123
lines changed

5 files changed

+35
-1123
lines changed

build.sbt

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ val partestDependencies = Seq(
5757
"methvsfield" -> "be8454d5e7751b063ade201c225dcedefd252775",
5858
"nest" -> "cd33e0a0ea249eb42363a2f8ba531186345ff68c"
5959
).map(bootstrapDep("test/files/lib")) ++ Seq(
60-
bootstrapDep("test/files/codelib")("code" -> "e737b123d31eede5594ceda07caafed1673ec472") % "test",
61-
bootstrapDep("test/files/speclib")("instrumented" -> "d015eff38243f1c2edb44ac3b6a0ce99bc5656db") % "test"
60+
bootstrapDep("test/files/codelib")("code" -> "e737b123d31eede5594ceda07caafed1673ec472") % "test"
6261
)
6362

6463
lazy val publishSettings : Seq[Setting[_]] = Seq(
@@ -552,6 +551,36 @@ lazy val scalacheckLib = project.in(file("src") / "scalacheck")
552551
libraryDependencies += testInterfaceDep
553552
)
554553

554+
// An instrumented version of BoxesRunTime and ScalaRunTime for partest's "specialized" test category
555+
lazy val specLib = project.in(file("test") / "instrumented")
556+
.dependsOn(library, reflect, compiler)
557+
.settings(clearSourceAndResourceDirectories)
558+
.settings(commonSettings)
559+
.settings(disableDocs)
560+
.settings(disablePublishing)
561+
.settings(
562+
sourceGenerators in Compile += Def.task {
563+
import scala.collection.JavaConverters._
564+
val srcBase = (sourceDirectories in Compile in library).value.head / "scala/runtime"
565+
val targetBase = (sourceManaged in Compile).value / "scala/runtime"
566+
def patch(srcFile: String, patchFile: String): File = try {
567+
val p = difflib.DiffUtils.parseUnifiedDiff(IO.readLines(baseDirectory.value / patchFile).asJava)
568+
val r = difflib.DiffUtils.patch(IO.readLines(srcBase / srcFile).asJava, p)
569+
val target = targetBase / srcFile
570+
IO.writeLines(target, r.asScala)
571+
target
572+
} catch { case ex: Exception =>
573+
streams.value.log.error(s"Error patching $srcFile: $ex")
574+
throw ex
575+
}
576+
IO.createDirectory(targetBase)
577+
Seq(
578+
patch("BoxesRunTime.java", "boxes.patch"),
579+
patch("ScalaRunTime.scala", "srt.patch")
580+
)
581+
}.taskValue
582+
)
583+
555584
// The scala version used by the benchmark suites, leave undefined to use the ambient version.")
556585
def benchmarkScalaVersion = System.getProperty("benchmark.scala.version", "")
557586

@@ -703,9 +732,9 @@ lazy val test = project
703732
testOptions in IntegrationTest += Tests.Setup { () =>
704733
val cp = (dependencyClasspath in Test).value
705734
val baseDir = (baseDirectory in ThisBuild).value
706-
// Copy code.jar and instrumented.jar (resolved in the otherwise unused scope "test") to the location where partest expects them
735+
// Copy code.jar (resolved in the otherwise unused scope "test") and instrumented.jar (from specLib) to the location where partest expects them
707736
copyBootstrapJar(cp, baseDir, "test/files/codelib", "code")
708-
copyBootstrapJar(cp, baseDir, "test/files/speclib", "instrumented")
737+
IO.copyFile((packagedArtifact in (LocalProject("specLib"), Compile, packageBin)).value._2, baseDir / "test/files/speclib/instrumented.jar")
709738
},
710739
definedTests in IntegrationTest += new sbt.TestDefinition(
711740
"partest",

project/plugins.sbt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.1.15")
2323

2424
libraryDependencies ++= Seq(
2525
"org.eclipse.jgit" % "org.eclipse.jgit" % "4.6.0.201612231935-r",
26-
"org.slf4j" % "slf4j-nop" % "1.7.23"
26+
"org.slf4j" % "slf4j-nop" % "1.7.23",
27+
"com.googlecode.java-diff-utils" % "diffutils" % "1.3.0"
2728
)
2829

2930
concurrentRestrictions in Global := Seq(

0 commit comments

Comments
 (0)