Skip to content

Commit f1cb694

Browse files
committed
Fix #20: test locally built scala.xml classes
not scala-compiler's scala-xml dependency... also put int a println to show the version we're testing to prevent regression
1 parent 57b6e25 commit f1cb694

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

build.sbt

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,21 @@ libraryDependencies += "junit" % "junit" % "4.11" % "test"
1717

1818
libraryDependencies += "com.novocode" % "junit-interface" % "0.10" % "test"
1919

20+
//// testing:
2021
// used in CompilerErrors test
21-
libraryDependencies += "org.scala-lang" % "scala-compiler" % scalaVersion.value % "test"
22+
libraryDependencies += ("org.scala-lang" % "scala-compiler" % scalaVersion.value % "test").exclude("org.scala-lang.modules", s"scala-xml*")
23+
24+
// needed to fix classloader issues (see #20)
25+
// alternatively, manage the scala instance as shown below (commented)
26+
fork in Test := true
27+
28+
// ALTERNATIVE: manage the Scala instance ourselves to exclude the published scala-xml (scala-compiler depends on it)
29+
// since this dependency hides the classes we're testing
30+
// managedScalaInstance := false
31+
//
32+
// ivyConfigurations += Configurations.ScalaTool
33+
//
34+
// libraryDependencies ++= Seq(
35+
// "org.scala-lang" % "scala-library" % scalaVersion.value,
36+
// ("org.scala-lang" % "scala-compiler" % scalaVersion.value % "scala-tool").exclude("org.scala-lang.modules", s"scala-xml_${scalaBinaryVersion.value}")
37+
// )

src/main/scala/scala/xml/XML.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,8 @@ object XML extends XMLLoader[Elem] {
112112
w.write(Utility.serialize(node, minimizeTags = minimizeTags).toString)
113113
}
114114
}
115+
116+
object Properties extends scala.util.PropertiesTrait {
117+
protected def propCategory = "scala-xml"
118+
protected def pickJarBasedOn = classOf[scala.xml.pull.XMLEventReader]
119+
}

src/test/scala/scala/xml/CompilerErrors.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,11 @@ class CompilerErrors extends CompilerTesting {
164164

165165
// TODO: factor out somewhere?
166166
class CompilerTesting {
167+
// TODO: refine this; for now, just println -- the goal is to ensure we're testing the right version of scala-xml
168+
// (it should print the same thing as the version in the sbt build)
169+
// we used to always test the scala-xml jar that the compiler depends on, because it was part of the scala-tool ivy config
170+
println(s"Testing scala-xml version ${Properties.versionNumberString}.")
171+
167172
def errorMessages(errorSnippet: String, compileOptions: String = "")(code: String): List[String] = {
168173
import scala.tools.reflect._
169174
val m = scala.reflect.runtime.currentMirror

0 commit comments

Comments
 (0)