diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/scaladoc/IndexTest.scala | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/test/scaladoc/IndexTest.scala b/test/scaladoc/IndexTest.scala index 21b14d4bf0..fea2fe33e3 100644 --- a/test/scaladoc/IndexTest.scala +++ b/test/scaladoc/IndexTest.scala @@ -5,12 +5,23 @@ import scala.tools.nsc.doc.html.page.Index import java.net.URLClassLoader object Test extends Properties("Index") { + def getClasspath = { + // these things can be tricky + // this test previously relied on the assumption that the current thread's classloader is an url classloader and contains all the classpaths + // does partest actually guarantee this? to quote Leonard Nimoy: The answer, of course, is no. + // this test _will_ fail again some time in the future. + val paths = Thread.currentThread.getContextClassLoader.asInstanceOf[URLClassLoader].getURLs.map(_.getPath) + val morepaths = Thread.currentThread.getContextClassLoader.getParent.asInstanceOf[URLClassLoader].getURLs.map(_.getPath) + (paths ++ morepaths).mkString(java.io.File.pathSeparator) + } + val docFactory = { val settings = new doc.Settings((s: String) => { Console.err.println(s) }) - settings.classpath.value = - Thread.currentThread.getContextClassLoader.asInstanceOf[URLClassLoader].getURLs.map(_.getPath).mkString(":") + + settings.classpath.value = getClasspath + println(settings.classpath.value) val reporter = new scala.tools.nsc.reporters.ConsoleReporter(settings) @@ -21,8 +32,7 @@ object Test extends Properties("Index") { val settings = new doc.Settings((s: String) => { Console.err.println(s) }) - settings.classpath.value = - Thread.currentThread.getContextClassLoader.asInstanceOf[URLClassLoader].getURLs.map(_.getPath).mkString(":") + settings.classpath.value = getClasspath val reporter = new scala.tools.nsc.reporters.ConsoleReporter(settings) @@ -31,14 +41,14 @@ object Test extends Properties("Index") { def createIndex(path: String): Option[Index] = { val maybeModel = { - val stream = new java.io.ByteArrayOutputStream - val original = Console.out - Console.setOut(stream) + //val stream = new java.io.ByteArrayOutputStream + //val original = Console.out + //Console.setOut(stream) val result = docFactory.universe(List(path)) // assert(stream.toString == "model contains 2 documentable templates\n") - Console.setOut(original) + //Console.setOut(original) result } @@ -93,4 +103,4 @@ object Test extends Properties("Index") { case None => false } } -}
\ No newline at end of file +} |