Skip to content

Commit b195184

Browse files
committed
Remove scala3doc-test
Move testcases into dedicated project.
1 parent 11d190b commit b195184

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+60
-101
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ on:
55
paths-ignore:
66
# Do not run everything on changes only in docs
77
- 'scala3doc/**'
8-
- 'scala3doc-test/**'
8+
- 'scala3doc-testcases/**'
99
pull_request:
1010
paths-ignore:
1111
# Do not run everything on changes only in docs
1212
- 'scala3doc/**'
13-
- 'scala3doc-test/**'
13+
- 'scala3doc-testcases/**'
1414
schedule:
1515
- cron: '0 3 * * *' # Every day at 3 AM
1616

.github/workflows/scala3doc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
java-version: 11
3434

3535
- name: Compile and test
36-
run: ./project/scripts/sbt scala3doc-test/test
36+
run: ./project/scripts/sbt scala3doc/test
3737

3838
- name: Locally publish self
3939
run: ./project/scripts/sbt scala3doc/publishLocal

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ val `tasty-core` = Build.`tasty-core`
2121
val `tasty-core-bootstrapped` = Build.`tasty-core-bootstrapped`
2222
val `tasty-core-scala2` = Build.`tasty-core-scala2`
2323
val scala3doc = Build.scala3doc
24-
val `scala3doc-test` = Build.`scala3doc-test`
24+
val `scala3doc-testcases` = Build.`scala3doc-testcases`
2525
val `scala3-bench-run` = Build.`scala3-bench-run`
2626
val dist = Build.dist
2727
val `community-build` = Build.`community-build`

project/Build.scala

Lines changed: 23 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,8 +1158,10 @@ object Build {
11581158
lazy val `scala3-bench-bootstrapped` = project.in(file("bench")).asDottyBench(Bootstrapped)
11591159
lazy val `scala3-bench-run` = project.in(file("bench-run")).asDottyBench(Bootstrapped)
11601160

1161+
val testcasesOutputDir = taskKey[String]("Root directory where tests classses are generated")
1162+
val testcasesSourceRoot = taskKey[String]("Root directory where tests sources are generated")
11611163
lazy val `scala3doc` = project.in(file("scala3doc")).asScala3doc
1162-
lazy val `scala3doc-test` = project.in(file("scala3doc-test")).asScala3docTest
1164+
lazy val `scala3doc-testcases` = project.in(file("scala3doc-testcases")).asScala3docTestcases
11631165

11641166
// sbt plugin to use Dotty in your own build, see
11651167
// https://github.com/lampepfl/scala3-example-project for usage.
@@ -1448,60 +1450,34 @@ object Build {
14481450
settings(commonBenchmarkSettings).
14491451
enablePlugins(JmhPlugin)
14501452

1451-
def commonScala3docSettings = Seq(
1452-
resolvers += Resolver.jcenterRepo,
1453-
resolvers += Resolver.bintrayRepo("kotlin", "kotlin-dev"),
1454-
resolvers += Resolver.bintrayRepo("virtuslab", "dokka"),
1455-
)
1456-
14571453
def asScala3doc: Project =
14581454
project.settings(commonBootstrappedSettings).
1459-
settings(commonScala3docSettings).
14601455
dependsOn(`scala3-compiler-bootstrapped`).
14611456
dependsOn(`scala3-tasty-inspector`).
1462-
settings(artifactsForScala3Documentation := Seq(
1463-
// All projects below will be used to generated documentation for Scala 3
1464-
classDirectory.in(`scala3-interfaces`).in(Compile).value,
1465-
classDirectory.in(`tasty-core`).in(Compile).value,
1466-
classDirectory.in(`scala3-library`).in(Compile).value,
1467-
// TODO this one fails to load using TASTY
1468-
// classDirectory.in(`stdlib-bootstrapped`).in(Compile).value,
1469-
))
1470-
1471-
def asScala3docTest: Project =
1472-
project.settings(commonBootstrappedSettings0).
1473-
settings(commonScala3docSettings).
1474-
dependsOn(`scala3doc`).
14751457
settings(
1476-
Compile/doc/target := baseDirectory.value / "../out/doc" / name.value,
1477-
doc/scalaInstance := {
1478-
val externalNonBootstrappedDeps = externalDependencyClasspath.in(`scala3doc`, Compile).value
1479-
val scalaLibrary = findArtifact(externalNonBootstrappedDeps, "scala-library")
1480-
1481-
// IMPORTANT: We need to use actual jars to form the ScalaInstance and not
1482-
// just directories containing classfiles because sbt maintains a cache of
1483-
// compiler instances. This cache is invalidated based on timestamps
1484-
// however this is only implemented on jars, directories are never
1485-
// invalidated.
1486-
val tastyCore = packageBin.in(`tasty-core`, Compile).value
1487-
val dottyLibrary = packageBin.in(`scala3-library-bootstrapped`, Compile).value
1488-
val dottyInterfaces = packageBin.in(`scala3-interfaces`, Compile).value
1489-
val dottyCompiler = packageBin.in(`scala3-compiler-bootstrapped`, Compile).value
1490-
val doctool = packageBin.in(`scala3doc`, Compile).value
1491-
1492-
val allJars = Seq(tastyCore, dottyLibrary, dottyInterfaces, dottyCompiler, doctool) ++ externalNonBootstrappedDeps.map(_.data)
1493-
1494-
makeScalaInstance(
1495-
state.value,
1496-
scalaVersion.value,
1497-
scalaLibrary,
1498-
dottyLibrary,
1499-
dottyCompiler,
1500-
allJars
1501-
)
1458+
resolvers += Resolver.jcenterRepo,
1459+
resolvers += Resolver.bintrayRepo("kotlin", "kotlin-dev"),
1460+
resolvers += Resolver.bintrayRepo("virtuslab", "dokka"),
1461+
artifactsForScala3Documentation := Seq(
1462+
// All projects below will be used to generated documentation for Scala 3
1463+
classDirectory.in(`scala3-interfaces`).in(Compile).value,
1464+
classDirectory.in(`tasty-core`).in(Compile).value,
1465+
classDirectory.in(`scala3-library`).in(Compile).value,
1466+
// TODO this one fails to load using TASTY
1467+
// classDirectory.in(`stdlib-bootstrapped`).in(Compile).value,
1468+
),
1469+
test.in(Test) := {
1470+
// Test
1471+
compile.in(Compile).in(`scala3doc-testcases`).value
1472+
test.in(Test).value
15021473
},
1474+
testcasesOutputDir.in(Test) := classDirectory.in(Compile).in(`scala3doc-testcases`).value.getAbsolutePath.toString,
1475+
testcasesSourceRoot.in(Test) := (baseDirectory.in(`scala3doc-testcases`).value / "src").getAbsolutePath.toString
15031476
)
15041477

1478+
def asScala3docTestcases: Project =
1479+
project.dependsOn(`scala3-compiler-bootstrapped`).settings(commonBootstrappedSettings)
1480+
15051481
def asDist(implicit mode: Mode): Project = project.
15061482
enablePlugins(PackPlugin).
15071483
withCommonSettings.

scala3doc-test/build.sbt

Lines changed: 0 additions & 30 deletions
This file was deleted.

scala3doc/build.sbt

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ val flexmarkVersion = "0.42.12"
22
val jacksonVersion = "2.9.8"
33
val scalaTagsVersion = "0.9.1"
44
val dokkaSiteVersion = "0.1.9"
5-
5+
val dokkaVersion = "1.4.10.2"
66

77
libraryDependencies ++= Seq(
88
"org.scala-lang" %% "scala3-tasty-inspector" % scalaVersion.value,
@@ -11,16 +11,20 @@ libraryDependencies ++= Seq(
1111
"com.vladsch.flexmark" % "flexmark-all" % flexmarkVersion,
1212
"nl.big-o" % "liqp" % "0.6.7",
1313
"args4j" % "args4j" % "2.33",
14+
15+
"org.jetbrains.dokka" % "dokka-test-api" % dokkaVersion % "test",
16+
"com.novocode" % "junit-interface" % "0.11" % "test",
1417
)
1518

1619
val generateSelfDocumentation = inputKey[Unit]("Generate example documentation")
1720
generateSelfDocumentation := Def.inputTaskDyn {
18-
runSelfDocumentation(classDirectory.in(Compile).value.getAbsolutePath)
21+
generateDocumentation(classDirectory.in(Compile).value.getAbsolutePath, "scala3doc", "self", "-d documentation")
1922
}.evaluated
2023

21-
def runSelfDocumentation(classDir: String) = Def.taskDyn {
22-
val mapping = "src/main/scala=https://github.com/lampepfl/scala3doc/tree/master/src/main/scala#L"
23-
run.in(Compile).toTask(s" -o output/self -t $classDir -d documentation -n scala3doc -s $mapping")
24+
25+
def generateDocumentation(targets: String, name: String, outDir: String, params: String = "") = Def.taskDyn {
26+
val sourceMapping = "=https://github.com/lampepfl/dotty/tree/master#L"
27+
run.in(Compile).toTask(s""" -o output/$outDir -t $targets -n "$name" -s $sourceMapping $params""")
2428
}
2529

2630
// Uncomment to debug dokka processing (require to run debug in listen mode on 5005 port)
@@ -29,22 +33,31 @@ def runSelfDocumentation(classDir: String) = Def.taskDyn {
2933
fork.in(run) := true
3034
Compile / mainClass := Some("dotty.dokka.Main")
3135

32-
33-
def generateDottyDocsFromClasspath(artifacts: Seq[String]) = Def.taskDyn {
34-
val roots = artifacts.mkString(java.io.File.pathSeparator)
35-
val mapping = "=https://github.com/lampepfl/dotty/tree/master#L"
36-
if (artifacts.isEmpty) Def.task {
37-
streams.value.log.error("Dotty lib wasn't found")
38-
} else Def.task {
39-
run.in(Compile).toTask(s" -o output/stdLib -t $roots -d dotty-docs/docs -n dotty-lib -s $mapping ").value
40-
}
41-
}
36+
// There is a bug in dokka that prevents parallel tests withing the same jvm
37+
fork.in(test) := true
38+
Test / parallelExecution := false
4239

4340
val generateScala3Documentation = taskKey[Unit]("Generate documentation for dotty lib")
4441
generateScala3Documentation := Def.taskDyn {
4542
val dottyJars = Build.artifactsForScala3Documentation.value.map(_.toString)
43+
val roots = dottyJars.mkString(java.io.File.pathSeparator)
4644

47-
streams.value.log.info(s"Documenting classes from:\n${dottyJars.mkString("\n")}")
45+
if (dottyJars.isEmpty) Def.task { streams.value.log.error("Dotty lib wasn't found") }
46+
else generateDocumentation(roots, "Scala 3", "stdLib", "-d dotty-docs/docs")
47+
}.value
4848

49-
generateDottyDocsFromClasspath(dottyJars)
49+
val generateTestcasesDocumentation = taskKey[Unit]("Generate documentation for testcases, usefull for debugging tests")
50+
generateTestcasesDocumentation := Def.taskDyn {
51+
val dottyJars = Build.artifactsForScala3Documentation.value.map(_.toString)
52+
generateDocumentation(Build.testcasesOutputDir.in(Test).value, "Scala3doc testcases", "testcases")
5053
}.value
54+
55+
56+
buildInfoKeys in Test := Seq[BuildInfoKey](
57+
Build.testcasesOutputDir.in(Test),
58+
Build.testcasesSourceRoot.in(Test),
59+
)
60+
61+
buildInfoPackage in Test := "dotty.dokka"
62+
BuildInfoPlugin.buildInfoScopedSettings(Test)
63+
BuildInfoPlugin.buildInfoDefaultSettings

scala3doc-test/test/dotty/dokka/MultipleFileTest.scala renamed to scala3doc/test/dotty/dokka/MultipleFileTest.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ abstract class MultipleFileTest(val sourceFiles: List[String], val tastyFolders:
5151
def cleanup(s: String) = s.replace("\n", " ").replaceAll(" +", " ")
5252

5353
val allFromSource = sourceFiles.map{ file =>
54-
val all = signaturesFromSource(Source.fromFile(s"${BuildInfo.testSourceRoot}/tests/$file.scala"))
54+
val all = signaturesFromSource(Source.fromFile(s"${BuildInfo.test_testcasesSourceRoot}/tests/$file.scala"))
5555
(all.expected, all.unexpected)
5656
}
5757

5858
val expectedFromSource = allFromSource.map(_._1).flatten.filter(extractSymbolName(_) != "NULL").map(cleanup)
5959
val unexpectedFromSource = allFromSource.map(_._2).flatten.filter(extractSymbolName(_) != "NULL").map(cleanup)
6060
val unexpectedSignatureSymbolNames = unexpectedFromSource.map(extractSymbolName)
6161

62-
val allFromDocumentation = tastyFolders.flatMap(folder => signaturesFromDocumentation(s"${BuildInfo.testOutputDir}/tests/$folder"))
62+
val allFromDocumentation = tastyFolders.flatMap(folder => signaturesFromDocumentation(s"${BuildInfo.test_testcasesOutputDir}/tests/$folder"))
6363
val fromDocumentation = allFromDocumentation.filter(extractSymbolName(_) != "NULL").map(cleanup)
6464

6565
val documentedSignatures = fromDocumentation.flatMap(matchSignature(_, expectedFromSource)).toSet

scala3doc-test/test/dotty/dokka/tasty/comments/MemberLookupTests.scala renamed to scala3doc/test/dotty/dokka/tasty/comments/MemberLookupTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class MemberLookupTests {
123123
import java.io.File
124124
import scala.collection.mutable.ListBuffer
125125

126-
val classRoot = new File(BuildInfo.testOutputDir)
126+
val classRoot = new File(BuildInfo.test_testcasesOutputDir)
127127

128128
def go(bld: ListBuffer[String])(file: File): Unit =
129129
file.listFiles.foreach { f =>

0 commit comments

Comments
 (0)