diff options
author | Guillaume Martres <smarter@ubuntu.com> | 2016-11-19 22:27:56 +0100 |
---|---|---|
committer | Guillaume Martres <smarter@ubuntu.com> | 2016-11-22 01:35:08 +0100 |
commit | 07923f1c6269ffc459f101dd1ac06cfaefd5c86c (patch) | |
tree | f5b9877c76a356f0c9876632b4b31d8a7dfd14d7 /compiler/test | |
parent | 1806e28cc9b82823b534abcbcf5bb36cd74732a8 (diff) | |
download | dotty-07923f1c6269ffc459f101dd1ac06cfaefd5c86c.tar.gz dotty-07923f1c6269ffc459f101dd1ac06cfaefd5c86c.tar.bz2 dotty-07923f1c6269ffc459f101dd1ac06cfaefd5c86c.zip |
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.
Diffstat (limited to 'compiler/test')
-rw-r--r-- | compiler/test/dotty/partest/DPConsoleRunner.scala | 39 |
1 files changed, 39 insertions, 0 deletions
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) |