# HG changeset patch
# User Jeroen Demeyer <jdemeyer@cage.ugent.be>
# Date 1365422124 -7200
# Node ID d158cebb4d85996b08dcb61f77071fee9367ba72
# Parent 190c98af438d79b5121f1cc8424606e75fcfb43e
Check that interfaces handle write errors gracefully
diff --git a/sage/interfaces/tests.py b/sage/interfaces/tests.py
a
|
b
|
|
21 | 21 | 4 |
22 | 22 | sage: parent(a) |
23 | 23 | Singular |
| 24 | |
| 25 | Test that write errors to stderr are handled gracefully by GAP |
| 26 | (see :trac:`13211`) and ECL (see :trac:`14426`) and other interfaces:: |
| 27 | |
| 28 | sage: import subprocess |
| 29 | sage: try: |
| 30 | ....: f = open('/dev/full', 'w') |
| 31 | ....: except IOError: |
| 32 | ....: f = open('/dev/null', 'w') |
| 33 | sage: kwds = dict(shell=True, stdout=f, stderr=f) |
| 34 | sage: subprocess.call("echo syntax error | ecl", **kwds) |
| 35 | 0 |
| 36 | sage: subprocess.call("echo syntax error | gap", **kwds) |
| 37 | 0 |
| 38 | sage: subprocess.call("echo syntax error | gp", **kwds) |
| 39 | 0 |
| 40 | sage: subprocess.call("echo syntax error | ipython", **kwds) in (0,1) |
| 41 | True |
| 42 | sage: subprocess.call("echo syntax error | singular", **kwds) |
| 43 | 0 |
24 | 44 | """ |
25 | 45 | |
26 | 46 | from all import * |
diff --git a/sage/tests/cmdline.py b/sage/tests/cmdline.py
a
|
b
|
|
55 | 55 | import os, select |
56 | 56 | |
57 | 57 | |
58 | | def test_executable(args, input="", timeout=100.0, cwd=None): |
| 58 | def test_executable(args, input="", timeout=100.0, **kwds): |
59 | 59 | r""" |
60 | 60 | Run the program defined by ``args`` using the string ``input`` on |
61 | 61 | the standard input. |
… |
… |
|
71 | 71 | - ``timeout`` -- if the program produces no output for ``timeout`` |
72 | 72 | seconds, a RuntimeError is raised. |
73 | 73 | |
74 | | - ``cwd`` -- (default: ``None``) if not None, run the program from |
75 | | the given directory. |
| 74 | - ``**kwds`` -- Additional keyword arguments passed to the |
| 75 | :class:`Popen` constructor. |
76 | 76 | |
77 | 77 | OUTPUT: a tuple ``(out, err, ret)`` with the standard output, |
78 | 78 | standard error and exitcode of the program run. |
… |
… |
|
591 | 591 | del pexpect_env["TERM"] |
592 | 592 | except KeyError: |
593 | 593 | pass |
594 | | p = Popen(args, stdin=PIPE, stdout=PIPE, stderr=PIPE, cwd=cwd, env=pexpect_env) |
| 594 | p = Popen(args, stdin=PIPE, stdout=PIPE, stderr=PIPE, env=pexpect_env, **kwds) |
595 | 595 | if input: |
596 | 596 | p.stdin.write(input) |
597 | 597 | p.stdin.close() |