Skip to content

Commit

Permalink
CI failure: blindly retry, as I can't reproduce anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
lefou committed Sep 14, 2021
1 parent c680c79 commit 8f46947
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion contrib/scoverage/test/src/HelloWorldTests.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package mill.contrib.scoverage

import scala.annotation.tailrec

import mill._
import mill.contrib.buildinfo.BuildInfo
import mill.scalalib._
Expand Down Expand Up @@ -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" - {
Expand Down

0 comments on commit 8f46947

Please sign in to comment.