diff --git a/modules/integration/src/test/scala/scala/cli/integration/BloopTests.scala b/modules/integration/src/test/scala/scala/cli/integration/BloopTests.scala index 750ecf410a..6aa994764f 100644 --- a/modules/integration/src/test/scala/scala/cli/integration/BloopTests.scala +++ b/modules/integration/src/test/scala/scala/cli/integration/BloopTests.scala @@ -5,6 +5,7 @@ import com.eed3si9n.expecty.Expecty.expect import scala.cli.integration.util.BloopUtil import scala.concurrent.ExecutionContext import scala.concurrent.duration.Duration +import scala.util.Properties class BloopTests extends ScalaCliSuite { @@ -134,36 +135,38 @@ class BloopTests extends ScalaCliSuite { } } - test("Restart Bloop server while watching") { - TestUtil.withThreadPool("bloop-restart-test", 2) { pool => - val timeout = Duration("90 seconds") - val ec = ExecutionContext.fromExecutorService(pool) - - def content(message: String) = - s"""object Hello { - | def main(args: Array[String]): Unit = - | println("$message") - |} - |""".stripMargin - val sourcePath = os.rel / "Hello.scala" - val inputs = TestInputs( - sourcePath -> content("Hello") - ) - inputs.fromRoot { root => - val proc = os.proc(TestUtil.cli, "run", "--power", "--offline", "-w", ".") - .spawn(cwd = root) - val firstLine = TestUtil.readLine(proc.stdout, ec, timeout) - expect(firstLine == "Hello") - - os.proc(TestUtil.cli, "--power", "bloop", "exit") - .call(cwd = root) - - os.write.over(root / sourcePath, content("Foo")) - val secondLine = TestUtil.readLine(proc.stdout, ec, timeout) - expect(secondLine == "Foo") - - proc.destroy() + if (!Properties.isMac || !TestUtil.isNativeCli || !TestUtil.isCI) + // TODO make this pass reliably on Mac CI + test("Restart Bloop server while watching") { + TestUtil.withThreadPool("bloop-restart-test", 2) { pool => + val timeout = Duration("90 seconds") + val ec = ExecutionContext.fromExecutorService(pool) + + def content(message: String) = + s"""object Hello { + | def main(args: Array[String]): Unit = + | println("$message") + |} + |""".stripMargin + val sourcePath = os.rel / "Hello.scala" + val inputs = TestInputs( + sourcePath -> content("Hello") + ) + inputs.fromRoot { root => + val proc = os.proc(TestUtil.cli, "run", "--power", "--offline", "-w", ".") + .spawn(cwd = root) + val firstLine = TestUtil.readLine(proc.stdout, ec, timeout) + expect(firstLine == "Hello") + + os.proc(TestUtil.cli, "--power", "bloop", "exit") + .call(cwd = root) + + os.write.over(root / sourcePath, content("Foo")) + val secondLine = TestUtil.readLine(proc.stdout, ec, timeout) + expect(secondLine == "Foo") + + proc.destroy() + } } } - } } diff --git a/modules/integration/src/test/scala/scala/cli/integration/RunTestsDefault.scala b/modules/integration/src/test/scala/scala/cli/integration/RunTestsDefault.scala index cb7dbb603a..eae40cdb36 100644 --- a/modules/integration/src/test/scala/scala/cli/integration/RunTestsDefault.scala +++ b/modules/integration/src/test/scala/scala/cli/integration/RunTestsDefault.scala @@ -66,77 +66,87 @@ class RunTestsDefault extends RunTestDefinitions(scalaVersionOpt = None) { } } - test("watch artifacts") { - val libSourcePath = os.rel / "lib" / "Messages.scala" - def libSource(hello: String) = - s"""//> using publish.organization "test-org" - |//> using publish.name "messages" - |//> using publish.version "0.1.0" - | - |package messages - | - |object Messages { - | def hello(name: String) = s"$hello $$name" - |} - |""".stripMargin - val inputs = TestInputs( - libSourcePath -> libSource("Hello"), - os.rel / "app" / "TestApp.scala" -> - """//> using lib "test-org::messages:0.1.0" - | - |package testapp - | - |import messages.Messages - | - |@main - |def run(): Unit = - | println(Messages.hello("user")) - |""".stripMargin - ) - inputs.fromRoot { root => - val testRepo = root / "test-repo" - - def publishLib(): Unit = - os.proc(TestUtil.cli, "--power", "publish", "--publish-repo", testRepo, "lib") - .call(cwd = root) - - publishLib() - - val proc = os.proc( - TestUtil.cli, - "--power", - "run", - "--offline", - "app", - "-w", - "-r", - testRepo.toNIO.toUri.toASCIIString + if (!Properties.isMac || !TestUtil.isNativeCli || !TestUtil.isCI) + // TODO make this pass reliably on Mac CI + test("watch artifacts") { + val libSourcePath = os.rel / "lib" / "Messages.scala" + def libSource(hello: String) = + s"""//> using publish.organization "test-org" + |//> using publish.name "messages" + |//> using publish.version "0.1.0" + | + |package messages + | + |object Messages { + | def hello(name: String) = s"$hello $$name" + |} + |""".stripMargin + val inputs = TestInputs( + libSourcePath -> libSource("Hello"), + os.rel / "app" / "TestApp.scala" -> + """//> using lib "test-org::messages:0.1.0" + | + |package testapp + | + |import messages.Messages + | + |@main + |def run(): Unit = + | println(Messages.hello("user")) + |""".stripMargin ) - .spawn(cwd = root) - - try - TestUtil.withThreadPool("watch-artifacts-test", 2) { pool => - val timeout = Duration("90 seconds") - val ec = ExecutionContext.fromExecutorService(pool) - - val output = TestUtil.readLine(proc.stdout, ec, timeout) - expect(output == "Hello user") + inputs.fromRoot { root => + val testRepo = root / "test-repo" - os.write.over(root / libSourcePath, libSource("Hola")) - publishLib() + def publishLib(): Unit = + os.proc( + TestUtil.cli, + "--power", + "publish", + "--offline", + "--publish-repo", + testRepo, + "lib" + ) + .call(cwd = root) - val secondOutput = TestUtil.readLine(proc.stdout, ec, timeout) - expect(secondOutput == "Hola user") - } - finally - if (proc.isAlive()) { - proc.destroy() - Thread.sleep(200L) - if (proc.isAlive()) - proc.destroyForcibly() - } + publishLib() + + val proc = os.proc( + TestUtil.cli, + "--power", + "run", + "--offline", + "app", + "-w", + "-r", + testRepo.toNIO.toUri.toASCIIString + ) + .spawn(cwd = root) + + try + TestUtil.withThreadPool("watch-artifacts-test", 2) { pool => + val timeout = Duration("90 seconds") + val ec = ExecutionContext.fromExecutorService(pool) + + val output = TestUtil.readLine(proc.stdout, ec, timeout) + expect(output == "Hello user") + + os.write.over(root / libSourcePath, libSource("Hola")) + publishLib() + + val secondOutput = TestUtil.readLine(proc.stdout, ec, timeout) + expect(secondOutput == "Hola user") + } + finally + if (proc.isAlive()) { + proc.destroy() + Thread.sleep(200L) + if (proc.isAlive()) + proc.destroyForcibly() + } + } } - } test("watch test - no infinite loop") {