diff --git a/src/test/java/org/apposed/appose/ApposeTest.java b/src/test/java/org/apposed/appose/ApposeTest.java index a3584d2..e84ec54 100644 --- a/src/test/java/org/apposed/appose/ApposeTest.java +++ b/src/test/java/org/apposed/appose/ApposeTest.java @@ -32,6 +32,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; import java.io.File; @@ -147,6 +148,26 @@ public void testServiceStartupFailure() throws IOException, InterruptedException } } + @Test + public void testTaskFailurePython() throws InterruptedException, IOException { + Environment env = Appose.system(); + try (Service service = env.python()) { + service.debug(System.out::println); + String script = "whee\n"; + Task task = service.task(script); + task.waitFor(); + assertSame(TaskStatus.FAILED, task.status); + String nl = "(\r\n|\n|\r)"; + String expectedError = + "Traceback \\(most recent call last\\):" + nl + + " File \"[^ ]*python_worker.py\", line \\d+, in execute_script" + nl + + " result = eval\\(" + nl + + " File \"\", line 1, in " + nl + + "NameError: name 'whee' is not defined" + nl; + assertTrue(task.error.matches(expectedError)); + } + } + public void executeAndAssert(Service service, String script) throws IOException, InterruptedException {