@@ -88,27 +88,43 @@ extends SuiteRunner(testSourcePath, fileManager, updateCheck, failed, javaCmdPat
8888 """ .stripMargin
8989 }
9090
91- /** Tests which are compiled with one or more of the flags in this list will be run
92- * one by one, without any other test running at the same time.
93- * This is necessary because some test flags require a lot of memory when running
94- * the compiler and may exhaust the available memory when run in parallel with other tests.
95- */
96- def sequentialFlags = List (" -Ytest-pickler" )
91+ /** Some tests require a limitation of resources, tests which are compiled
92+ * with one or more of the flags in this list will be run with
93+ * `limitedThreads`. This is necessary because some test flags require a lot
94+ * of memory when running the compiler and may exhaust the available memory
95+ * when run in parallel with too many other tests.
96+ *
97+ * This number could be increased on the CI, but might fail locally if
98+ * scaled too extreme - override with:
99+ *
100+ * ```
101+ * -Ddotty.tests.limitedThreads=X
102+ * ```
103+ */
104+ def limitResourceFlags = List (" -Ytest-pickler" )
105+ private val limitedThreads = sys.props.get(" dotty.tests.limitedThreads" ).getOrElse(" 2" )
97106
98107 override def runTestsForFiles (kindFiles : Array [File ], kind : String ): Array [TestState ] = {
99- val (sequentialTests , parallelTests) =
108+ val (limitResourceTests , parallelTests) =
100109 kindFiles partition { kindFile =>
101110 val flags = kindFile.changeExtension(" flags" ).fileContents
102- sequentialFlags .exists(seqFlag => flags.contains(seqFlag))
111+ limitResourceFlags .exists(seqFlag => flags.contains(seqFlag))
103112 }
104113
105114 val seqResults =
106- if (! sequentialTests .isEmpty) {
115+ if (! limitResourceTests .isEmpty) {
107116 val savedThreads = sys.props(" partest.threads" )
108- sys.props(" partest.threads" ) = " 2"
117+ sys.props(" partest.threads" ) = {
118+ assert(
119+ savedThreads == null || limitedThreads.toInt <= savedThreads.toInt,
120+ """ |Should not use more threads than the default, when the point
121+ |is to limit the amount of resources""" .stripMargin
122+ )
123+ limitedThreads
124+ }
109125
110- NestUI .echo(s " ## we will run ${sequentialTests .length} tests using ${PartestDefaults .numThreads} thread(s) " )
111- val res = super .runTestsForFiles(sequentialTests , kind)
126+ NestUI .echo(s " ## we will run ${limitResourceTests .length} tests using ${PartestDefaults .numThreads} thread(s) in parallel " )
127+ val res = super .runTestsForFiles(limitResourceTests , kind)
112128
113129 if (savedThreads != null )
114130 sys.props(" partest.threads" ) = savedThreads
@@ -383,13 +399,9 @@ class DPTestRunner(testFile: File, suiteRunner: DPSuiteRunner) extends nest.Runn
383399 suiteRunner.fileManager.asInstanceOf [DottyFileManager ].extraJarList ::: super .extraClasspath
384400
385401 // override to keep class files if failed and delete clog if ok
386- override def cleanup = if (lastState.isOk) try {
402+ override def cleanup = if (lastState.isOk) {
387403 logFile.delete
388404 cLogFile.delete
389405 Directory (outDir).deleteRecursively
390- } catch {
391- case t : Throwable =>
392- println(" whhhhhhhhhhhhhhhhhhhhhhhhhhhaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaat" )
393- throw t
394406 }
395407}
0 commit comments