Mentions légales du service

Skip to content
Snippets Groups Projects
Commit cfd72d90 authored by Mathieu Giraud's avatar Mathieu Giraud
Browse files

src/should.py: use temporary files to handle large outputs

Closes #19.
parent f1c6222d
No related branches found
No related tags found
No related merge requests found
Pipeline #408398 failed
......@@ -39,6 +39,7 @@ from collections import defaultdict, OrderedDict
import xml.etree.ElementTree as ET
import xml.dom.minidom as minidom
import datetime
import tempfile
# Make sure the output is in utf8
sys.stdout = open(sys.stdout.fileno(), mode='w', encoding='utf8', buffering=1)
......@@ -778,8 +779,10 @@ class TestSuite():
cmd = ' ; '.join(map(pre_process, self.cmds))
cmd = cmd_variables_cd(cmd)
f_stdout = tempfile.TemporaryFile()
f_stderr = tempfile.TemporaryFile()
p = subprocess.Popen([cmd], shell=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
stdout=f_stdout, stderr=f_stderr,
close_fds=True)
try:
......@@ -789,9 +792,12 @@ class TestSuite():
self.exit_code = None
self.tests.append(ExternalTestCase('Exit code is %d' % self.expected_exit_code, SKIP, 'timeout after %s seconds' % TIMEOUT))
self.stdout = [l.decode(errors='replace') for l in p.stdout.readlines()]
self.stderr = [l.decode(errors='replace') for l in p.stderr.readlines()]
f_stdout.seek(0)
f_stderr.seek(0)
self.stdout = [l.decode(errors='replace') for l in f_stdout.readlines()]
self.stderr = [l.decode(errors='replace') for l in f_stderr.readlines()]
f_stdout.close()
f_stderr.close()
if verbose > 0:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment