diff --git a/build.sbt b/build.sbt index b9213e0d6..d26c78694 100644 --- a/build.sbt +++ b/build.sbt @@ -17,5 +17,21 @@ libraryDependencies += "junit" % "junit" % "4.11" % "test" libraryDependencies += "com.novocode" % "junit-interface" % "0.10" % "test" +//// testing: // used in CompilerErrors test -libraryDependencies += "org.scala-lang" % "scala-compiler" % scalaVersion.value % "test" +libraryDependencies += ("org.scala-lang" % "scala-compiler" % scalaVersion.value % "test").exclude("org.scala-lang.modules", s"scala-xml*") + +// needed to fix classloader issues (see #20) +// alternatively, manage the scala instance as shown below (commented) +fork in Test := true + +// ALTERNATIVE: manage the Scala instance ourselves to exclude the published scala-xml (scala-compiler depends on it) +// since this dependency hides the classes we're testing +// managedScalaInstance := false +// +// ivyConfigurations += Configurations.ScalaTool +// +// libraryDependencies ++= Seq( +// "org.scala-lang" % "scala-library" % scalaVersion.value, +// ("org.scala-lang" % "scala-compiler" % scalaVersion.value % "scala-tool").exclude("org.scala-lang.modules", s"scala-xml_${scalaBinaryVersion.value}") +// ) diff --git a/src/main/scala/scala/xml/XML.scala b/src/main/scala/scala/xml/XML.scala index 034c7e5da..8b70eafd2 100755 --- a/src/main/scala/scala/xml/XML.scala +++ b/src/main/scala/scala/xml/XML.scala @@ -112,3 +112,8 @@ object XML extends XMLLoader[Elem] { w.write(Utility.serialize(node, minimizeTags = minimizeTags).toString) } } + +object Properties extends scala.util.PropertiesTrait { + protected def propCategory = "scala-xml" + protected def pickJarBasedOn = classOf[scala.xml.pull.XMLEventReader] +} diff --git a/src/test/scala/scala/xml/CompilerErrors.scala b/src/test/scala/scala/xml/CompilerErrors.scala index 285c99f71..6096e5a60 100644 --- a/src/test/scala/scala/xml/CompilerErrors.scala +++ b/src/test/scala/scala/xml/CompilerErrors.scala @@ -164,6 +164,11 @@ class CompilerErrors extends CompilerTesting { // TODO: factor out somewhere? class CompilerTesting { + // TODO: refine this; for now, just println -- the goal is to ensure we're testing the right version of scala-xml + // (it should print the same thing as the version in the sbt build) + // we used to always test the scala-xml jar that the compiler depends on, because it was part of the scala-tool ivy config + println(s"Testing scala-xml version ${Properties.versionNumberString}.") + def errorMessages(errorSnippet: String, compileOptions: String = "")(code: String): List[String] = { import scala.tools.reflect._ val m = scala.reflect.runtime.currentMirror