Mercurial > hg
annotate tests/test-stdio.py @ 45077:fa270dcbdb55
procutil: back out 8403cc54bc83 (make ....procutil.stderr unbuffered)
Changeset 8403cc54bc83 introduced code that opens a second file object
referring to the stderr file descriptor. This broke tests on Windows. The
reason is that on Windows, sys.stderr is buffered and procutil.stderr closed
the file descriptor when it got garbage collected before sys.stderr had the
chance to flush buffered data.
`procutil.stdout` had the same problem for a long time, but we didn’t realize,
as in CI test runs, stdout is not a TTY and in this case no second file object
is opened.
author | Manuel Jacob <me@manueljacob.de> |
---|---|
date | Sat, 11 Jul 2020 06:03:22 +0200 |
parents | bc05c13e246f |
children | a59aab6078eb |
rev | line source |
---|---|
45038
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
2 """ |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
3 Tests the buffering behavior of stdio streams in `mercurial.utils.procutil`. |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
4 """ |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
5 from __future__ import absolute_import |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
6 |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
7 import contextlib |
45068
8cd18aba5e6c
tests: proof test-stdio.py against buffer fill-up
Manuel Jacob <me@manueljacob.de>
parents:
45045
diff
changeset
|
8 import errno |
45038
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
9 import os |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
10 import subprocess |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
11 import sys |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
12 import unittest |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
13 |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
14 from mercurial import pycompat |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
15 |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
16 |
45070
bc05c13e246f
tests: make names in test-stdio.py more distinctive
Manuel Jacob <me@manueljacob.de>
parents:
45069
diff
changeset
|
17 BUFFERING_CHILD_SCRIPT = r''' |
45038
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
18 import os |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
19 |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
20 from mercurial import dispatch |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
21 from mercurial.utils import procutil |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
22 |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
23 dispatch.initstdio() |
45044
359884685eab
tests: generalize common test case code in test-stdio.py
Manuel Jacob <me@manueljacob.de>
parents:
45043
diff
changeset
|
24 procutil.{stream}.write(b'aaa') |
359884685eab
tests: generalize common test case code in test-stdio.py
Manuel Jacob <me@manueljacob.de>
parents:
45043
diff
changeset
|
25 os.write(procutil.{stream}.fileno(), b'[written aaa]') |
359884685eab
tests: generalize common test case code in test-stdio.py
Manuel Jacob <me@manueljacob.de>
parents:
45043
diff
changeset
|
26 procutil.{stream}.write(b'bbb\n') |
359884685eab
tests: generalize common test case code in test-stdio.py
Manuel Jacob <me@manueljacob.de>
parents:
45043
diff
changeset
|
27 os.write(procutil.{stream}.fileno(), b'[written bbb\\n]') |
45038
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
28 ''' |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
29 UNBUFFERED = b'aaa[written aaa]bbb\n[written bbb\\n]' |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
30 LINE_BUFFERED = b'[written aaa]aaabbb\n[written bbb\\n]' |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
31 FULLY_BUFFERED = b'[written aaa][written bbb\\n]aaabbb\n' |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
32 |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
33 |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
34 @contextlib.contextmanager |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
35 def _closing(fds): |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
36 try: |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
37 yield |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
38 finally: |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
39 for fd in fds: |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
40 try: |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
41 os.close(fd) |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
42 except EnvironmentError: |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
43 pass |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
44 |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
45 |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
46 @contextlib.contextmanager |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
47 def _pipes(): |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
48 rwpair = os.pipe() |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
49 with _closing(rwpair): |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
50 yield rwpair |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
51 |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
52 |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
53 @contextlib.contextmanager |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
54 def _ptys(): |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
55 if pycompat.iswindows: |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
56 raise unittest.SkipTest("PTYs are not supported on Windows") |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
57 import pty |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
58 import tty |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
59 |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
60 rwpair = pty.openpty() |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
61 with _closing(rwpair): |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
62 tty.setraw(rwpair[0]) |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
63 yield rwpair |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
64 |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
65 |
45068
8cd18aba5e6c
tests: proof test-stdio.py against buffer fill-up
Manuel Jacob <me@manueljacob.de>
parents:
45045
diff
changeset
|
66 def _readall(fd, buffer_size): |
8cd18aba5e6c
tests: proof test-stdio.py against buffer fill-up
Manuel Jacob <me@manueljacob.de>
parents:
45045
diff
changeset
|
67 buf = [] |
8cd18aba5e6c
tests: proof test-stdio.py against buffer fill-up
Manuel Jacob <me@manueljacob.de>
parents:
45045
diff
changeset
|
68 while True: |
8cd18aba5e6c
tests: proof test-stdio.py against buffer fill-up
Manuel Jacob <me@manueljacob.de>
parents:
45045
diff
changeset
|
69 try: |
8cd18aba5e6c
tests: proof test-stdio.py against buffer fill-up
Manuel Jacob <me@manueljacob.de>
parents:
45045
diff
changeset
|
70 s = os.read(fd, buffer_size) |
8cd18aba5e6c
tests: proof test-stdio.py against buffer fill-up
Manuel Jacob <me@manueljacob.de>
parents:
45045
diff
changeset
|
71 except OSError as e: |
8cd18aba5e6c
tests: proof test-stdio.py against buffer fill-up
Manuel Jacob <me@manueljacob.de>
parents:
45045
diff
changeset
|
72 if e.errno == errno.EIO: |
8cd18aba5e6c
tests: proof test-stdio.py against buffer fill-up
Manuel Jacob <me@manueljacob.de>
parents:
45045
diff
changeset
|
73 # If the child-facing PTY got closed, reading from the |
8cd18aba5e6c
tests: proof test-stdio.py against buffer fill-up
Manuel Jacob <me@manueljacob.de>
parents:
45045
diff
changeset
|
74 # parent-facing PTY raises EIO. |
8cd18aba5e6c
tests: proof test-stdio.py against buffer fill-up
Manuel Jacob <me@manueljacob.de>
parents:
45045
diff
changeset
|
75 break |
8cd18aba5e6c
tests: proof test-stdio.py against buffer fill-up
Manuel Jacob <me@manueljacob.de>
parents:
45045
diff
changeset
|
76 raise |
8cd18aba5e6c
tests: proof test-stdio.py against buffer fill-up
Manuel Jacob <me@manueljacob.de>
parents:
45045
diff
changeset
|
77 if not s: |
8cd18aba5e6c
tests: proof test-stdio.py against buffer fill-up
Manuel Jacob <me@manueljacob.de>
parents:
45045
diff
changeset
|
78 break |
8cd18aba5e6c
tests: proof test-stdio.py against buffer fill-up
Manuel Jacob <me@manueljacob.de>
parents:
45045
diff
changeset
|
79 buf.append(s) |
8cd18aba5e6c
tests: proof test-stdio.py against buffer fill-up
Manuel Jacob <me@manueljacob.de>
parents:
45045
diff
changeset
|
80 return b''.join(buf) |
8cd18aba5e6c
tests: proof test-stdio.py against buffer fill-up
Manuel Jacob <me@manueljacob.de>
parents:
45045
diff
changeset
|
81 |
8cd18aba5e6c
tests: proof test-stdio.py against buffer fill-up
Manuel Jacob <me@manueljacob.de>
parents:
45045
diff
changeset
|
82 |
45044
359884685eab
tests: generalize common test case code in test-stdio.py
Manuel Jacob <me@manueljacob.de>
parents:
45043
diff
changeset
|
83 class TestStdio(unittest.TestCase): |
359884685eab
tests: generalize common test case code in test-stdio.py
Manuel Jacob <me@manueljacob.de>
parents:
45043
diff
changeset
|
84 def _test(self, stream, rwpair_generator, expected_output, python_args=[]): |
359884685eab
tests: generalize common test case code in test-stdio.py
Manuel Jacob <me@manueljacob.de>
parents:
45043
diff
changeset
|
85 assert stream in ('stdout', 'stderr') |
359884685eab
tests: generalize common test case code in test-stdio.py
Manuel Jacob <me@manueljacob.de>
parents:
45043
diff
changeset
|
86 with rwpair_generator() as (stream_receiver, child_stream), open( |
45038
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
87 os.devnull, 'rb' |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
88 ) as child_stdin: |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
89 proc = subprocess.Popen( |
45044
359884685eab
tests: generalize common test case code in test-stdio.py
Manuel Jacob <me@manueljacob.de>
parents:
45043
diff
changeset
|
90 [sys.executable] |
359884685eab
tests: generalize common test case code in test-stdio.py
Manuel Jacob <me@manueljacob.de>
parents:
45043
diff
changeset
|
91 + python_args |
45070
bc05c13e246f
tests: make names in test-stdio.py more distinctive
Manuel Jacob <me@manueljacob.de>
parents:
45069
diff
changeset
|
92 + ['-c', BUFFERING_CHILD_SCRIPT.format(stream=stream)], |
45038
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
93 stdin=child_stdin, |
45044
359884685eab
tests: generalize common test case code in test-stdio.py
Manuel Jacob <me@manueljacob.de>
parents:
45043
diff
changeset
|
94 stdout=child_stream if stream == 'stdout' else None, |
359884685eab
tests: generalize common test case code in test-stdio.py
Manuel Jacob <me@manueljacob.de>
parents:
45043
diff
changeset
|
95 stderr=child_stream if stream == 'stderr' else None, |
45038
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
96 ) |
45068
8cd18aba5e6c
tests: proof test-stdio.py against buffer fill-up
Manuel Jacob <me@manueljacob.de>
parents:
45045
diff
changeset
|
97 try: |
8cd18aba5e6c
tests: proof test-stdio.py against buffer fill-up
Manuel Jacob <me@manueljacob.de>
parents:
45045
diff
changeset
|
98 os.close(child_stream) |
8cd18aba5e6c
tests: proof test-stdio.py against buffer fill-up
Manuel Jacob <me@manueljacob.de>
parents:
45045
diff
changeset
|
99 self.assertEqual( |
8cd18aba5e6c
tests: proof test-stdio.py against buffer fill-up
Manuel Jacob <me@manueljacob.de>
parents:
45045
diff
changeset
|
100 _readall(stream_receiver, 1024), expected_output |
8cd18aba5e6c
tests: proof test-stdio.py against buffer fill-up
Manuel Jacob <me@manueljacob.de>
parents:
45045
diff
changeset
|
101 ) |
45069
9172fd511999
tests: terminate subprocess in test-stdio.py in case of exception
Manuel Jacob <me@manueljacob.de>
parents:
45068
diff
changeset
|
102 except: # re-raises |
9172fd511999
tests: terminate subprocess in test-stdio.py in case of exception
Manuel Jacob <me@manueljacob.de>
parents:
45068
diff
changeset
|
103 proc.terminate() |
9172fd511999
tests: terminate subprocess in test-stdio.py in case of exception
Manuel Jacob <me@manueljacob.de>
parents:
45068
diff
changeset
|
104 raise |
45068
8cd18aba5e6c
tests: proof test-stdio.py against buffer fill-up
Manuel Jacob <me@manueljacob.de>
parents:
45045
diff
changeset
|
105 finally: |
8cd18aba5e6c
tests: proof test-stdio.py against buffer fill-up
Manuel Jacob <me@manueljacob.de>
parents:
45045
diff
changeset
|
106 retcode = proc.wait() |
45038
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
107 self.assertEqual(retcode, 0) |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
108 |
45070
bc05c13e246f
tests: make names in test-stdio.py more distinctive
Manuel Jacob <me@manueljacob.de>
parents:
45069
diff
changeset
|
109 def test_buffering_stdout_pipes(self): |
45044
359884685eab
tests: generalize common test case code in test-stdio.py
Manuel Jacob <me@manueljacob.de>
parents:
45043
diff
changeset
|
110 self._test('stdout', _pipes, FULLY_BUFFERED) |
45038
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
111 |
45070
bc05c13e246f
tests: make names in test-stdio.py more distinctive
Manuel Jacob <me@manueljacob.de>
parents:
45069
diff
changeset
|
112 def test_buffering_stdout_ptys(self): |
45044
359884685eab
tests: generalize common test case code in test-stdio.py
Manuel Jacob <me@manueljacob.de>
parents:
45043
diff
changeset
|
113 self._test('stdout', _ptys, LINE_BUFFERED) |
45038
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
114 |
45070
bc05c13e246f
tests: make names in test-stdio.py more distinctive
Manuel Jacob <me@manueljacob.de>
parents:
45069
diff
changeset
|
115 def test_buffering_stdout_pipes_unbuffered(self): |
45044
359884685eab
tests: generalize common test case code in test-stdio.py
Manuel Jacob <me@manueljacob.de>
parents:
45043
diff
changeset
|
116 self._test('stdout', _pipes, UNBUFFERED, python_args=['-u']) |
45038
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
117 |
45070
bc05c13e246f
tests: make names in test-stdio.py more distinctive
Manuel Jacob <me@manueljacob.de>
parents:
45069
diff
changeset
|
118 def test_buffering_stdout_ptys_unbuffered(self): |
45044
359884685eab
tests: generalize common test case code in test-stdio.py
Manuel Jacob <me@manueljacob.de>
parents:
45043
diff
changeset
|
119 self._test('stdout', _ptys, UNBUFFERED, python_args=['-u']) |
45038
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
120 |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
121 if not pycompat.ispy3 and not pycompat.iswindows: |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
122 # On Python 2 on non-Windows, we manually open stdout in line-buffered |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
123 # mode if connected to a TTY. We should check if Python was configured |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
124 # to use unbuffered stdout, but it's hard to do that. |
45070
bc05c13e246f
tests: make names in test-stdio.py more distinctive
Manuel Jacob <me@manueljacob.de>
parents:
45069
diff
changeset
|
125 test_buffering_stdout_ptys_unbuffered = unittest.expectedFailure( |
bc05c13e246f
tests: make names in test-stdio.py more distinctive
Manuel Jacob <me@manueljacob.de>
parents:
45069
diff
changeset
|
126 test_buffering_stdout_ptys_unbuffered |
45038
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
127 ) |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
128 |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
129 |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
130 if __name__ == '__main__': |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
131 import silenttestrunner |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
132 |
c7d109c400a4
tests: add tests for buffering behavior of mercurial.utils.procutil.stdout
Manuel Jacob <me@manueljacob.de>
parents:
diff
changeset
|
133 silenttestrunner.main(__name__) |