Skip to content

Commit 0b91fde

Browse files
committed
chore: add test-suite for the bootstrapped compiler
1 parent 7322dbd commit 0b91fde

File tree

6 files changed

+45
-14
lines changed

6 files changed

+45
-14
lines changed

project/Build.scala

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2292,17 +2292,20 @@ object Build {
22922292
crossPaths := true, // org.scala-lang:scala3-compiler has a crosspath
22932293
// sbt shouldn't add stdlib automatically, we depend on `scala3-library-nonbootstrapped`
22942294
autoScalaLibrary := false,
2295-
// Add the source directories for the stdlib (non-boostrapped)
2295+
// Add the source directories for the compiler (boostrapped)
22962296
Compile / unmanagedSourceDirectories := Seq(baseDirectory.value / "src"),
22972297
Compile / unmanagedSourceDirectories += baseDirectory.value / "src-bootstrapped",
2298+
// Add the test directories for the compiler (bootstrapped)
2299+
Test / unmanagedSourceDirectories := Seq(baseDirectory.value / "test"),
22982300
// All the dependencies needed by the compiler
22992301
libraryDependencies ++= Seq(
23002302
"org.scala-lang.modules" % "scala-asm" % "9.8.0-scala-1",
23012303
Dependencies.compilerInterface,
23022304
"org.jline" % "jline-reader" % "3.29.0",
23032305
"org.jline" % "jline-terminal" % "3.29.0",
23042306
"org.jline" % "jline-terminal-jni" % "3.29.0",
2305-
//("io.get-coursier" %% "coursier" % "2.0.16" % Test).cross(CrossVersion.for3Use2_13),
2307+
"com.github.sbt" % "junit-interface" % "0.13.3" % Test,
2308+
("io.get-coursier" %% "coursier" % "2.0.16" % Test).cross(CrossVersion.for3Use2_13),
23062309
),
23072310
// NOTE: The only difference here is that we drop `-Werror` and semanticDB for now
23082311
Compile / scalacOptions := Seq("-deprecation", "-feature", "-unchecked", "-encoding", "UTF8", "-language:implicitConversions"),
@@ -2346,6 +2349,7 @@ object Build {
23462349
Seq(file)
23472350
}.taskValue,
23482351
// Configure to use the non-bootstrapped compiler
2352+
managedScalaInstance := false,
23492353
scalaInstance := {
23502354
val externalCompilerDeps = (`scala3-compiler-nonbootstrapped` / Compile / externalDependencyClasspath).value.map(_.data).toSet
23512355

@@ -2412,7 +2416,39 @@ object Build {
24122416
sjsSources
24132417
} (Set(scalaJSIRSourcesJar)).toSeq
24142418
}.taskValue,
2415-
(Compile / sourceGenerators) += ShadedSourceGenerator.task.taskValue
2419+
(Compile / sourceGenerators) += ShadedSourceGenerator.task.taskValue,
2420+
// Configuration of the test suite
2421+
Test / forkOptions := (Test / forkOptions).value
2422+
.withWorkingDirectory((ThisBuild / baseDirectory).value),
2423+
Test / test := (Test / testOnly).toTask(" -- --exclude-categories=dotty.VulpixMetaTests").value,
2424+
Test / testOptions += Tests.Argument(
2425+
TestFrameworks.JUnit,
2426+
"--run-listener=dotty.tools.ContextEscapeDetector",
2427+
),
2428+
Test / javaOptions ++= {
2429+
val log = streams.value.log
2430+
val managedSrcDir = {
2431+
// Populate the directory
2432+
(Compile / managedSources).value
2433+
2434+
(Compile / sourceManaged).value
2435+
}
2436+
val externalDeps = (ThisProject / Runtime / externalDependencyClasspath).value
2437+
Seq(
2438+
s"-Ddotty.tests.dottyCompilerManagedSources=${managedSrcDir}",
2439+
s"-Ddotty.tests.classes.dottyInterfaces=${(`scala3-interfaces` / Compile / packageBin).value}",
2440+
s"-Ddotty.tests.classes.dottyCompiler=${(ThisProject / Compile / packageBin).value}",
2441+
s"-Ddotty.tests.classes.tastyCore=${(`tasty-core-bootstrapped-new` / Compile / packageBin).value}",
2442+
s"-Ddotty.tests.classes.compilerInterface=${findArtifactPath(externalDeps, "compiler-interface")}",
2443+
s"-Ddotty.tests.classes.scalaLibrary=${(`scala-library-bootstrapped` / Compile / packageBin).value}",
2444+
s"-Ddotty.tests.classes.scalaAsm=${findArtifactPath(externalDeps, "scala-asm")}",
2445+
s"-Ddotty.tests.classes.jlineTerminal=${findArtifactPath(externalDeps, "jline-terminal")}",
2446+
s"-Ddotty.tests.classes.jlineReader=${findArtifactPath(externalDeps, "jline-reader")}",
2447+
s"-Ddotty.tests.classes.dottyStaging=${(LocalProject("scala3-staging-new") / Compile / packageBin).value}",
2448+
s"-Ddotty.tests.classes.dottyTastyInspector=${(LocalProject("scala3-tasty-inspector-new") / Compile / packageBin).value}",
2449+
s"-Ddotty.tools.dotc.semanticdb.test=${(ThisBuild / baseDirectory).value/"tests"/"semanticdb"}",
2450+
)
2451+
},
24162452
)
24172453

24182454
// ==============================================================================================

tests/neg-macros/annot-crash.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
|^^^^^^
55
|Failed to evaluate macro annotation '@crash'.
66
| Caused by class scala.NotImplementedError: an implementation is missing
7-
| scala.Predef$.$qmark$qmark$qmark(Predef.scala:344)
7+
| scala.Predef$.$qmark$qmark$qmark(Predef.scala:400)
88
| crash.transform(Macro_1.scala:7)

tests/neg-macros/i23008.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
| ^^^^^^^^^^^^^^^^^^
55
| Exception occurred while executing macro expansion.
66
| java.lang.IllegalArgumentException: requirement failed: value of StringConstant cannot be `null`
7-
| at scala.Predef$.require(Predef.scala:337)
7+
| at scala.Predef$.require(Predef.scala:393)
88
| at scala.quoted.runtime.impl.QuotesImpl$reflect$StringConstant$.apply(QuotesImpl.scala:2540)
99
| at scala.quoted.runtime.impl.QuotesImpl$reflect$StringConstant$.apply(QuotesImpl.scala:2539)
1010
| at scala.quoted.ToExpr$StringToExpr.apply(ToExpr.scala:82)

tests/run-tasty-inspector/i8364.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import scala.tasty.inspector.*
1111

1212
// Artefact of the current test infrastructure
1313
// TODO improve infrastructure to avoid needing this code on each test
14-
val libJarClasspath = dotty.tools.dotc.util.ClasspathFromClassloader(this.getClass.getClassLoader).split(java.io.File.pathSeparator).find(x => x.contains("scala3-library-bootstrapped") && x.endsWith(".jar")).get
14+
val libJarClasspath = dotty.tools.dotc.util.ClasspathFromClassloader(this.getClass.getClassLoader).split(java.io.File.pathSeparator).find(x => x.contains("scala-library-bootstrapped") && x.endsWith(".jar")).get
1515

1616
TastyInspector.inspectTastyFilesInJar(libJarClasspath)(inspector)
1717
}

tests/run-tasty-inspector/scala2-library-test.scala

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,9 @@ def blacklistsOnlyContainsClassesThatExist() =
2020
loadBlacklisted.diff(scalaLibTastyPathsSet).mkString(
2121
"`loadBlacklisted` contains names that are not in `scalaLibTastyPaths`: \n ", "\n ", "\n\n"))
2222

23-
def dottyVersion =
24-
System.getProperty("java.class.path").nn.split(pathSeparator).collectFirst {
25-
case path if path.endsWith(".jar") && path.contains("scala3-library_3-") =>
26-
path.split("scala3-library_3-").last.stripSuffix(".jar")
27-
}.get
28-
2923
def scalaLibClassesPath =
3024
java.nio.file.Paths.get(
31-
s"out/bootstrap/scala2-library-bootstrapped/scala-$dottyVersion-nonbootstrapped/classes".replace("/", separator))
25+
s"library/target/scala-library-bootstrapped/classes".replace("/", separator))
3226

3327
lazy val scalaLibTastyPaths =
3428
new Directory(scalaLibClassesPath).deepFiles

tests/run-tasty-inspector/stdlibExperimentalDefinitions.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ val experimentalDefinitionInLibrary = Set(
9797
"scala.Precise",
9898
"scala.annotation.internal.WitnessNames",
9999
"scala.runtime.stdLibPatches.Predef$.is",
100+
"scala.Predef$.is",
100101

101102
// New feature: functions with erased parameters.
102103
// Need quotedPatternsWithPolymorphicFunctions enabled.
@@ -154,7 +155,7 @@ val experimentalDefinitionInLibrary = Set(
154155

155156
// Artefact of the current test infrastructure
156157
// TODO improve infrastructure to avoid needing this code on each test
157-
val libJarClasspath = dotty.tools.dotc.util.ClasspathFromClassloader(this.getClass.getClassLoader).split(java.io.File.pathSeparator).find(x => x.contains("scala3-library-bootstrapped") && x.endsWith(".jar")).get
158+
val libJarClasspath = dotty.tools.dotc.util.ClasspathFromClassloader(this.getClass.getClassLoader).split(java.io.File.pathSeparator).find(x => x.contains("scala-library-bootstrapped") && x.endsWith(".jar")).get
158159

159160
TastyInspector.inspectTastyFilesInJar(libJarClasspath)(inspector)
160161
}

0 commit comments

Comments
 (0)