Skip to content

Commit b7681ca

Browse files
committed
Run Future tests sequentially, not concurrently
1 parent 1520fe2 commit b7681ca

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

utest/src/utest/TestRunner.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,9 @@ object TestRunner {
171171
case HTree.Leaf(f) => f().map(HTree.Leaf(_))
172172
case HTree.Node(v, children @ _*) =>
173173
for{
174-
childValues <- Future.traverse(children.toSeq)(evaluateFutureTree(_))
174+
childValues <- children.foldLeft(Future.successful(List.newBuilder[HTree[N, L]])) { (fb, c) =>
175+
fb.flatMap(b => evaluateFutureTree(c).map(b += _))
176+
}.map(_.result())
175177
} yield HTree.Node(v, childValues:_*)
176178
}
177179

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package test.utest
2+
import utest._
3+
import concurrent.{Future, ExecutionContext}
4+
5+
object FutureTest extends TestSuite {
6+
implicit val ec: ExecutionContext = ExecutionContext.global
7+
@volatile var flag = false
8+
9+
def tests = TestSuite {
10+
test("runs before next test"){
11+
Future { flag = true }
12+
}
13+
test("previous test ran first"){
14+
assert(flag)
15+
}
16+
}
17+
}

0 commit comments

Comments
 (0)