diff --git a/engine/runtime/src/test/scala/org/enso/interpreter/test/semantic/SystemProcessTest.scala b/engine/runtime/src/test/scala/org/enso/interpreter/test/semantic/SystemProcessTest.scala index b3cd6f9f4311..d38ec8d1fc5f 100644 --- a/engine/runtime/src/test/scala/org/enso/interpreter/test/semantic/SystemProcessTest.scala +++ b/engine/runtime/src/test/scala/org/enso/interpreter/test/semantic/SystemProcessTest.scala @@ -16,7 +16,7 @@ class SystemProcessTest extends InterpreterTest with OsSpec { interpreterContext: InterpreterContext ): Unit = { - "return success exit code" in { + "return success exit code (Unix)" taggedAs OsUnix in { val code = """from Standard.Builtins import all | @@ -29,6 +29,19 @@ class SystemProcessTest extends InterpreterTest with OsSpec { consumeErr shouldEqual List() } + "return success exit code (Windows)" taggedAs OsWindows in { + val code = + """from Standard.Builtins import all + | + |main = + | result = System.create_process "cmd" (Array.new_1 "/c") "" False False False + | result.exit_code + |""".stripMargin + eval(code) shouldEqual 0 + consumeOut shouldEqual List() + consumeErr shouldEqual List() + } + "return error when creating nonexistent command" in { val code = """from Standard.Builtins import all @@ -41,7 +54,7 @@ class SystemProcessTest extends InterpreterTest with OsSpec { consumeErr shouldEqual List() } - "return error exit code" in { + "return error exit code (Unix)" taggedAs OsUnix in { val code = """from Standard.Builtins import all | @@ -55,6 +68,20 @@ class SystemProcessTest extends InterpreterTest with OsSpec { consumeErr shouldEqual List() } + "return error exit code (Windows)" taggedAs OsWindows in { + val code = + """from Standard.Builtins import all + | + |main = + | result = System.create_process "cmd" (Array.new_2 "/c" "exit 7") "" False False False + | result.exit_code + |""".stripMargin + + eval(code) shouldEqual 7 + consumeOut shouldEqual List() + consumeErr shouldEqual List() + } + "redirect stdin chars (Unix)" taggedAs OsUnix in { val code = """from Standard.Builtins import all @@ -101,7 +128,7 @@ class SystemProcessTest extends InterpreterTest with OsSpec { consumeErr shouldEqual List() } - "redirect stdin unused" in { + "redirect stdin unused (Unix)" taggedAs OsUnix in { val code = """from Standard.Builtins import all | @@ -116,7 +143,22 @@ class SystemProcessTest extends InterpreterTest with OsSpec { consumeErr shouldEqual List() } - "redirect stdin empty" in { + "redirect stdin unused (Windows)" taggedAs OsWindows in { + val code = + """from Standard.Builtins import all + | + |main = + | result = System.create_process "cmd" (Array.new_2 "/c" "echo 9") "" True True True + | result.exit_code + |""".stripMargin + + feedInput("unused input") + eval(code) shouldEqual 0 + consumeOut shouldEqual List("9") + consumeErr shouldEqual List() + } + + "redirect stdin empty (Unix)" taggedAs OsUnix in { val code = """from Standard.Builtins import all | @@ -130,6 +172,20 @@ class SystemProcessTest extends InterpreterTest with OsSpec { consumeErr shouldEqual List() } + "redirect stdin empty (Windows)" taggedAs OsWindows in { + val code = + """from Standard.Builtins import all + | + |main = + | result = System.create_process "cmd" (Array.new_2 "/c" "echo 9") "" True True True + | result.exit_code + |""".stripMargin + + eval(code) shouldEqual 0 + consumeOut shouldEqual List("9") + consumeErr shouldEqual List() + } + "provide stdin string (Unix)" taggedAs OsUnix in { val code = """from Standard.Builtins import all @@ -158,7 +214,7 @@ class SystemProcessTest extends InterpreterTest with OsSpec { consumeErr shouldEqual List() } - "redirect stdout chars" in { + "redirect stdout chars (Unix)" taggedAs OsUnix in { val code = """from Standard.Builtins import all | @@ -172,6 +228,20 @@ class SystemProcessTest extends InterpreterTest with OsSpec { consumeErr shouldEqual List() } + "redirect stdout chars (Windows)" taggedAs OsWindows in { + val code = + """from Standard.Builtins import all + | + |main = + | result = System.create_process "cmd" (Array.new_2 "/c" "echo foobar") "" False True True + | result.exit_code + |""".stripMargin + + eval(code) shouldEqual 0 + consumeOut shouldEqual List("foobar") + consumeErr shouldEqual List() + } + "redirect stdout binary (Unix)" taggedAs OsUnix in { val code = """from Standard.Builtins import all @@ -186,7 +256,7 @@ class SystemProcessTest extends InterpreterTest with OsSpec { consumeErrBytes shouldEqual Array() } - "return stdout string" in { + "return stdout string (Unix)" taggedAs OsUnix in { val code = """from Standard.Builtins import all | @@ -201,6 +271,21 @@ class SystemProcessTest extends InterpreterTest with OsSpec { consumeErr shouldEqual List() } + "return stdout string (Windows)" taggedAs OsWindows in { + val code = + """from Standard.Builtins import all + | + |main = + | result = System.create_process "cmd" (Array.new_2 "/c" "echo foobar") "" False False False + | result.stdout + |""".stripMargin + + val result = eval(code).asString().replace("\r\n","\n") + result shouldEqual "foobar\n" + consumeOut shouldEqual List() + consumeErr shouldEqual List() + } + "redirect stderr chars (Unix)" taggedAs OsUnix in { val code = """from Standard.Builtins import all