Skip to content

Commit 20ff42c

Browse files
committed
chore: add test-suite for the bootstrapped compiler
1 parent dc590d6 commit 20ff42c

File tree

6 files changed

+44
-13
lines changed

6 files changed

+44
-13
lines changed

project/Build.scala

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2261,17 +2261,20 @@ object Build {
22612261
crossPaths := true, // org.scala-lang:scala3-compiler has a crosspath
22622262
// sbt shouldn't add stdlib automatically, we depend on `scala3-library-nonbootstrapped`
22632263
autoScalaLibrary := false,
2264-
// Add the source directories for the stdlib (non-boostrapped)
2264+
// Add the source directories for the compiler (boostrapped)
22652265
Compile / unmanagedSourceDirectories := Seq(baseDirectory.value / "src"),
22662266
Compile / unmanagedSourceDirectories += baseDirectory.value / "src-bootstrapped",
2267+
// Add the test directories for the compiler (bootstrapped)
2268+
Test / unmanagedSourceDirectories := Seq(baseDirectory.value / "test"),
22672269
// All the dependencies needed by the compiler
22682270
libraryDependencies ++= Seq(
22692271
"org.scala-lang.modules" % "scala-asm" % "9.8.0-scala-1",
22702272
Dependencies.compilerInterface,
22712273
"org.jline" % "jline-reader" % "3.29.0",
22722274
"org.jline" % "jline-terminal" % "3.29.0",
22732275
"org.jline" % "jline-terminal-jni" % "3.29.0",
2274-
//("io.get-coursier" %% "coursier" % "2.0.16" % Test).cross(CrossVersion.for3Use2_13),
2276+
"com.github.sbt" % "junit-interface" % "0.13.3" % Test,
2277+
("io.get-coursier" %% "coursier" % "2.0.16" % Test).cross(CrossVersion.for3Use2_13),
22752278
),
22762279
// NOTE: The only difference here is that we drop `-Werror` and semanticDB for now
22772280
Compile / scalacOptions := Seq("-deprecation", "-feature", "-unchecked", "-encoding", "UTF8", "-language:implicitConversions"),
@@ -2315,6 +2318,7 @@ object Build {
23152318
Seq(file)
23162319
}.taskValue,
23172320
// Configure to use the non-bootstrapped compiler
2321+
managedScalaInstance := false,
23182322
scalaInstance := {
23192323
val externalCompilerDeps = (`scala3-compiler-nonbootstrapped` / Compile / externalDependencyClasspath).value.map(_.data).toSet
23202324

@@ -2381,6 +2385,38 @@ object Build {
23812385
sjsSources
23822386
} (Set(scalaJSIRSourcesJar)).toSeq
23832387
}.taskValue,
2388+
// Configuration of the test suite
2389+
Test / forkOptions := (Test / forkOptions).value
2390+
.withWorkingDirectory((ThisBuild / baseDirectory).value),
2391+
Test / test := (Test / testOnly).toTask(" -- --exclude-categories=dotty.VulpixMetaTests").value,
2392+
Test / testOptions += Tests.Argument(
2393+
TestFrameworks.JUnit,
2394+
"--run-listener=dotty.tools.ContextEscapeDetector",
2395+
),
2396+
Test / javaOptions ++= {
2397+
val log = streams.value.log
2398+
val managedSrcDir = {
2399+
// Populate the directory
2400+
(Compile / managedSources).value
2401+
2402+
(Compile / sourceManaged).value
2403+
}
2404+
val externalDeps = (ThisProject / Runtime / externalDependencyClasspath).value
2405+
Seq(
2406+
s"-Ddotty.tests.dottyCompilerManagedSources=${managedSrcDir}",
2407+
s"-Ddotty.tests.classes.dottyInterfaces=${(`scala3-interfaces` / Compile / packageBin).value}",
2408+
s"-Ddotty.tests.classes.dottyCompiler=${(ThisProject / Compile / packageBin).value}",
2409+
s"-Ddotty.tests.classes.tastyCore=${(`tasty-core-bootstrapped-new` / Compile / packageBin).value}",
2410+
s"-Ddotty.tests.classes.compilerInterface=${findArtifactPath(externalDeps, "compiler-interface")}",
2411+
s"-Ddotty.tests.classes.scalaLibrary=${(`scala-library-bootstrapped` / Compile / packageBin).value}",
2412+
s"-Ddotty.tests.classes.scalaAsm=${findArtifactPath(externalDeps, "scala-asm")}",
2413+
s"-Ddotty.tests.classes.jlineTerminal=${findArtifactPath(externalDeps, "jline-terminal")}",
2414+
s"-Ddotty.tests.classes.jlineReader=${findArtifactPath(externalDeps, "jline-reader")}",
2415+
s"-Ddotty.tests.classes.dottyStaging=${(LocalProject("scala3-staging-new") / Compile / packageBin).value}",
2416+
s"-Ddotty.tests.classes.dottyTastyInspector=${(LocalProject("scala3-tasty-inspector-new") / Compile / packageBin).value}",
2417+
s"-Ddotty.tools.dotc.semanticdb.test=${(ThisBuild / baseDirectory).value/"tests"/"semanticdb"}",
2418+
)
2419+
},
23842420
)
23852421

23862422
// ==============================================================================================

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)