@@ -23,23 +23,25 @@ class BaseHtmlTest:
23
23
withGeneratedDoc(Seq (" site" ), docsRoot = Some (base.toAbsolutePath.toString))(op)
24
24
25
25
def withGeneratedDoc (
26
- pcks : Seq [String ],
27
- docsRoot : Option [String ] = None )(
28
- op : ProjectContext ?=> Unit ,
26
+ pcks : Seq [String ],
27
+ docsRoot : Option [String ] = None ,
28
+ customArgs : Option [Scaladoc .Args ] = None ,
29
+ )(
30
+ op : ProjectContext ?=> Unit ,
29
31
): Unit =
30
- val dest = Files .createTempDirectory(" test-doc" )
32
+ val dest = customArgs.map(_.output).getOrElse( Files .createTempDirectory(" test-doc" ).toFile )
31
33
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
- )
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
+ ) )
39
41
Scaladoc .run(args)(using testContext)
40
- op(using ProjectContext (dest ))
42
+ op(using ProjectContext (args.output.toPath ))
41
43
42
- finally IO .delete(dest.toFile )
44
+ finally IO .delete(dest)
43
45
44
46
class DocumentContext (d : Document , path : Path ):
45
47
import collection .JavaConverters ._
@@ -49,7 +51,7 @@ class BaseHtmlTest:
49
51
def assertTextsIn (selector : String , expected : String * ) =
50
52
assertFalse(niceMsg(s " Selector not found for ' $selector' " ), d.select(selector).isEmpty)
51
53
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)
53
55
54
56
def assertAttr (selector : String , attr : String , expected : String * ) =
55
57
assertFalse(niceMsg(s " Selector ' $selector' not found " ), d.select(selector).isEmpty)
@@ -60,6 +62,9 @@ class BaseHtmlTest:
60
62
val msg = niceMsg(s " Selector ' $selector' exisits in document " )
61
63
assertTrue(msg, d.select(selector).isEmpty)
62
64
65
+ def fileExists =
66
+ assertTrue(path.toFile.exists)
67
+
63
68
def withHtmlFile (pathStr : String )(op : DocumentContext => Unit )(using ProjectContext ) =
64
69
val path = summon[ProjectContext ].path.resolve(pathStr)
65
70
assertTrue(s " File at $path does not exisits! " , Files .exists(path))
0 commit comments