Skip to content

Commit

Permalink
app: write test output directly to files
Browse files Browse the repository at this point in the history
There is no sense to wait for the process termination or timeout.

It allows to see the output as the file's content during a test
execution.
  • Loading branch information
Totktonada committed May 29, 2023
1 parent 344becd commit ab30bd9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 3 additions & 6 deletions lib/app_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,14 @@ def timeout_handler(server_process, test_timeout):

def run_server(execs, cwd, server, logfile, retval, test_id):
os.putenv("LISTEN", server.listen_uri)
server.process = Popen(execs, stdout=PIPE, stderr=PIPE, cwd=cwd)
with open(logfile, 'ab') as f:
server.process = Popen(execs, stdout=sys.stdout, stderr=f, cwd=cwd)
sampler.register_process(server.process.pid, test_id, server.name)
test_timeout = Options().args.test_timeout
timer = Timer(test_timeout, timeout_handler, (server.process, test_timeout))
timer.start()
stdout, stderr = server.process.communicate()
timer.cancel()
sys.stdout.write_bytes(stdout)
with open(logfile, 'ab') as f:
f.write(stderr)
retval['returncode'] = server.process.wait()
timer.cancel()
server.process = None


Expand Down
4 changes: 4 additions & 0 deletions lib/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ def close(self):
def flush(self):
self.stream.flush()

def fileno(self):
""" May be used for direct writting. Discards any filters.
"""
return self.stream.fileno()

def get_filename_by_test(postfix, test_name):
"""For <..>/<name>_test.* or <..>/<name>.test.* return <name> + postfix
Expand Down

0 comments on commit ab30bd9

Please sign in to comment.