fix: separate stderr capture in incus and suppress in test plugin

Capture stderr separately in Incus.run() instead of merging
it into stdout, which corrupted JSON parsing in run_json().
Add --quiet flag to reduce incus noise.
Suppress stderr in Remote subprocess to prevent pytest-xdist
communication issues.
This commit is contained in:
holger krekel
2026-03-10 17:49:48 +01:00
parent 155c1221b8
commit d14f384de3
2 changed files with 8 additions and 5 deletions

View File

@@ -122,7 +122,7 @@ class Incus:
to the terminal line-by-line while also being captured for to the terminal line-by-line while also being captured for
later return via result.stdout. later return via result.stdout.
""" """
cmd = ["incus"] + list(args) cmd = ["incus", "--quiet"] + list(args)
sub = self.out.new_prefixed_out(" ") sub = self.out.new_prefixed_out(" ")
if not capture: if not capture:
@@ -146,7 +146,7 @@ class Incus:
text=True, text=True,
stdin=subprocess.PIPE if input else subprocess.DEVNULL, stdin=subprocess.PIPE if input else subprocess.DEVNULL,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT, stderr=subprocess.PIPE,
) )
stdout_lines = [] stdout_lines = []
@@ -159,15 +159,17 @@ class Incus:
if sub.verbosity >= 2: if sub.verbosity >= 2:
sub.print(f" > {line.rstrip()}") sub.print(f" > {line.rstrip()}")
stderr = proc.stderr.read()
ret = proc.wait() ret = proc.wait()
stdout = "".join(stdout_lines) stdout = "".join(stdout_lines)
if check and ret != 0: if check and ret != 0:
for line in stdout.splitlines(): full_output = stdout + stderr
for line in full_output.splitlines():
if sub.verbosity < 1: # and we haven't printed it yet if sub.verbosity < 1: # and we haven't printed it yet
sub.red(line) sub.red(line)
raise subprocess.CalledProcessError(ret, cmd, output=stdout) raise subprocess.CalledProcessError(ret, cmd, output=stdout, stderr=stderr)
return subprocess.CompletedProcess(cmd, ret, stdout=stdout) return subprocess.CompletedProcess(cmd, ret, stdout=stdout, stderr=stderr)
def run_json(self, args, check=True): def run_json(self, args, check=True):
"""Run an incus command with ``--format=json``. """Run an incus command with ``--format=json``.

View File

@@ -516,6 +516,7 @@ class Remote:
command, command,
stdin=subprocess.DEVNULL, stdin=subprocess.DEVNULL,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL,
) )
self._procs.append(popen) self._procs.append(popen)
while 1: while 1: