Skip to content

Commit f0a8100

Browse files
committed
Enable compilation tests using parallel backend
[Cherry-picked 9746478]
1 parent 49b21db commit f0a8100

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

compiler/src/dotty/tools/backend/jvm/CodeGen.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,13 @@ class CodeGen(val int: DottyBackendInterface, val primitives: DottyPrimitives)(
7272
genTastyAndSetAttributes(sym, tastyAttrNode)
7373

7474
def registerGeneratedClass(classNode: ClassNode, isArtifact: Boolean): Unit =
75-
generatedClasses += GeneratedClass(classNode, sym.javaClassName, sym.srcPos.sourcePos, isArtifact, onFileCreated(classNode, sym, unit.source))
75+
if classNode ne null then
76+
generatedClasses += GeneratedClass(classNode,
77+
sourceClassName = sym.javaClassName,
78+
position = sym.srcPos.sourcePos,
79+
isArtifact = isArtifact,
80+
onFileCreated = onFileCreated(classNode, sym, unit.source)
81+
)
7682

7783
registerGeneratedClass(mainClassNode, isArtifact = false)
7884
registerGeneratedClass(mirrorClassNode, isArtifact = true)

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

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import scala.concurrent.duration._
1818
import TestSources.sources
1919
import reporting.TestReporter
2020
import vulpix._
21+
import dotty.tools.dotc.config.ScalaSettings
2122

2223
class CompilationTests {
2324
import ParallelTesting._
@@ -212,7 +213,6 @@ class CompilationTests {
212213
compileFilesInDir("tests/init/warn", defaultOptions.and("-Ysafe-init")).checkWarnings()
213214
compileFilesInDir("tests/init/pos", options).checkCompile()
214215
compileFilesInDir("tests/init/crash", options.without("-Xfatal-warnings")).checkCompile()
215-
216216
// The regression test for i12128 has some atypical classpath requirements.
217217
// The test consists of three files: (a) Reflect_1 (b) Macro_2 (c) Test_3
218218
// which must be compiled separately. In addition:
@@ -234,6 +234,38 @@ class CompilationTests {
234234
tests.foreach(_.delete())
235235
}
236236
}
237+
238+
// parallel backend tests
239+
@Test def parallelBackend: Unit = {
240+
given TestGroup = TestGroup("parallelBackend")
241+
val parallelism = Runtime.getRuntime().availableProcessors().min(16)
242+
assumeTrue("Not enough available processors to run parallel tests", parallelism > 1)
243+
244+
val options = defaultOptions.and(s"-Ybackend-parallelism:${parallelism}")
245+
def parCompileDir(directory: String) = compileDir(directory, options)
246+
247+
// Compilation units containing more than 1 source file
248+
aggregateTests(
249+
parCompileDir("tests/pos/i10477"),
250+
parCompileDir("tests/pos/i4758"),
251+
parCompileDir("tests/pos/scala2traits"),
252+
parCompileDir("tests/pos/class-gadt"),
253+
parCompileDir("tests/pos/tailcall"),
254+
parCompileDir("tests/pos/reference"),
255+
parCompileDir("tests/pos/pos_valueclasses")
256+
).checkCompile()
257+
258+
aggregateTests(
259+
parCompileDir("tests/neg/package-implicit"),
260+
parCompileDir("tests/neg/package-export")
261+
).checkExpectedErrors()
262+
263+
aggregateTests(
264+
parCompileDir("tests/run/decorators"),
265+
parCompileDir("tests/run/generic")
266+
).checkRuns()
267+
268+
}
237269
}
238270

239271
object CompilationTests extends ParallelTesting {

0 commit comments

Comments
 (0)