Skip to content

Commit

Permalink
Add stdout/stderr to doctor calledProcesserror
Browse files Browse the repository at this point in the history
Summary:
Doctor uses subproccesses to run many external commands

When these commands fail, we currently only get the error code, not the stdout/stderr
https://fb.workplace.com/groups/eden.users/permalink/8868413416541861/

This diff adds that output to the doctor log to assist in debugging

Reviewed By: genevievehelsel

Differential Revision: D67551014

fbshipit-source-id: f64c47094ef84816f5c6ae643f444e5a62402be0
  • Loading branch information
Chris Dinh authored and facebook-github-bot committed Dec 21, 2024
1 parent 70cd568 commit ebbdd2d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
12 changes: 11 additions & 1 deletion eden/fs/cli/doctor/test/corrupt_hg_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,19 @@ def patched_func() -> typing.List[str]:
Found inconsistent/missing data in {hg_dot_path}:
Found a journal file in backing repo, might have an interrupted transaction
Repairing hg directory contents for {checkout_path}...<red>error<reset>
(.*\n)+
Failed to fix or verify fix for problem HgDirectoryError: CalledProcessError: Command 'hg' returned non-zero exit status 1.
│ Traceback .*
(.*\n){{15}}.*
│ subprocess.CalledProcessError: Command 'hg' returned non-zero exit status 1.
stdout:
stderr:
repair error
<red>Failed to fix 1 problem.<reset>
.*""",
msg=f"formatted output:\n{out.getvalue()}",
)

def _verify_hg_dir(self) -> None:
Expand Down
7 changes: 7 additions & 0 deletions eden/fs/cli/doctor/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,13 @@ def format_exception(ex: BaseException, with_tb: bool = False) -> str:
result.append(f"{type(ex).__name__}: {ex}")
if with_tb:
result.extend(format_traceback(ex, "│ "))
# Get CalledProcess output
if type(ex) is subprocess.CalledProcessError:
result.append("stdout:")
result.append(ex.stdout.decode("utf-8"))
result.append("stderr:")
result.append(ex.stderr.decode("utf-8"))

context = ex.__context__

if context:
Expand Down

0 comments on commit ebbdd2d

Please sign in to comment.