Skip to content

Commit

Permalink
Enable compilation tests using parallel backend
Browse files Browse the repository at this point in the history
[Cherry-picked 9746478]
  • Loading branch information
WojciechMazur committed Jul 10, 2024
1 parent 49b21db commit f0a8100
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
8 changes: 7 additions & 1 deletion compiler/src/dotty/tools/backend/jvm/CodeGen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,13 @@ class CodeGen(val int: DottyBackendInterface, val primitives: DottyPrimitives)(
genTastyAndSetAttributes(sym, tastyAttrNode)

def registerGeneratedClass(classNode: ClassNode, isArtifact: Boolean): Unit =
generatedClasses += GeneratedClass(classNode, sym.javaClassName, sym.srcPos.sourcePos, isArtifact, onFileCreated(classNode, sym, unit.source))
if classNode ne null then
generatedClasses += GeneratedClass(classNode,
sourceClassName = sym.javaClassName,
position = sym.srcPos.sourcePos,
isArtifact = isArtifact,
onFileCreated = onFileCreated(classNode, sym, unit.source)
)

registerGeneratedClass(mainClassNode, isArtifact = false)
registerGeneratedClass(mirrorClassNode, isArtifact = true)
Expand Down
34 changes: 33 additions & 1 deletion compiler/test/dotty/tools/dotc/CompilationTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import scala.concurrent.duration._
import TestSources.sources
import reporting.TestReporter
import vulpix._
import dotty.tools.dotc.config.ScalaSettings

class CompilationTests {
import ParallelTesting._
Expand Down Expand Up @@ -212,7 +213,6 @@ class CompilationTests {
compileFilesInDir("tests/init/warn", defaultOptions.and("-Ysafe-init")).checkWarnings()
compileFilesInDir("tests/init/pos", options).checkCompile()
compileFilesInDir("tests/init/crash", options.without("-Xfatal-warnings")).checkCompile()

// The regression test for i12128 has some atypical classpath requirements.
// The test consists of three files: (a) Reflect_1 (b) Macro_2 (c) Test_3
// which must be compiled separately. In addition:
Expand All @@ -234,6 +234,38 @@ class CompilationTests {
tests.foreach(_.delete())
}
}

// parallel backend tests
@Test def parallelBackend: Unit = {
given TestGroup = TestGroup("parallelBackend")
val parallelism = Runtime.getRuntime().availableProcessors().min(16)
assumeTrue("Not enough available processors to run parallel tests", parallelism > 1)

val options = defaultOptions.and(s"-Ybackend-parallelism:${parallelism}")
def parCompileDir(directory: String) = compileDir(directory, options)

// Compilation units containing more than 1 source file
aggregateTests(
parCompileDir("tests/pos/i10477"),
parCompileDir("tests/pos/i4758"),
parCompileDir("tests/pos/scala2traits"),
parCompileDir("tests/pos/class-gadt"),
parCompileDir("tests/pos/tailcall"),
parCompileDir("tests/pos/reference"),
parCompileDir("tests/pos/pos_valueclasses")
).checkCompile()

aggregateTests(
parCompileDir("tests/neg/package-implicit"),
parCompileDir("tests/neg/package-export")
).checkExpectedErrors()

aggregateTests(
parCompileDir("tests/run/decorators"),
parCompileDir("tests/run/generic")
).checkRuns()

}
}

object CompilationTests extends ParallelTesting {
Expand Down

0 comments on commit f0a8100

Please sign in to comment.