Skip to content

Commit

Permalink
Enable compilation tests using parallel backend
Browse files Browse the repository at this point in the history
  • Loading branch information
WojciechMazur committed Oct 9, 2023
1 parent cd43ea3 commit 9746478
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 @@ -219,7 +220,6 @@ class CompilationTests {
compileFilesInDir("tests/init/neg", options).checkExpectedErrors()
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 @@ -241,6 +241,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 9746478

Please sign in to comment.