mirror of
https://github.com/chatmail/relay.git
synced 2026-05-19 20:38:05 +00:00
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:
@@ -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``.
|
||||||
|
|||||||
@@ -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:
|
||||||
|
|||||||
Reference in New Issue
Block a user