Skip to content

Commit 327be51

Browse files
[CI] Restore compilation and tests of scaladoc (#24779)
The `scaladoc` project has not been compiled or tested recently. - Restore CI checks for scaladoc - Fixes compilation under -Yexplicit-nulls - Adjust tests for the new classpath without Scala 2 stdlib: - Remove `Scaladoc2LegacyExternalLocationProviderIntegrationTest` cannot be tested without any Scala 2 library on classpath. - Change order of `ExternalMappings` - previously it picked Scala 2 first (`.*scala/.*:`), then `.*externalStubs.*` - it no longer matches becouse first filter was applied only to Scala2 stdlib, but not to the Scala 3 stdlib additions. Switching order makes the 2 tests pass again - `project/scripts/cmdScaladocTests` removed dead logic towards Scala 2 stdlib
1 parent 8ff2fca commit 327be51

File tree

6 files changed

+16
-57
lines changed

6 files changed

+16
-57
lines changed

.github/workflows/scaladoc.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ jobs:
4141
- name: Compile and test scala3doc-js
4242
run: ./project/scripts/sbt scaladoc-js-main/test
4343

44-
#- name: Compile and test
45-
# run: |
46-
# ./project/scripts/sbt scaladoc/test
47-
# ./project/scripts/sbt dist/Universal/stage
48-
# ./project/scripts/cmdScaladocTests
44+
- name: Compile and test
45+
run: |
46+
./project/scripts/sbt scaladoc/test
47+
./project/scripts/sbt dist/Universal/stage
48+
./project/scripts/cmdScaladocTests
4949
5050
- name: Locally publish self
5151
run: ./project/scripts/sbt scaladoc/publishLocal

project/scripts/cmdScaladocTests

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ clear_out "$OUT"
77
clear_out "$OUT1"
88

99

10-
STDLIB_COMMAND="$SBT \"eval println(Build.stdlibVersion(Modes.NonBootstrapped))\""
11-
STDLIB_VERSION=$(eval $STDLIB_COMMAND | tail -n 2 | head -n 1)
12-
1310
DOTTY_NONBOOTSTRAPPED_VERSION_COMMAND="$SBT \"eval println(Build.dottyNonBootstrappedVersion)\""
1411
DOTTY_NONBOOTSTRAPPED_VERSION=$(eval $DOTTY_NONBOOTSTRAPPED_VERSION_COMMAND | tail -n 2 | head -n 1)
1512

@@ -23,8 +20,6 @@ SOURCE_LINKS_VERSION="${GITHUB_SHA:-$DOTTY_BOOTSTRAPPED_VERSION}"
2320
dist/target/universal/stage/bin/scaladoc \
2421
-d "$OUT1" \
2522
-project "scaladoc testcases" \
26-
-source-links:out/bootstrap/scala2-library-bootstrapped/scala-"${DOTTY_NONBOOTSTRAPPED_VERSION}"/src_managed/main/scala-library-src=github://scala/scala/v"${STDLIB_VERSION}"#src/library \
27-
-source-links:out/bootstrap/scala2-library-bootstrapped/scala-"${DOTTY_NONBOOTSTRAPPED_VERSION}"/src_managed/main/dotty-library-src=github://"${SOURCE_LINKS_REPOSITORY}"/"${SOURCE_LINKS_VERSION}"\#library/src \
2823
-source-links:github://"${SOURCE_LINKS_REPOSITORY}"/"${SOURCE_LINKS_VERSION}" \
2924
"-external-mappings:.*scala/.*::scaladoc3::https://dotty.epfl.ch/api/,.*java/.*::javadoc::https://docs.oracle.com/javase/8/docs/api/" \
3025
"-skip-by-regex:.+\.internal($|\..+)" \

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class BaseHtmlTest:
3939
projectVersion = Some(projectVersion)
4040
))
4141
Scaladoc.run(args)(using testContext)
42-
op(using ProjectContext(args.output.toPath))
42+
op(using ProjectContext(args.output.nn.toPath))
4343

4444
finally IO.delete(dest)
4545
end withGeneratedDoc

scaladoc/test/dotty/tools/scaladoc/ExternalLocationProviderIntegrationTest.scala

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package dotty.tools.scaladoc
22

3-
import scala.io.Source
43
import scala.jdk.CollectionConverters._
5-
import scala.util.matching.Regex
64
import dotty.tools.scaladoc.test.BuildInfo
75
import java.nio.file.Path;
86
import org.jsoup.Jsoup
@@ -26,8 +24,8 @@ class JavadocExternalLocationProviderIntegrationTest extends ExternalLocationPro
2624
class Scaladoc2ExternalLocationProviderIntegrationTest extends ExternalLocationProviderIntegrationTest(
2725
"externalScaladoc2",
2826
List(
27+
".*externalStubs.*::scaladoc2::https://external.stubs/api/",
2928
".*scala/.*::scaladoc2::https://www.scala-lang.org/api/current/",
30-
".*externalStubs.*::scaladoc2::https://external.stubs/api/"
3129
),
3230
List(
3331
"https://www.scala-lang.org/api/current/scala/util/matching/Regex$$Match.html",
@@ -43,8 +41,8 @@ class Scaladoc2ExternalLocationProviderIntegrationTest extends ExternalLocationP
4341
class Scaladoc3ExternalLocationProviderIntegrationTest extends ExternalLocationProviderIntegrationTest(
4442
"externalScaladoc3",
4543
List(
44+
".*externalStubs.*::scaladoc3::https://external.stubs/api/",
4645
".*scala/.*::scaladoc3::https://dotty.epfl.ch/api/",
47-
".*externalStubs.*::scaladoc3::https://external.stubs/api/"
4846
),
4947
List(
5048
"https://dotty.epfl.ch/api/scala/collection/immutable/Map.html",
@@ -55,26 +53,6 @@ class Scaladoc3ExternalLocationProviderIntegrationTest extends ExternalLocationP
5553
)
5654
)
5755

58-
def getScalaLibraryPath: String = {
59-
val classpath: List[String] = System.getProperty("java.class.path").split(java.io.File.pathSeparatorChar).toList
60-
// For an unclear reason, depending on if we pass the compiler context onto the tasty inspector
61-
// the scala-2-library path needs to have its characters case fixed with new java.io.File(stdlib).getCanonicalPath()
62-
classpath.find(_.contains("scala-library-2")).getOrElse("foobarbazz") // If we don't find the scala 2 library, the test will fail
63-
}
64-
65-
class Scaladoc2LegacyExternalLocationProviderIntegrationTest extends LegacyExternalLocationProviderIntegrationTest(
66-
"externalScaladoc2",
67-
List(s"${getScalaLibraryPath}#https://www.scala-lang.org/api/current/"),
68-
List(
69-
"https://www.scala-lang.org/api/current/scala/util/matching/Regex$$Match.html",
70-
"https://www.scala-lang.org/api/current/scala/Predef$.html#String",
71-
"https://www.scala-lang.org/api/current/scala/collection/immutable/Map.html",
72-
"https://www.scala-lang.org/api/current/scala/collection/IterableOnceOps.html#addString(b:StringBuilder,start:String,sep:String,end:String):b.type",
73-
"https://www.scala-lang.org/api/current/scala/collection/IterableOnceOps.html#mkString(start:String,sep:String,end:String):String"
74-
)
75-
)
76-
77-
7856
abstract class ExternalLocationProviderIntegrationTest(
7957
name: String,
8058
mappings: Seq[String],
@@ -89,7 +67,7 @@ abstract class ExternalLocationProviderIntegrationTest(
8967
)
9068

9169
override def runTest = afterRendering {
92-
val output = summon[DocContext].args.output.toPath
70+
val output = summon[DocContext].args.output.nn.toPath
9371
val linksBuilder = List.newBuilder[String]
9472

9573
def processFile(path: Path): Unit =
@@ -113,17 +91,3 @@ abstract class ExternalLocationProviderIntegrationTest(
11391
reportError(reportMessage)
11492
}
11593
} :: Nil
116-
117-
abstract class LegacyExternalLocationProviderIntegrationTest(
118-
name: String,
119-
mappings: Seq[String],
120-
expectedLinks: Seq[String]
121-
) extends ExternalLocationProviderIntegrationTest(name, mappings, expectedLinks):
122-
123-
override def args = super.args.copy(
124-
externalMappings = mappings.flatMap( s =>
125-
ExternalDocLink.parseLegacy(s).fold(left => None, right => Some(right)
126-
)
127-
).toList
128-
)
129-

scaladoc/test/dotty/tools/scaladoc/signatures/SignatureTest.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ abstract class SignatureTest(
8787
kindMatch <- kinds.flatMap(k =>s"\\b$k\\b".r.findFirstMatchIn(signature)).headOption
8888
kind <- Option(kindMatch.group(0)) // to filter out nulls
8989
afterKind <- Option(kindMatch.after(0)) // to filter out nulls
90-
name <- if kind.contains("extension") then Some(signature) // The name of an extension will always be the signature itself
90+
case name: String <- if kind.contains("extension") then Some(signature) // The name of an extension will always be the signature itself
9191
else identifierRegex.findFirstMatchIn(afterKind).map(_.group(1))
9292
yield name
9393

@@ -97,8 +97,8 @@ abstract class SignatureTest(
9797
.filterNot(l => l.startWithAnyOfThese("=",":","{","}", "//") && !l.startsWith("//expected:"))
9898
.toSeq
9999
.flatMap {
100-
case unexpectedRegex(signature) => findName(signature, kinds).map(Unexpected(_))
101-
case expectedRegex(signature) => findName(signature, kinds).map(Expected(_, signature))
100+
case unexpectedRegex(signature: String) => findName(signature, kinds).map(Unexpected(_))
101+
case expectedRegex(signature: String) => findName(signature, kinds).map(Expected(_, signature))
102102
case signature =>
103103
findName(signature, kinds).map(
104104
Expected(_, commentRegex.replaceAllIn(signature, "")
@@ -107,7 +107,7 @@ abstract class SignatureTest(
107107
}
108108

109109
private def signaturesFromDocumentation()(using DocContext): Seq[String] =
110-
val output = summon[DocContext].args.output.toPath
110+
val output = summon[DocContext].args.output.nn.toPath
111111
val signatures = List.newBuilder[String]
112112

113113
def processFile(path: Path): Unit = if filterFunc(path) then

scaladoc/test/dotty/tools/scaladoc/snippets/SnippetsE2eTest.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,16 +146,16 @@ object SnippetsE2eTest:
146146
case class Message(level: MessageLevel, offset: Offset)
147147
object SnippetInfo:
148148
def apply(str: String): SnippetInfo = str match {
149-
case snippetInfoRegex(ol, oc, il, ic) => SnippetInfo(
149+
case snippetInfoRegex(ol: String, oc: String, il: String, ic: String) => SnippetInfo(
150150
Offset(ol.toInt, oc.toInt),
151151
Offset(il.toInt, ic.toInt)
152152
)
153153
}
154154

155155
object Message:
156156
def apply(str: String): Message = str match {
157-
case errorRegex(ln, cl) => Message(MessageLevel.Error, Offset(ln.toInt, cl.toInt))
158-
case warningRegex(ln, cl) => Message(MessageLevel.Warning, Offset(ln.toInt, cl.toInt))
157+
case errorRegex(ln: String, cl: String) => Message(MessageLevel.Error, Offset(ln.toInt, cl.toInt))
158+
case warningRegex(ln: String, cl: String) => Message(MessageLevel.Warning, Offset(ln.toInt, cl.toInt))
159159
}
160160
val snippetInfoRegex = (raw"SNIPPET\(" +
161161
raw"OUTERLINEOFFSET:(\d+),OUTERCOLUMNOFFSET:(\d+)," +

0 commit comments

Comments
 (0)