Skip to content

Commit 764a23e

Browse files
Merge pull request #8382 from Uko/community-test-rerun
Fix lampepfl/dotty-knowledge#30: Re-run failing community tests
2 parents 04d5068 + 92a3952 commit 764a23e

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

community-build/test/scala/dotty/communitybuild/CommunityBuildTest.scala

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,17 @@ class CommunityBuildTest:
298298
* @param arguments Arguments to pass to the testing program
299299
*/
300300
def test(project: String, command: String, arguments: Seq[String]): Unit = {
301+
@annotation.tailrec
302+
def execTimes(task: => Int, timesToRerun: Int): Boolean =
303+
val exitCode = task
304+
if exitCode == 0
305+
then true
306+
else if timesToRerun == 0
307+
then false
308+
else
309+
log(s"Rerunning tests in $project because of a previous run failure.")
310+
execTimes(task, timesToRerun - 1)
311+
301312
log(s"Building $project with dotty-bootstrapped $compilerVersion...")
302313

303314
val projectDir = communitybuildDir.resolve("community-projects").resolve(project)
@@ -312,9 +323,9 @@ class CommunityBuildTest:
312323
|""".stripMargin)
313324
}
314325

315-
val exitCode = exec(projectDir, command, arguments: _*)
326+
val testsCompletedSuccessfully = execTimes(exec(projectDir, command, arguments: _*), 3)
316327

317-
if (exitCode != 0) {
328+
if (!testsCompletedSuccessfully) {
318329
fail(s"""
319330
|
320331
|$command exited with an error code. To reproduce without JUnit, use:

0 commit comments

Comments
 (0)