File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
opengrok-tools/src/test/python Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -169,6 +169,32 @@ def test_stderr():
169
169
assert 'root' in "\n " .join (cmd .getoutput ())
170
170
171
171
172
+ # This test needs the "/bin/cat" command, therefore it is Unix only.
173
+ @pytest .mark .skipif (not os .name .startswith ("posix" ), reason = "requires posix" )
174
+ def test_long_output ():
175
+ """
176
+ Test that output thread in the Command class captures all of the output.
177
+ (and also it does not hang the command by filling up the pipe)
178
+ """
179
+ # in bytes, should be enough to fill a pipe
180
+ num_lines = 500
181
+ line_length = 1000
182
+ with tempfile .NamedTemporaryFile () as file :
183
+ for _ in range (num_lines ):
184
+ file .write (b'A' * line_length )
185
+ file .write (b'\n ' )
186
+ file .flush ()
187
+ assert os .path .getsize (file .name ) == num_lines * (line_length + 1 )
188
+
189
+ cmd = Command (["/bin/cat" , file .name ])
190
+ cmd .execute ()
191
+
192
+ assert cmd .getstate () == Command .FINISHED
193
+ assert cmd .getretcode () == 0
194
+ assert cmd .geterroutput () is None
195
+ assert len (cmd .getoutputstr ()) == num_lines * (line_length + 1 )
196
+
197
+
172
198
@pytest .mark .skipif (not os .name .startswith ("posix" ), reason = "requires posix" )
173
199
def test_resource_limits ():
174
200
"""
You can’t perform that action at this time.
0 commit comments