Skip to content

Commit f413554

Browse files
committed
Stress test PosixPluginFrontendSpec
1 parent 3041aed commit f413554

File tree

1 file changed

+24
-17
lines changed

1 file changed

+24
-17
lines changed

bridge/src/test/scala/protocbridge/frontend/PosixPluginFrontendSpec.scala

+24-17
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,30 @@ class PosixPluginFrontendSpec extends AnyFlatSpec with Matchers {
2323
toReceive
2424
}
2525
}
26-
val (path, state) = PosixPluginFrontend.prepare(
27-
fakeGenerator,
28-
env
29-
)
30-
val actualOutput = new ByteArrayOutputStream()
31-
val process = sys.process
32-
.Process(path.toAbsolutePath.toString)
33-
.run(new ProcessIO(writeInput => {
34-
writeInput.write(toSend)
35-
writeInput.close()
36-
}, processOutput => {
37-
IOUtils.copy(processOutput, actualOutput)
38-
processOutput.close()
39-
}, _.close()))
40-
process.exitValue()
41-
actualOutput.toByteArray mustBe toReceive
42-
PosixPluginFrontend.cleanup(state)
26+
27+
// Repeat 10,000 times since named pipes on macOS are flaky.
28+
val repeatCount = 10000
29+
for (i <- 1 to repeatCount) {
30+
if (i % 100 == 1) println(s"Running iteration $i of $repeatCount")
31+
32+
val (path, state) = PosixPluginFrontend.prepare(
33+
fakeGenerator,
34+
env
35+
)
36+
val actualOutput = new ByteArrayOutputStream()
37+
val process = sys.process
38+
.Process(path.toAbsolutePath.toString)
39+
.run(new ProcessIO(writeInput => {
40+
writeInput.write(toSend)
41+
writeInput.close()
42+
}, processOutput => {
43+
IOUtils.copy(processOutput, actualOutput)
44+
processOutput.close()
45+
}, _.close()))
46+
process.exitValue()
47+
actualOutput.toByteArray mustBe toReceive
48+
PosixPluginFrontend.cleanup(state)
49+
}
4350
}
4451
}
4552
}

0 commit comments

Comments
 (0)