11package scala .cli .integration
22
33import com .eed3si9n .expecty .Expecty .expect
4+ import os .SubProcess
45
5- import scala .concurrent .duration .DurationInt
6+ import scala .concurrent .ExecutionContext
7+ import scala .concurrent .duration .{Duration , DurationInt }
68import scala .util .{Properties , Try }
79
810trait RunWithWatchTestDefinitions { _ : RunTestDefinitions =>
11+ implicit class ProcOps (proc : SubProcess ) {
12+ def printStderrUntilRerun (timeout : Duration )(implicit ec : ExecutionContext ): Unit = {
13+ def rerunWasTriggered (): Boolean = {
14+ val stderrOutput = TestUtil .readLine(proc.stderr, ec, timeout)
15+ println(stderrOutput)
16+ stderrOutput.contains(" re-run" )
17+ }
18+ while (! rerunWasTriggered()) Thread .sleep(100L )
19+ }
20+ }
21+
922 if (! Properties .isMac || ! TestUtil .isCI)
1023 // TODO make this pass reliably on Mac CI
1124 test(" simple --watch .scala source" ) {
@@ -21,8 +34,7 @@ trait RunWithWatchTestDefinitions { _: RunTestDefinitions =>
2134 val output1 = TestUtil .readLine(proc.stdout, ec, timeout)
2235 expect(output1 == expectedMessage1)
2336 val expectedMessage2 = " World"
24- while (! TestUtil .readLine(proc.stderr, ec, timeout).contains(" re-run" ))
25- Thread .sleep(100L )
37+ proc.printStderrUntilRerun(timeout)(ec)
2638 os.write.over(
2739 root / inputPath,
2840 s """ object Smth extends App { println(" $expectedMessage2") } """
0 commit comments