Skip to content

Commit a50ab5a

Browse files
committed
improvement: Add a larger timeout for tests and don't wait
1 parent 21251c6 commit a50ab5a

3 files changed

Lines changed: 35 additions & 13 deletions

File tree

frontend/src/test/scala/bloop/TestSpec.scala

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -389,24 +389,27 @@ object JvmTestSpec extends BaseTestSpec("test-project-test", "cross-test-build-s
389389
}
390390

391391
object NoTestFrameworksSpec extends ProjectBaseSuite("no-test-frameworks") {
392-
testProject("must have frameworks in test project", runOnlyOnJava8 = false) { (build, logger) =>
393-
val project = build.projectFor("myProject")
394-
val testState = build.state.test(project)
395-
try {
396-
assert(!testState.status.isOk)
397-
assert(logger.errors.contains("Missing configured test frameworks in myProject-test"))
398-
} catch { case err: AssertionError => logger.dump(); throw err }
392+
testProjectTask("must have frameworks in test project", runOnlyOnJava8 = false) {
393+
(build, logger) =>
394+
val project = build.projectFor("myProject")
395+
build.state.testTask(project).map { testState =>
396+
try {
397+
assert(!testState.status.isOk)
398+
assert(logger.errors.contains("Missing configured test frameworks in myProject-test"))
399+
} catch { case err: AssertionError => logger.dump(); throw err }
400+
}
399401
}
400402

401-
testProject("non-test projects can have empty frameworks", runOnlyOnJava8 = false) {
403+
testProjectTask("non-test projects can have empty frameworks", runOnlyOnJava8 = false) {
402404
(rawBuild, logger) =>
403405
val build = rawBuild.filterProjectsByName(!_.endsWith("-test"))
404406
val project = build.projectFor("myProject")
405-
val testState = build.state.test(project)
406-
try {
407-
assert(testState.status.isOk)
408-
// No message is logged - this is not a test target, and therefore it is ignored.
409-
} catch { case err: AssertionError => logger.dump(); throw err }
407+
build.state.testTask(project).map { testState =>
408+
try {
409+
assert(testState.status.isOk)
410+
// No message is logged - this is not a test target, and therefore it is ignored.
411+
} catch { case err: AssertionError => logger.dump(); throw err }
412+
}
410413
}
411414
}
412415

frontend/src/test/scala/bloop/testing/BloopHelpers.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,10 @@ trait BloopHelpers {
222222
test(project, Nil, Nil)
223223
}
224224

225+
def testTask(project: TestProject): Task[TestState] = {
226+
testTask(project, Nil, Nil)
227+
}
228+
225229
def testHandle(
226230
project: TestProject,
227231
only: List[String],

frontend/src/test/scala/bloop/testing/ProjectBaseSuite.scala

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import java.nio.file.Files
55
import bloop.io.AbsolutePath
66
import bloop.io.Paths
77
import bloop.logging.RecordingLogger
8+
import bloop.task.Task
9+
import scala.concurrent.duration.Duration
810

911
class ProjectBaseSuite(buildName: String) extends BaseSuite {
1012
val workspace: AbsolutePath = AbsolutePath(Files.createTempDirectory(s"workspace-${buildName}"))
@@ -22,6 +24,19 @@ class ProjectBaseSuite(buildName: String) extends BaseSuite {
2224
else test(name)(fun(newBuild, newLogger))
2325
}
2426

27+
def testProjectTask(
28+
name: String,
29+
runOnlyOnJava8: Boolean,
30+
maxDuration: Duration = Duration("60s")
31+
)(
32+
fun: (TestBuild, RecordingLogger) => Task[Unit]
33+
): Unit = {
34+
val newLogger = new RecordingLogger(ansiCodesSupported = false)
35+
val newBuild = build.withLogger(newLogger)
36+
if (runOnlyOnJava8) testOnlyOnJava8(name)(fun(newBuild, newLogger))
37+
else testTask(name, maxDuration)(fun(newBuild, newLogger))
38+
}
39+
2540
override def test(name: String)(fun: => Any): Unit = {
2641
super.test(name)(fun)
2742
}

0 commit comments

Comments
 (0)