Skip to content

Commit aa485b4

Browse files
committed
Add a simple test for basic --watch .scala sources
1 parent a708ae9 commit aa485b4

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

modules/integration/src/test/scala/scala/cli/integration/RunTestDefinitions.scala

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2354,4 +2354,37 @@ abstract class RunTestDefinitions
23542354
}
23552355
}
23562356
}
2357+
2358+
test("simple --watch .scala source") {
2359+
val expectedMessage1 = "Hello"
2360+
val inputPath = os.rel / "smth.scala"
2361+
TestInputs(inputPath -> s"""object Smth extends App { println("$expectedMessage1") }""")
2362+
.fromRoot { root =>
2363+
val proc = os.proc(TestUtil.cli, "run", ".", "--watch", extraOptions)
2364+
.spawn(cwd = root, stderr = os.Pipe)
2365+
try
2366+
TestUtil.withThreadPool("simple-watch-scala-source-test", 2) { pool =>
2367+
val timeout = Duration("90 seconds")
2368+
val ec = ExecutionContext.fromExecutorService(pool)
2369+
val output1 = TestUtil.readLine(proc.stdout, ec, timeout)
2370+
expect(output1 == expectedMessage1)
2371+
val expectedMessage2 = "World"
2372+
while (!TestUtil.readLine(proc.stderr, ec, timeout).contains("re-run"))
2373+
Thread.sleep(100L)
2374+
os.write.over(
2375+
root / inputPath,
2376+
s"""object Smth extends App { println("$expectedMessage2") }""".stripMargin
2377+
)
2378+
val output2 = TestUtil.readLine(proc.stdout, ec, timeout)
2379+
expect(output2 == expectedMessage2)
2380+
}
2381+
finally
2382+
if (proc.isAlive()) {
2383+
proc.destroy()
2384+
Thread.sleep(200L)
2385+
if (proc.isAlive())
2386+
proc.destroyForcibly()
2387+
}
2388+
}
2389+
}
23572390
}

0 commit comments

Comments
 (0)