Skip to content

Commit 9746478

Browse files
committed
Enable compilation tests using parallel backend
1 parent cd43ea3 commit 9746478

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

Diff for: compiler/src/dotty/tools/backend/jvm/CodeGen.scala

+7-1
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)

Diff for: compiler/test/dotty/tools/dotc/CompilationTests.scala

+33-1
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._
@@ -219,7 +220,6 @@ class CompilationTests {
219220
compileFilesInDir("tests/init/neg", options).checkExpectedErrors()
220221
compileFilesInDir("tests/init/pos", options).checkCompile()
221222
compileFilesInDir("tests/init/crash", options.without("-Xfatal-warnings")).checkCompile()
222-
223223
// The regression test for i12128 has some atypical classpath requirements.
224224
// The test consists of three files: (a) Reflect_1 (b) Macro_2 (c) Test_3
225225
// which must be compiled separately. In addition:
@@ -241,6 +241,38 @@ class CompilationTests {
241241
tests.foreach(_.delete())
242242
}
243243
}
244+
245+
// parallel backend tests
246+
@Test def parallelBackend: Unit = {
247+
given TestGroup = TestGroup("parallelBackend")
248+
val parallelism = Runtime.getRuntime().availableProcessors().min(16)
249+
assumeTrue("Not enough available processors to run parallel tests", parallelism > 1)
250+
251+
val options = defaultOptions.and(s"-Ybackend-parallelism:${parallelism}")
252+
def parCompileDir(directory: String) = compileDir(directory, options)
253+
254+
// Compilation units containing more than 1 source file
255+
aggregateTests(
256+
parCompileDir("tests/pos/i10477"),
257+
parCompileDir("tests/pos/i4758"),
258+
parCompileDir("tests/pos/scala2traits"),
259+
parCompileDir("tests/pos/class-gadt"),
260+
parCompileDir("tests/pos/tailcall"),
261+
parCompileDir("tests/pos/reference"),
262+
parCompileDir("tests/pos/pos_valueclasses")
263+
).checkCompile()
264+
265+
aggregateTests(
266+
parCompileDir("tests/neg/package-implicit"),
267+
parCompileDir("tests/neg/package-export")
268+
).checkExpectedErrors()
269+
270+
aggregateTests(
271+
parCompileDir("tests/run/decorators"),
272+
parCompileDir("tests/run/generic")
273+
).checkRuns()
274+
275+
}
244276
}
245277

246278
object CompilationTests extends ParallelTesting {

0 commit comments

Comments
 (0)