Skip to content

Commit

Permalink
tests: add debugging output when watchman doesn't start
Browse files Browse the repository at this point in the history
Summary: We get WatchmanTimeout errors in tests sometimes. The timeout is 30 seconds, so probably watchman is failing to start. Let's add some more error output.

Reviewed By: zzl0

Differential Revision: D55017294

fbshipit-source-id: 71f1410b85126c983c889da4e91e65ccd5bddcee
  • Loading branch information
muirdm authored and facebook-github-bot committed Mar 19, 2024
1 parent 7c56dae commit 9726eab
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions eden/scm/tests/watchman.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import os
import subprocess
import sys
import time
import uuid
from pathlib import Path
Expand Down Expand Up @@ -84,15 +85,26 @@ def start(self) -> None:
]
deadline = time.time() + 30
watchmanavailable = False
lastoutput = ""
while not watchmanavailable and time.time() < deadline:
try:
# The watchman CLI can wait for a short time if socket
# is not ready.
subprocess.check_output(argv, env=env, close_fds=self._close_fds)
subprocess.run(
argv,
env=env,
close_fds=self._close_fds,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
check=True,
)
watchmanavailable = True
except Exception:
except subprocess.CalledProcessError as ex:
time.sleep(0.1)
lastoutput = ex.output.decode(errors="replace")
if not watchmanavailable:
sys.stderr.write(f"watchman CLI output: {lastoutput}\n")
sys.stderr.write("watchman log:\n%s\n" % open(clilogfile, "r").read())
raise WatchmanTimeout()

def stop(self) -> None:
Expand Down

0 comments on commit 9726eab

Please sign in to comment.