diff --git a/src/test/kotlin/de/hoennig/werkator/build/BuildExecutorTest.kt b/src/test/kotlin/de/hoennig/werkator/build/BuildExecutorTest.kt index 1174a1f..cb6a0a9 100644 --- a/src/test/kotlin/de/hoennig/werkator/build/BuildExecutorTest.kt +++ b/src/test/kotlin/de/hoennig/werkator/build/BuildExecutorTest.kt @@ -505,6 +505,8 @@ class BuildExecutorTest : FunSpec() { } test("with maxConcurrent 1 a second branch stays PENDING until the first finished") { + // branch-a blocks on a gate file the test creates, so the PENDING assertion + // below cannot race the first build finishing on a loaded machine val h = Harness( """ @@ -512,7 +514,7 @@ class BuildExecutorTest : FunSpec() { maxConcurrent: 1 branches: branch-a: - buildCommand: "sleep 1" + buildCommand: "until [ -f gate ]; do sleep 0.05; done" cleanCommand: "" branch-b: buildCommand: "echo ok" @@ -523,8 +525,13 @@ class BuildExecutorTest : FunSpec() { h.executor.startBuild(h.repo, "branch-a", "sha-a") h.executor.startBuild(h.repo, "branch-b", "sha-b") + eventually(30.seconds) { + h.repository.latestFor("branch-a")?.status shouldBe BuildStatus.RUNNING + } h.repository.latestFor("branch-b")?.status shouldBe BuildStatus.PENDING + Files.createFile(h.workingDir.resolve("gate")) + awaitStatus(h, "branch-b", BuildStatus.SUCCESS) awaitStatus(h, "branch-a", BuildStatus.SUCCESS) val transitions = h.events.map { it.result.branch to it.result.status }