From 8f46947fb278053b956fb16b501aace7997d67ec Mon Sep 17 00:00:00 2001 From: Tobias Roeser Date: Tue, 14 Sep 2021 09:53:12 +0200 Subject: [PATCH] CI failure: blindly retry, as I can't reproduce anymore --- contrib/scoverage/test/src/HelloWorldTests.scala | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/contrib/scoverage/test/src/HelloWorldTests.scala b/contrib/scoverage/test/src/HelloWorldTests.scala index 29f823ba1cf..e521f1e452f 100644 --- a/contrib/scoverage/test/src/HelloWorldTests.scala +++ b/contrib/scoverage/test/src/HelloWorldTests.scala @@ -1,5 +1,7 @@ package mill.contrib.scoverage +import scala.annotation.tailrec + import mill._ import mill.contrib.buildinfo.BuildInfo import mill.scalalib._ @@ -63,13 +65,24 @@ trait HelloWorldTests extends utest.TestSuite { resourcePath: os.Path = resourcePath )(t: TestEvaluator => T)(implicit tp: TestPath): T = { val eval = new TestEvaluator(m, threads = threadCount, debugEnabled = true) - os.remove.all(m.millSourcePath) + retry(3, 500) { os.remove.all(m.millSourcePath) } os.remove.all(eval.outPath) os.makeDir.all(m.millSourcePath / os.up) os.copy(resourcePath, m.millSourcePath) t(eval) } + @tailrec private final def retry[T](n: Int, wait: Long)(body: => T): T = { + try body + catch { + case e: Throwable => + if (n > 0) { + Thread.sleep(wait) + retry(n - 1, wait)(body) + } else throw e + } + } + def tests: utest.Tests = utest.Tests { "HelloWorld" - { "core" - {