Skip to content

Commit

Permalink
bug 1517712 - log mach output when test_telemetry.py fails. r=sheehan
Browse files Browse the repository at this point in the history
Differential Revision: https://phabricator.services.mozilla.com/D15716

--HG--
extra : moz-landing-system : lando
  • Loading branch information
luser committed Jan 8, 2019
1 parent 52229a8 commit fc2a640
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions python/mach/mach/test/test_telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@

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):
Expand All @@ -32,15 +39,16 @@ def run_mach(tmpdir):

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)
Expand Down

0 comments on commit fc2a640

Please sign in to comment.