Skip to content

Commit cfb0200

Browse files
committed
Fix dottydoc tests
1 parent b492fd8 commit cfb0200

File tree

5 files changed

+43
-43
lines changed

5 files changed

+43
-43
lines changed

doc-tool/test/dotty/tools/dottydoc/ConstructorTest.scala

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ abstract class ConstructorsBase extends DottyDocTest {
2222
""".stripMargin
2323
)
2424

25-
val className = "scala.Class"
25+
val tastyFile = "scala/Class.tasty"
2626

27-
check(className :: Nil, source :: Nil) { (ctx, packages) =>
27+
check(tastyFile :: Nil, source :: Nil) { (ctx, packages) =>
2828
packages("scala") match {
2929
case PackageImpl(_, _, _, List(cls: Class), _, _, _, _) =>
3030
cls.constructors.headOption match {
@@ -45,9 +45,9 @@ abstract class ConstructorsBase extends DottyDocTest {
4545
""".stripMargin
4646
)
4747

48-
val className = "scala.Class"
48+
val tastyFile = "scala/Class.tasty"
4949

50-
check(className :: Nil, source :: Nil) { (ctx, packages) =>
50+
check(tastyFile :: Nil, source :: Nil) { (ctx, packages) =>
5151
packages("scala") match {
5252
case PackageImpl(_, _, _, List(cls: Class), _, _, _, _) =>
5353
cls.constructors match {
@@ -71,9 +71,9 @@ abstract class ConstructorsBase extends DottyDocTest {
7171
""".stripMargin
7272
)
7373

74-
val className = "scala.Class"
74+
val tastyFile = "scala/Class.tasty"
7575

76-
check(className :: Nil, source :: Nil) { (ctx, packages) =>
76+
check(tastyFile :: Nil, source :: Nil) { (ctx, packages) =>
7777
packages("scala") match {
7878
case PackageImpl(_, _, _, List(cls: Class), _, _, _, _) =>
7979
cls.constructors match {
@@ -104,9 +104,9 @@ abstract class ConstructorsBase extends DottyDocTest {
104104
""".stripMargin
105105
)
106106

107-
val className = "scala.Class"
107+
val tastyFile = "scala/Class.tasty"
108108

109-
check(className :: Nil, source :: Nil) { (ctx, packages) =>
109+
check(tastyFile :: Nil, source :: Nil) { (ctx, packages) =>
110110
packages("scala") match {
111111
case PackageImpl(_, _, _, List(cls: Class), _, _, _, _) =>
112112
cls.constructors match {
@@ -143,9 +143,9 @@ abstract class ConstructorsBase extends DottyDocTest {
143143
""".stripMargin
144144
)
145145

146-
val className = "scala.Class"
146+
val tastyFile = "scala/Class.tasty"
147147

148-
check(className :: Nil, source :: Nil) { (ctx, packages) =>
148+
check(tastyFile :: Nil, source :: Nil) { (ctx, packages) =>
149149
packages("scala") match {
150150
case PackageImpl(_, _, _, List(cls: CaseClass, obj: Object), _, _, _, _) =>
151151
cls.constructors match {
@@ -177,9 +177,9 @@ abstract class ConstructorsBase extends DottyDocTest {
177177
""".stripMargin
178178
)
179179

180-
val className = "scala.Trait"
180+
val tastyFile = "scala/Trait.tasty"
181181

182-
check(className :: Nil, source :: Nil) { (ctx, packages) =>
182+
check(tastyFile :: Nil, source :: Nil) { (ctx, packages) =>
183183
packages("scala") match {
184184
case PackageImpl(_, _, _, List(trt: Trait), _, _, _, _) =>
185185
trt.traitParams match {

doc-tool/test/dotty/tools/dottydoc/DottyDocTest.scala

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import dotty.tools.dottydoc.util.syntax._
1616
import dotty.tools.io.AbstractFile
1717
import dotc.reporting.{ StoreReporter, MessageRendering }
1818
import dotc.interfaces.Diagnostic.ERROR
19-
import io.{Directory, PlainFile, Path}
19+
import io.{Directory, PlainFile, Path, PlainDirectory}
2020
import org.junit.Assert.fail
2121

2222
import java.io.{ BufferedWriter, OutputStreamWriter }
@@ -78,8 +78,6 @@ trait DottyDocTest extends MessageRendering {
7878
throw new IllegalStateException("couldn't get calling method via reflection")
7979
}
8080

81-
private def fileFromPath(path: String): AbstractFile = new PlainFile(Path(path))
82-
8381
private def sourceFileFromString(name: String, contents: String): SourceFile = {
8482
val virtualFile = new dotty.tools.io.VirtualFile(name)
8583
val writer = new BufferedWriter(new OutputStreamWriter(virtualFile.output, StandardCharsets.UTF_8))
@@ -97,7 +95,7 @@ trait DottyDocTest extends MessageRendering {
9795
def checkFiles(sources: List[String])(assertion: (Context, Map[String, Package]) => Unit): Unit = {
9896
val c = compilerWithChecker(assertion)
9997
val run = c.newRun
100-
val files = sources.map(fileFromPath)
98+
val files = sources.map(path => new PlainFile(Path(path)))
10199
run.compile(files)
102100
}
103101

@@ -107,7 +105,7 @@ trait DottyDocTest extends MessageRendering {
107105
run.compileSources(sourceFiles)
108106
}
109107

110-
def checkFromTasty(classNames: List[String], sources: List[SourceFile])(assertion: (Context, Map[String, Package]) => Unit): Unit = {
108+
def checkFromTasty(tastyFiles: List[String], sources: List[SourceFile])(assertion: (Context, Map[String, Package]) => Unit): Unit = {
111109
Directory.inTempDirectory { tmp =>
112110
val ctx = "shadow ctx"
113111
val out = tmp./(Directory("out"))
@@ -128,24 +126,26 @@ trait DottyDocTest extends MessageRendering {
128126
}
129127
val fromTastyCompiler = compilerWithChecker(assertion)
130128
val fromTastyRun = fromTastyCompiler.newRun(using fromTastyCtx)
131-
val classFiles = classNames.map(fileFromPath)
132-
fromTastyRun.compile(classFiles)
129+
val outDir = new PlainDirectory(out)
130+
val files = tastyFiles.map(outDir.fileNamed)
131+
fromTastyRun.compile(files)
132+
fromTastyCtx.reporter.allErrors.foreach(println)
133133
assert(!fromTastyCtx.reporter.hasErrors)
134134
}
135135
}
136136

137-
def check(classNames: List[String], sources: List[SourceFile])(assertion: (Context, Map[String, Package]) => Unit): Unit
137+
def check(tastyFiles: List[String], sources: List[SourceFile])(assertion: (Context, Map[String, Package]) => Unit): Unit
138138

139139
}
140140

141141
trait CheckFromSource extends DottyDocTest {
142-
override def check(classNames: List[String], sources: List[SourceFile])(assertion: (Context, Map[String, Package]) => Unit): Unit = {
142+
override def check(tastyFiles: List[String], sources: List[SourceFile])(assertion: (Context, Map[String, Package]) => Unit): Unit = {
143143
checkFromSource(sources)(assertion)
144144
}
145145
}
146146

147147
trait CheckFromTasty extends DottyDocTest {
148-
override def check(classNames: List[String], sources: List[SourceFile])(assertion: (Context, Map[String, Package]) => Unit): Unit = {
149-
checkFromTasty(classNames, sources)(assertion)
148+
override def check(tastyFiles: List[String], sources: List[SourceFile])(assertion: (Context, Map[String, Package]) => Unit): Unit = {
149+
checkFromTasty(tastyFiles, sources)(assertion)
150150
}
151151
}

doc-tool/test/dotty/tools/dottydoc/PackageStructure.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ abstract class PackageStructureBase extends DottyDocTest {
2121
""".stripMargin
2222
)
2323

24-
val className = "scala.A"
24+
val tastyFile = "scala/A.tasty"
2525

26-
check(className :: Nil, source :: Nil) { (ctx, packages) =>
26+
check(tastyFile :: Nil, source :: Nil) { (ctx, packages) =>
2727
packages("scala") match {
2828
case PackageImpl(_, _, _, List(trt: Trait), _, _, _, _) =>
2929
assert(trt.annotations.isEmpty)
@@ -48,9 +48,9 @@ abstract class PackageStructureBase extends DottyDocTest {
4848
""".stripMargin
4949
)
5050

51-
val classNames = "scala.A" :: "scala.B" :: Nil
51+
val tastyFiles = "scala/A.tasty" :: "scala/B.tasty" :: Nil
5252

53-
check(classNames, source1 :: source2 :: Nil) { (ctx, packages) =>
53+
check(tastyFiles, source1 :: source2 :: Nil) { (ctx, packages) =>
5454
packages("scala") match {
5555
case PackageImpl(_, _, _, List(tA, tB), _, _, _, _) =>
5656
assert(
@@ -80,9 +80,9 @@ abstract class PackageStructureBase extends DottyDocTest {
8080
|trait B
8181
""".stripMargin)
8282

83-
val classNames = "scala.collection.A" :: "scala.collection.B" :: Nil
83+
val tastyFiles = "scala/collection/A.tasty" :: "scala/collection/B.tasty" :: Nil
8484

85-
check(classNames, source1 :: source2 :: Nil) { (ctx, packages) =>
85+
check(tastyFiles, source1 :: source2 :: Nil) { (ctx, packages) =>
8686
packages("scala.collection") match {
8787
case PackageImpl(_, _, "scala.collection", List(tA, tB), _, _, _, _) =>
8888
assert(

doc-tool/test/dotty/tools/dottydoc/SimpleComments.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ abstract class SimpleCommentsBase extends DottyDocTest {
4646
)
4747

4848

49-
val className = "scala.HelloWorld"
49+
val tastyFile = "scala/HelloWorld.tasty"
5050

51-
check(className :: Nil, source :: Nil) { (ctx, packages) =>
51+
check(tastyFile :: Nil, source :: Nil) { (ctx, packages) =>
5252
val traitCmt =
5353
packages("scala")
5454
.children.find(_.path.mkString(".") == "scala.HelloWorld")

doc-tool/test/dotty/tools/dottydoc/UsecaseTest.scala

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ abstract class UsecaseBase extends DottyDocTest {
2929
""".stripMargin
3030
)
3131

32-
val className = "scala.Test"
32+
val tastyFile = "scala/Test.tasty"
3333

34-
check(className :: Nil, source :: Nil) { (ctx, packages) =>
34+
check(tastyFile :: Nil, source :: Nil) { (ctx, packages) =>
3535
packages("scala") match {
3636
case PackageImpl(_, _, _, List(trt: Trait), _, _, _, _) =>
3737
val List(foo: Def) = trt.members
@@ -74,9 +74,9 @@ abstract class UsecaseBase extends DottyDocTest {
7474
""".stripMargin
7575
)
7676

77-
val className = "scala.Test"
77+
val tastyFile = "scala/Test.tasty"
7878

79-
check(className :: Nil, source :: Nil) { (ctx, packages) =>
79+
check(tastyFile :: Nil, source :: Nil) { (ctx, packages) =>
8080
packages("scala") match {
8181
case PackageImpl(_, _, _, List(trt: Trait), _, _, _, _) =>
8282
val List(foo: Def) = trt.members
@@ -120,9 +120,9 @@ abstract class UsecaseBase extends DottyDocTest {
120120
""".stripMargin
121121
)
122122

123-
val className = "scala.Test"
123+
val tastyFile = "scala/Test.tasty"
124124

125-
check(className :: Nil, source :: Nil) { (ctx, packages) =>
125+
check(tastyFile :: Nil, source :: Nil) { (ctx, packages) =>
126126
packages("scala") match {
127127
case PackageImpl(_, _, _, List(trt: Trait), _, _, _, _) =>
128128
val List(foo: Def) = trt.members
@@ -169,9 +169,9 @@ abstract class UsecaseBase extends DottyDocTest {
169169
""".stripMargin
170170
)
171171

172-
val className = "scala.Iterable"
172+
val tastyFile = "scala/Iterable.tasty"
173173

174-
check(className :: Nil, source :: Nil) { (ctx, packages) =>
174+
check(tastyFile :: Nil, source :: Nil) { (ctx, packages) =>
175175
packages("scala") match {
176176
case PackageImpl(_, _, _, List(trt: Trait), _, _, _, _) =>
177177
val List(map: Def) = trt.members
@@ -213,9 +213,9 @@ abstract class UsecaseBase extends DottyDocTest {
213213
""".stripMargin
214214
)
215215

216-
val className = "scala.Iterable"
216+
val tastyFile = "scala/Iterable.tasty"
217217

218-
check(className :: Nil, source :: Nil) { (ctx, packages) =>
218+
check(tastyFile :: Nil, source :: Nil) { (ctx, packages) =>
219219
packages("scala") match {
220220
case PackageImpl(_, _, _, List(trt: Trait), _, _, _, _) =>
221221
val List(map: Def) = trt.members
@@ -245,9 +245,9 @@ abstract class UsecaseBase extends DottyDocTest {
245245
""".stripMargin
246246
)
247247

248-
val className = "scala.Test"
248+
val tastyFile = "scala/Test.tasty"
249249

250-
check(className :: Nil, source :: Nil) { (ctx, packages) =>
250+
check(tastyFile :: Nil, source :: Nil) { (ctx, packages) =>
251251
packages("scala") match {
252252
case PackageImpl(_, _, _, List(trt: Trait), _, _, _, _) =>
253253
val List(foo0: Def, foo1: Def) = trt.members

0 commit comments

Comments
 (0)