bug 1517712 - log mach output when test_telemetry.py fails. r=sheehan
authorTed Mielczarek <ted@mielczarek.org>
Tue, 08 Jan 2019 15:14:51 +0000
changeset 510055 d591851c88240323eedf457c5f58fbc3a2267519
parent 510054 c5f89e53d636d57680224b2f29c76919c207cf18
child 510056 0eb0c348396bce080ba91a102c23c7e651bad6e2
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssheehan
bugs1517712
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 1517712 - log mach output when test_telemetry.py fails. r=sheehan Differential Revision: https://phabricator.services.mozilla.com/D15716
python/mach/mach/test/test_telemetry.py
--- a/python/mach/mach/test/test_telemetry.py
+++ b/python/mach/mach/test/test_telemetry.py
@@ -9,16 +9,23 @@ import subprocess
 import sys
 
 import buildconfig
 import mozunit
 import pytest
 
 from mozboot.bootstrap import update_or_create_build_telemetry_config
 
+TELEMETRY_LOAD_ERROR = '''
+Error loading telemetry. mach output:
+=========================================================
+%s
+=========================================================
+'''
+
 
 @pytest.fixture
 def run_mach(tmpdir):
     """Return a function that runs mach with the provided arguments and then returns
     a list of the data contained within any telemetry entries generated during the command.
     """
     # Use tmpdir as the mozbuild state path, and enable telemetry in
     # a machrc there.
@@ -27,25 +34,26 @@ def run_mach(tmpdir):
     env[b'MOZBUILD_STATE_PATH'] = str(tmpdir)
     env[b'MACH_TELEMETRY_NO_SUBMIT'] = b'1'
     # Let whatever mach command we invoke from tests believe it's the main command.
     del env['MACH_MAIN_PID']
     mach = os.path.join(buildconfig.topsrcdir, 'mach')
 
     def run(*args, **kwargs):
         # Run mach with the provided arguments
-        subprocess.check_output([sys.executable, mach] + list(args),
-                                stderr=subprocess.STDOUT,
-                                env=env,
-                                **kwargs)
+        out = subprocess.check_output([sys.executable, mach] + list(args),
+                                      stderr=subprocess.STDOUT,
+                                      env=env,
+                                      **kwargs)
         # Load any telemetry data that was written
         path = tmpdir.join('telemetry', 'outgoing')
         try:
             return [json.load(f.open('rb')) for f in path.listdir()]
         except EnvironmentError:
+            print(TELEMETRY_LOAD_ERROR % out, file=sys.stderr)
             for p in path.parts(reverse=True):
                 if not p.check(dir=1):
                     print('Path does not exist: "%s"' % p, file=sys.stderr)
             raise
     return run
 
 
 def test_simple(run_mach, tmpdir):