Add better debugging to `mb run`.
`mb run` (i.e., `python tools/mb.py run`) can be used to run
tests under swarming directly. However, it turns out that there
were a couple of places where we were swallowing error output,
making it hard to understand why things were failing silently :).
This CL should fix at least some of those cases, and also tweaks
the output a bit to be a bit more readable.
Change-Id: If6b412a9afad472b35220cb23721002aaaadcd32
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1623745
Commit-Queue: Dirk Pranke <dpranke@chromium.org>
Reviewed-by: Caleb Rouleau <crouleau@chromium.org>
Cr-Commit-Position: refs/heads/master@{#662869}
diff --git a/tools/mb/mb.py b/tools/mb/mb.py
index c0848e5..b278a7b 100755
--- a/tools/mb/mb.py
+++ b/tools/mb/mb.py
@@ -352,13 +352,17 @@
if not vals:
return 1
if self.args.build:
+ self.Print('')
ret = self.Build(self.args.target)
if ret:
return ret
+
+ self.Print('')
ret = self.RunGNIsolate(vals)
if ret:
return ret
+ self.Print('')
if self.args.swarmed:
return self._RunUnderSwarming(self.args.path, self.args.target)
else:
@@ -450,8 +454,24 @@
'-I', isolate_server,
'--namespace', namespace,
]
- ret, out, _ = self.Run(cmd, force_verbose=False)
+
+ # Talking to the isolateserver may fail because we're not logged in.
+ # We trap the command explicitly and rewrite the error output so that
+ # the error message is actually correct for a Chromium check out.
+ self.PrintCmd(cmd, env=None)
+ ret, out, err = self.Run(cmd, force_verbose=False)
if ret:
+ self.Print(' -> returned %d' % ret)
+ if out:
+ self.Print(out, end='')
+ if err:
+ # The swarming client will return an exit code of 2 (via
+ # argparse.ArgumentParser.error()) and print a message to indicate
+ # that auth failed, so we have to parse the message to check.
+ if (ret == 2 and 'Please login to' in err):
+ err = err.replace(' auth.py', ' tools/swarming_client/auth.py')
+ self.Print(err, end='', file=sys.stderr)
+
return ret
isolated_hash = out.splitlines()[0].split()[0]
@@ -467,6 +487,7 @@
self._AddBaseSoftware(cmd)
if self.args.extra_args:
cmd += ['--'] + self.args.extra_args
+ self.Print('')
ret, _, _ = self.Run(cmd, force_verbose=True, buffer_output=False)
return ret
@@ -1500,7 +1521,7 @@
if self.args.jobs:
ninja_cmd.extend(['-j', '%d' % self.args.jobs])
ninja_cmd.append(target)
- ret, _, _ = self.Run(ninja_cmd, force_verbose=False, buffer_output=False)
+ ret, _, _ = self.Run(ninja_cmd, buffer_output=False)
return ret
def Run(self, cmd, env=None, force_verbose=True, buffer_output=True):