@@ -24,23 +24,25 @@ class BaseHtmlTest:
2424
2525 def withGeneratedDoc (
2626 pcks : Seq [String ],
27- docsRoot : Option [String ] = None )(
27+ docsRoot : Option [String ] = None ,
28+ customArgs : Option [Scaladoc .Args ] = None ,
29+ )(
2830 op : ProjectContext ?=> Unit ,
29- ): Unit =
30- val dest = Files .createTempDirectory(" test-doc" )
31- try
32- val args = Scaladoc .Args (
33- name = projectName,
34- tastyFiles = pcks.flatMap(tastyFiles(_)),
35- output = dest.toFile,
36- docsRoot = docsRoot,
37- projectVersion = Some (projectVersion)
38- )
39- Scaladoc .run(args)(using testContext)
40- op(using ProjectContext (dest))
41-
42- finally IO .delete(dest.toFile)
31+ ): Unit =
32+ val dest = customArgs.fold(Files .createTempDirectory(" test-doc" ).toFile)(_.output)
33+ try
34+ val args = customArgs.getOrElse(Scaladoc .Args (
35+ name = projectName,
36+ tastyFiles = pcks.flatMap(tastyFiles(_)),
37+ output = dest,
38+ docsRoot = docsRoot,
39+ projectVersion = Some (projectVersion)
40+ ))
41+ Scaladoc .run(args)(using testContext)
42+ op(using ProjectContext (args.output.toPath))
4343
44+ finally IO .delete(dest)
45+ end withGeneratedDoc
4446 class DocumentContext (d : Document , path : Path ):
4547 import collection .JavaConverters ._
4648
@@ -49,7 +51,7 @@ class BaseHtmlTest:
4951 def assertTextsIn (selector : String , expected : String * ) =
5052 assertFalse(niceMsg(s " Selector not found for ' $selector' " ), d.select(selector).isEmpty)
5153 val found = d.select(selector).eachText.asScala
52- assertEquals(niceMsg(s " Context does not match for ' $selector' " ), expected.toList, found.toList)
54+ assertEquals(niceMsg(s " Content does not match for ' $selector' " ), expected.toList, found.toList)
5355
5456 def assertAttr (selector : String , attr : String , expected : String * ) =
5557 assertFalse(niceMsg(s " Selector ' $selector' not found " ), d.select(selector).isEmpty)
@@ -60,6 +62,9 @@ class BaseHtmlTest:
6062 val msg = niceMsg(s " Selector ' $selector' exisits in document " )
6163 assertTrue(msg, d.select(selector).isEmpty)
6264
65+ def fileExists =
66+ assertTrue(path.toFile.exists)
67+
6368 def withHtmlFile (pathStr : String )(op : DocumentContext => Unit )(using ProjectContext ) =
6469 val path = summon[ProjectContext ].path.resolve(pathStr)
6570 assertTrue(s " File at $path does not exisits! " , Files .exists(path))
0 commit comments