1
1
package scala .cli .integration
2
2
3
3
import com .eed3si9n .expecty .Expecty .expect
4
+ import os .SubProcess
4
5
5
- import scala .concurrent .duration .DurationInt
6
+ import scala .concurrent .ExecutionContext
7
+ import scala .concurrent .duration .{Duration , DurationInt }
6
8
import scala .util .{Properties , Try }
7
9
8
10
trait 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
+
9
22
if (! Properties .isMac || ! TestUtil .isCI)
10
23
// TODO make this pass reliably on Mac CI
11
24
test(" simple --watch .scala source" ) {
@@ -21,8 +34,7 @@ trait RunWithWatchTestDefinitions { _: RunTestDefinitions =>
21
34
val output1 = TestUtil .readLine(proc.stdout, ec, timeout)
22
35
expect(output1 == expectedMessage1)
23
36
val expectedMessage2 = " World"
24
- while (! TestUtil .readLine(proc.stderr, ec, timeout).contains(" re-run" ))
25
- Thread .sleep(100L )
37
+ proc.printStderrUntilRerun(timeout)(ec)
26
38
os.write.over(
27
39
root / inputPath,
28
40
s """ object Smth extends App { println(" $expectedMessage2") } """
0 commit comments