Skip to content

Commit aed2582

Browse files
committed
Only run macro tests with a bootstrapped compiler
Compiling a macro with a non-bootstrapped compiler is fine, but running that macro in a subsequent compiler run as is usually done in macro tests is problematic since the MacroClassLoader is created using the compiler classpath (which contains a bootstrapped library) with the regular JVM classpath as parent classloader (which contains a non-bootstrapped library), this is inconsistent and could lead to various weird problems depending on the order in which things get loaded. One possible way to run these tests would be to always put the bootstrapped library on the JVM classpath, even if we're using the non-bootstrapped compiler, but this would cause test failures every time we would break binary compatibility. Instead, this commit moves the relevant tests to {pos,neg,run}-macros which will only be run with a bootstrapped compiler. To speed up development, it might be useful to add a flag to `testCompilation` that would put the bootstrapped library on the JVM classpath and still run these tests, but this is left as future work.
1 parent 3db70e6 commit aed2582

File tree

320 files changed

+17
-6
lines changed

Some content is hidden

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

320 files changed

+17
-6
lines changed

compiler/test/dotty/tools/dotc/BootstrappedOnlyCompilationTests.scala

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ class BootstrappedOnlyCompilationTests extends ParallelTesting {
2929

3030
// Positive tests ------------------------------------------------------------
3131

32+
@Test def posMacros: Unit = {
33+
implicit val testGroup: TestGroup = TestGroup("compilePosMacros")
34+
compileFilesInDir("tests/pos-macros", defaultOptions)
35+
}.checkCompile()
36+
3237
@Test def posWithCompiler: Unit = {
3338
implicit val testGroup: TestGroup = TestGroup("compilePosWithCompiler")
3439
compileFilesInDir("tests/pos-with-compiler", withCompilerOptions) +
@@ -69,13 +74,23 @@ class BootstrappedOnlyCompilationTests extends ParallelTesting {
6974

7075
// Negative tests ------------------------------------------------------------
7176

72-
@Test def negAll: Unit = {
77+
@Test def negMacros: Unit = {
78+
implicit val testGroup: TestGroup = TestGroup("compileNegWithCompiler")
79+
compileFilesInDir("tests/neg-macros", defaultOptions)
80+
}.checkExpectedErrors()
81+
82+
@Test def negWithCompiler: Unit = {
7383
implicit val testGroup: TestGroup = TestGroup("compileNegWithCompiler")
7484
compileFilesInDir("tests/neg-with-compiler", withCompilerOptions)
7585
}.checkExpectedErrors()
7686

7787
// Run tests -----------------------------------------------------------------
7888

89+
@Test def runMacros: Unit = {
90+
implicit val testGroup: TestGroup = TestGroup("runMacros")
91+
compileFilesInDir("tests/run-macros", defaultOptions)
92+
}.checkRuns()
93+
7994
@Test def runWithCompiler: Unit = {
8095
implicit val testGroup: TestGroup = TestGroup("runWithCompiler")
8196
compileFilesInDir("tests/run-with-compiler", withCompilerOptions) +
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

tests/run/i5533b/Macro_1.scala renamed to tests/run-macros/i5533b/Macro_1.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ object scalatest {
88
inline def assert(condition: => Boolean): Unit = ${assertImpl('condition)}
99

1010
def assertImpl(condition: Expr[Boolean])(implicit refl: Reflection): Expr[Unit] = {
11-
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(this.getClass.getClassLoader)
1211
import refl._
1312
val tree = condition.unseal
1413
def exprStr: String = condition.show
@@ -30,4 +29,4 @@ object scalatest {
3029
}
3130
}
3231
}
33-
}
32+
}
File renamed without changes.

tests/run/i5536/Macro_1.scala renamed to tests/run-macros/i5536/Macro_1.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ object scalatest {
66

77
def assertImpl(condition: Expr[Boolean])(implicit refl: Reflection): Expr[Unit] = {
88
import refl._
9-
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(this.getClass.getClassLoader)
109
val tree = condition.unseal
1110
def exprStr: String = condition.show
1211

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)