@@ -2,8 +2,9 @@ package scala.tools.nsc.scaladoc
22
33import org .scalacheck ._
44import org .scalacheck .Prop ._
5-
65import java .net .{URLClassLoader , URLDecoder }
6+ import java .nio .file .{Files , Paths }
7+
78import scala .collection .mutable
89import scala .xml .NodeSeq
910
@@ -32,22 +33,11 @@ object HtmlFactoryTest extends Properties("HtmlFactory") {
3233 import scala .tools .nsc .doc .{DocFactory , Settings }
3334 import scala .tools .nsc .doc .html .HtmlFactory
3435
35- def getClasspath = {
36- // these things can be tricky
37- // this test previously relied on the assumption that the current thread's classloader is an url classloader and contains all the classpaths
38- // does partest actually guarantee this? to quote Leonard Nimoy: The answer, of course, is no.
39- // this test _will_ fail again some time in the future.
40- // Footnote: java.lang.ClassCastException: org.apache.tools.ant.loader.AntClassLoader5 cannot be cast to java.net.URLClassLoader
41- val loader = Thread .currentThread.getContextClassLoader.asInstanceOf [URLClassLoader ]
42- val paths = loader.getURLs.map(u => URLDecoder .decode(u.getPath))
43- paths mkString java.io.File .pathSeparator
44- }
45-
4636 def createFactory = {
4737 val settings = new Settings ({Console .err.println(_)})
4838 settings.scaladocQuietRun = true
4939 settings.nowarn.value = true
50- settings.classpath.value = getClasspath
40+ SettingsUtil .configureClassAndSourcePath(settings)
5141 settings.docAuthor.value = true
5242
5343 val reporter = new scala.tools.nsc.reporters.ConsoleReporter (settings)
@@ -57,7 +47,8 @@ object HtmlFactoryTest extends Properties("HtmlFactory") {
5747 def createTemplates (basename : String ): collection.Map [String , NodeSeq ] = {
5848 val result = mutable.Map [String , NodeSeq ]()
5949
60- createFactory.makeUniverse(Left (List (RESOURCES + basename))) match {
50+ val path : String = SettingsUtil .checkoutRoot.resolve(RESOURCES ).resolve(basename).toAbsolutePath.toString
51+ createFactory.makeUniverse(Left (List (path))) match {
6152 case Some (universe) => {
6253 new HtmlFactory (universe, new ScalaDocReporter (universe.settings)).writeTemplates((page) => {
6354 result += (page.absoluteLinkTo(page.path) -> page.body)
@@ -320,7 +311,7 @@ object HtmlFactoryTest extends Properties("HtmlFactory") {
320311 }
321312
322313 property(" scala/bug#4421" ) = {
323- createTemplate(" SI_4421 .scala" ) match {
314+ createTemplate(" t4421 .scala" ) match {
324315 case node : scala.xml.Node => {
325316 val html = node.toString
326317 html.contains(" >Example:" ) && html.contains(" >Note<" )
@@ -330,7 +321,7 @@ object HtmlFactoryTest extends Properties("HtmlFactory") {
330321 }
331322
332323 property(" scala/bug#4589" ) = {
333- createTemplate(" SI_4589 .scala" ) match {
324+ createTemplate(" t4589 .scala" ) match {
334325 case node : scala.xml.Node => {
335326 val html = node.toString
336327 html.contains(" >x0123456789: <" ) &&
@@ -341,7 +332,7 @@ object HtmlFactoryTest extends Properties("HtmlFactory") {
341332 }
342333
343334 property(" scala/bug#4714: Should decode symbolic type alias name." ) = {
344- createTemplate(" SI_4715 .scala" ) match {
335+ createTemplate(" t4715 .scala" ) match {
345336 case node : scala.xml.Node => {
346337 val html = node.toString
347338 html.contains(" >:+:<" )
@@ -351,7 +342,7 @@ object HtmlFactoryTest extends Properties("HtmlFactory") {
351342 }
352343
353344 property(" scala/bug#4287: Default arguments of synthesized constructor" ) = {
354- val files = createTemplates(" SI_4287 .scala" )
345+ val files = createTemplates(" t4287 .scala" )
355346
356347 files(" ClassWithSugar.html" ) match {
357348 case node : scala.xml.Node => {
@@ -362,53 +353,53 @@ object HtmlFactoryTest extends Properties("HtmlFactory") {
362353 }
363354
364355 property(" scala/bug#4507: Default arguments of synthesized constructor" ) = {
365- createTemplate(" SI_4507 .scala" ) match {
356+ createTemplate(" t4507 .scala" ) match {
366357 case node : scala.xml.Node =>
367358 ! node.toString.contains(" <li>returns silently when evaluating true and true</li>" )
368359 case _ => false
369360 }
370361 }
371362
372363 property(" scala/bug#4898: Use cases and links should not crash scaladoc" ) = {
373- createTemplate(" SI_4898 .scala" )
364+ createTemplate(" t4898 .scala" )
374365 true
375366 }
376367
377368 property(" scala/bug#5054: Use cases should override their original members" ) =
378- checkText(" SI_5054_q1 .scala" )(
369+ checkText(" t5054_q1 .scala" )(
379370 (None ,""" def test(): Int""" , true )
380371 // Disabled because the full signature is now displayed
381372 // (None, """def test(implicit lost: Int): Int""", false)
382373 )
383374
384375 property(" scala/bug#5054: Use cases should keep their flags - final should not be lost" ) =
385- checkText(" SI_5054_q2 .scala" )((None , """ final def test(): Int""" , true ))
376+ checkText(" t5054_q2 .scala" )((None , """ final def test(): Int""" , true ))
386377
387378 property(" scala/bug#5054: Use cases should keep their flags - implicit should not be lost" ) =
388- checkText(" SI_5054_q3 .scala" )((None , """ implicit def test(): Int""" , true ))
379+ checkText(" t5054_q3 .scala" )((None , """ implicit def test(): Int""" , true ))
389380
390381 property(" scala/bug#5054: Use cases should keep their flags - real abstract should not be lost" ) =
391- checkText(" SI_5054_q4 .scala" )((None , """ abstract def test(): Int""" , true ))
382+ checkText(" t5054_q4 .scala" )((None , """ abstract def test(): Int""" , true ))
392383
393384 property(" scala/bug#5054: Use cases should keep their flags - traits should not be affected" ) =
394- checkText(" SI_5054_q5 .scala" )((None , """ def test(): Int""" , true ))
385+ checkText(" t5054_q5 .scala" )((None , """ def test(): Int""" , true ))
395386
396387 property(" scala/bug#5054: Use cases should keep their flags - traits should not be affected" ) =
397- checkText(" SI_5054_q6 .scala" )((None , """ abstract def test(): Int""" , true ))
388+ checkText(" t5054_q6 .scala" )((None , """ abstract def test(): Int""" , true ))
398389
399390 property(" scala/bug#5054: Use case individual signature test" ) =
400- checkText(" SI_5054_q7 .scala" )(
391+ checkText(" t5054_q7 .scala" )(
401392 (None , """ abstract def test2(explicit: Int): Int [use case] This takes the explicit value passed.""" , true ),
402393 (None , """ abstract def test1(): Int [use case] This takes the implicit value in scope.""" , true )
403394 )
404395
405396 property(" scala/bug#5287: Display correct \" Definition classes\" " ) =
406- checkText(" SI_5287 .scala" )(
397+ checkText(" t5287 .scala" )(
407398 (None ,
408399 """ def method(): Int
409400 [use case] The usecase explanation
410401 [use case] The usecase explanation
411- Definition Classes SI_5287 SI_5287_B SI_5287_A """ , true )
402+ Definition Classes t5287 t5287_B t5287_A """ , true )
412403 ) // the explanation appears twice, as small comment and full comment
413404
414405 property(" Comment inheritance: Correct comment inheritance for overriding" ) =
@@ -578,31 +569,31 @@ object HtmlFactoryTest extends Properties("HtmlFactory") {
578569 property(" Comment inheritance: Correct explicit inheritance in corner cases" ) =
579570 checkText(" inheritdoc-corner-cases.scala" )(
580571 (Some (" D" ),
581- """ def hello1: Int
572+ """ def hello1: Int
582573 Inherited: Hello 1 comment
583574 Inherited: Hello 1 comment
584575 Definition Classes D → A
585576 """ , true ),
586577 (Some (" D" ),
587- """ def hello2: Int
578+ """ def hello2: Int
588579 Inherited: Hello 2 comment
589580 Inherited: Hello 2 comment
590581 Definition Classes D → B
591582 """ , true ),
592583 (Some (" G" ),
593- """ def hello1: Int
584+ """ def hello1: Int
594585 Inherited: Hello 1 comment
595586 Inherited: Hello 1 comment
596587 Definition Classes G → D → A
597588 """ , true ),
598589 (Some (" G" ),
599- """ def hello2: Int
590+ """ def hello2: Int
600591 Inherited: Hello 2 comment
601592 Inherited: Hello 2 comment
602593 Definition Classes G → D → B
603594 """ , true ),
604595 (Some (" I" ),
605- """ def hello1(i: Int): Unit
596+ """ def hello1(i: Int): Unit
606597 [use case] Inherited: Hello 1 comment
607598 [use case] Inherited: Hello 1 comment
608599 Definition Classes I → G → D → A
0 commit comments