Skip to content

Commit

Permalink
WIP: enable live logging for non-parallel test runs
Browse files Browse the repository at this point in the history
This provides incremental output when test is running _without xdist_,
just like the old runner did.

With xdist the live output is not available, I believe because of
pytest-dev/pytest-xdist#402
pytest-dev/pytest-xdist#883 might help with
that, but I'm not going to hold my breath until it is available on
distros we use.
  • Loading branch information
pspacek committed Mar 16, 2023
1 parent 915b0c5 commit 3cb320a
Showing 1 changed file with 18 additions and 21 deletions.
39 changes: 18 additions & 21 deletions bin/tests/system/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,28 +364,25 @@ def _run_script( # pylint: disable=too-many-arguments
raise FileNotFoundError(f"script {script} not found in {cwd}")
logger.debug("running script: %s %s %s", interpreter, script, " ".join(args))
logger.debug(" workdir: %s", cwd)
stdout = b""
returncode = 1
try:
proc = subprocess.run(
[interpreter, script] + args,
env=env,
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
)
except subprocess.CalledProcessError as exc:
stdout = exc.stdout
returncode = exc.returncode
raise exc
else:
stdout = proc.stdout
returncode = proc.returncode
finally:
if stdout:
for line in stdout.decode().splitlines():
logger.debug(" %s", line)
logger.debug(" exited with %d", returncode)

cmd = [interpreter, script] + args
proc = subprocess.Popen(
cmd,
env=env,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
bufsize=1,
universal_newlines=True
)
if proc.stdout:
for line in proc.stdout:
logger.info(" %s", line.rstrip('\n'))
proc.communicate()
returncode = proc.returncode
if returncode:
raise subprocess.CalledProcessError(returncode, cmd)
logger.debug(" exited with %d", returncode)
return proc

@pytest.fixture(scope="module")
Expand Down

0 comments on commit 3cb320a

Please sign in to comment.