From f1cb6949a835779b5d383fb98a800855a464dbd8 Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Fri, 28 Feb 2014 08:30:12 -0800 Subject: [PATCH] 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 --- build.sbt | 18 +++++++++++++++++- src/main/scala/scala/xml/XML.scala | 5 +++++ src/test/scala/scala/xml/CompilerErrors.scala | 5 +++++ 3 files changed, 27 insertions(+), 1 deletion(-) 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