From 07923f1c6269ffc459f101dd1ac06cfaefd5c86c Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Sat, 19 Nov 2016 22:27:56 +0100 Subject: Run some tests sequentially to avoid exhausting available memory Some tests are run with "-Ytest-pickler" which uses a huge amount of memory. By running these tests one by one when no other test is running, we avoid running out of memory. --- compiler/test/dotty/partest/DPConsoleRunner.scala | 39 +++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'compiler/test/dotty/partest') diff --git a/compiler/test/dotty/partest/DPConsoleRunner.scala b/compiler/test/dotty/partest/DPConsoleRunner.scala index 310cba44d..06a36f661 100644 --- a/compiler/test/dotty/partest/DPConsoleRunner.scala +++ b/compiler/test/dotty/partest/DPConsoleRunner.scala @@ -88,6 +88,45 @@ extends SuiteRunner(testSourcePath, fileManager, updateCheck, failed, javaCmdPat """.stripMargin } + /** Tests which are compiled with one or more of the flags in this list will be run + * one by one, without any other test running at the same time. + * This is necessary because some test flags require a lot of memory when running + * the compiler and may exhaust the available memory when run in parallel with other tests. + */ + def sequentialFlags = List("-Ytest-pickler") + + override def runTestsForFiles(kindFiles: Array[File], kind: String): Array[TestState] = { + val (sequentialTests, parallelTests) = + kindFiles partition { kindFile => + val flags = kindFile.changeExtension("flags").fileContents + sequentialFlags.exists(seqFlag => flags.contains(seqFlag)) + } + + val seqResults = + if (!sequentialTests.isEmpty) { + val savedThreads = sys.props("partest.threads") + sys.props("partest.threads") = "1" + + NestUI.echo(s"## we will run ${sequentialTests.length} tests sequentially") + val res = super.runTestsForFiles(sequentialTests, kind) + + if (savedThreads != null) + sys.props("partest.threads") = savedThreads + else + sys.props.remove("partest.threads") + + res + } else Array[TestState]() + + val parResults = + if (!parallelTests.isEmpty) { + NestUI.echo(s"## we will run ${parallelTests.length} tests in parallel using ${PartestDefaults.numThreads} threads") + super.runTestsForFiles(parallelTests, kind) + } else Array[TestState]() + + seqResults ++ parResults + } + // override for DPTestRunner and redirecting compilation output to test.clog override def runTest(testFile: File): TestState = { val runner = new DPTestRunner(testFile, this) -- cgit v1.2.3