Skip to content

Commit 5ebdae6

Browse files
committed
Fix tests in scaladoc
1 parent db20d9c commit 5ebdae6

File tree

5 files changed

+22
-20
lines changed

5 files changed

+22
-20
lines changed

project/Build.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,7 +1151,7 @@ object Build {
11511151
lazy val `scala3-bench-bootstrapped` = project.in(file("bench")).asDottyBench(Bootstrapped)
11521152
lazy val `scala3-bench-run` = project.in(file("bench-run")).asDottyBench(Bootstrapped)
11531153

1154-
val testcasesOutputDir = taskKey[String]("Root directory where tests classses are generated")
1154+
val testcasesOutputDir = taskKey[Seq[String]]("Root directory where tests classses are generated")
11551155
val testcasesSourceRoot = taskKey[String]("Root directory where tests sources are generated")
11561156
val testDocumentationRoot = taskKey[String]("Root directory where tests documentation are stored")
11571157
val generateSelfDocumentation = taskKey[Unit]("Generate example documentation")
@@ -1512,13 +1512,13 @@ object Build {
15121512
}
15131513

15141514
def joinProducts(products: Seq[java.io.File]): String =
1515-
products.iterator.map(_.getAbsolutePath).map(p => s"'$p'").mkString(" ")
1515+
products.iterator.map(_.getAbsolutePath).mkString(" ")
15161516

15171517
val flexmarkVersion = "0.42.12"
15181518

15191519
scaladocBasic(Bootstrapped).settings(
15201520
Test / test := (Test / test).dependsOn(compile.in(Compile).in(`scaladoc-testcases`)).value,
1521-
testcasesOutputDir.in(Test) := joinProducts((`scaladoc-testcases`/Compile/products).value),
1521+
testcasesOutputDir.in(Test) := (`scaladoc-testcases`/Compile/products).value.map(_.getAbsolutePath),
15221522
testcasesSourceRoot.in(Test) := (baseDirectory.in(`scaladoc-testcases`).value / "src").getAbsolutePath.toString,
15231523
baseDirectory.in(run) := baseDirectory.in(ThisBuild).value,
15241524
generateSelfDocumentation := Def.taskDyn {
@@ -1588,7 +1588,7 @@ object Build {
15881588

15891589
generateTestcasesDocumentation := Def.taskDyn {
15901590
generateDocumentation(
1591-
Build.testcasesOutputDir.in(Test).value :: Nil,
1591+
Build.testcasesOutputDir.in(Test).value,
15921592
"scaladoc testcases",
15931593
"scaladoc/output/testcases",
15941594
"master")

scaladoc/test/dotty/tools/scaladoc/BaseHtmlTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class BaseHtmlTest:
3131
try
3232
val args = Scaladoc.Args(
3333
name = projectName,
34-
tastyFiles = pcks.flatMap(tastyFiles),
34+
tastyFiles = pcks.flatMap(tastyFiles(_)),
3535
output = dest.toFile,
3636
docsRoot = docsRoot,
3737
projectVersion = Some(projectVersion),

scaladoc/test/dotty/tools/scaladoc/RaportingTest.scala

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ class ReportingTest:
3333
assertNoInfos(diag)
3434
}
3535

36-
@Test
37-
def noClassesErors = checkReportedDiagnostics(_.copy(tastyFiles = Nil)){ diag =>
38-
assertMessagesAbout(diag.errorMsgs)("classes should no be empty")
39-
}
40-
4136
@Test
4237
def errorsInCaseOfIncompletClasspath =
4338
val notTasty = Files.createTempFile("broken", ".notTasty")

scaladoc/test/dotty/tools/scaladoc/tasty/util/TestUtils.scala

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,24 @@ object TestUtils {
88
import java.io.File
99
import scala.collection.mutable.ListBuffer
1010

11-
val classRoot = new File(BuildInfo.test_testcasesOutputDir)
12-
1311
def go(bld: ListBuffer[String])(file: File): Unit =
1412
file.listFiles.foreach { f =>
1513
if f.isFile() then
1614
if f.toString.endsWith(".tasty") then bld.append(f.toString)
1715
else go(bld)(f)
1816
}
1917

20-
if classRoot.isDirectory then
21-
val bld = new ListBuffer[String]
22-
go(bld)(classRoot)
23-
bld.result
24-
else
25-
sys.error(s"Class root could not be found: $classRoot")
18+
def listEntry(entry: String): List[String] =
19+
val classRoot = File(entry)
20+
if classRoot.isDirectory then
21+
val bld = new ListBuffer[String]
22+
go(bld)(classRoot)
23+
bld.result
24+
else
25+
sys.error(s"Class root could not be found: $classRoot")
26+
27+
val files = BuildInfo.test_testcasesOutputDir.flatMap(listEntry).toList
28+
assert(files.nonEmpty, "Provided list of root directories is empty")
29+
files
2630
}
2731
}

scaladoc/test/dotty/tools/scaladoc/testUtils.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def testContext = (new ContextBase).initialCtx.fresh.setReporter(new TestReporte
6060

6161
def testDocContext(files: Seq[File] = Nil) = DocContext(testArgs(files), testContext)
6262

63-
def tastyFiles(name: String) =
63+
def tastyFiles(name: String, allowEmpty: Boolean = false) =
6464
def listFilesSafe(dir: File) = Option(dir.listFiles).getOrElse {
6565
throw AssertionError(s"$dir not found. The test name is incorrect or scaladoc-testcases were not recompiled.")
6666
}
@@ -69,4 +69,7 @@ def tastyFiles(name: String) =
6969
case f if f.getName endsWith ".tasty" => f :: Nil
7070
case _ => Nil
7171
}
72-
collectFiles(File(s"${BuildInfo.test_testcasesOutputDir}/tests/$name"))
72+
val files = BuildInfo.test_testcasesOutputDir.flatMap(p => collectFiles(File(s"$p/tests/$name")))
73+
assert(files.nonEmpty || allowEmpty)
74+
files.toSeq
75+

0 commit comments

Comments
 (0)