From 5d9afeae2317f4e006ae9d63fd5b1bc31efc269d Mon Sep 17 00:00:00 2001 From: Wojciech Mazur Date: Tue, 28 Mar 2023 21:53:58 +0200 Subject: [PATCH] Enable compilation tests using parallel backend --- .../dotty/tools/dotc/CompilationTests.scala | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/compiler/test/dotty/tools/dotc/CompilationTests.scala b/compiler/test/dotty/tools/dotc/CompilationTests.scala index ed531aa404c2..609928c5002c 100644 --- a/compiler/test/dotty/tools/dotc/CompilationTests.scala +++ b/compiler/test/dotty/tools/dotc/CompilationTests.scala @@ -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._ @@ -273,7 +274,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: @@ -295,6 +295,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 {