Bug 1531234 - Write JS test structured logs to main_raw.log instead of intermixing them in stdout r=ahal
authorSteve Fink <sfink@mozilla.com>
Fri, 01 Mar 2019 18:19:40 +0000
changeset 519856 ccd70bb02d61d1b627815f921caaebe1ce999e4f
parent 519855 f4ec35c8165ffde437c749537af1793c9f86abbf
child 519857 c1d95be237463b87764315db98860fa7887625a0
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersahal
bugs1531234
milestone67.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 1531234 - Write JS test structured logs to main_raw.log instead of intermixing them in stdout r=ahal Differential Revision: https://phabricator.services.mozilla.com/D21483
js/src/tests/lib/structuredlog.py
taskcluster/scripts/builder/build-sm.sh
--- a/js/src/tests/lib/structuredlog.py
+++ b/js/src/tests/lib/structuredlog.py
@@ -1,34 +1,38 @@
 # produce mozlog-compatible log messages, following the spec at
 # https://mozbase.readthedocs.io/en/latest/mozlog.html
 
+from __future__ import print_function
+
 import json
 import os
 
 from time import time
 
 
 class TestLogger(object):
     def __init__(self, source, threadname='main'):
         self.template = {
             'source': source,
             'thread': threadname,
             'pid': os.getpid(),
         }
+        directory = os.environ.get("MOZ_UPLOAD_DIR", ".")
+        self.fh = open(os.path.join(directory, threadname + "_raw.log"), "a")
 
     def _record(self, **kwargs):
         record = self.template.copy()
         record.update(**kwargs)
         if 'time' not in record:
             record['time'] = time()
         return record
 
     def _log_obj(self, obj):
-        print(json.dumps(obj, sort_keys=True))
+        print(json.dumps(obj, sort_keys=True), file=self.fh)
 
     def _log(self, **kwargs):
         self._log_obj(self._record(**kwargs))
 
     def suite_start(self):
         self._log(action='suite_start', tests=[])
 
     def suite_end(self):
--- a/taskcluster/scripts/builder/build-sm.sh
+++ b/taskcluster/scripts/builder/build-sm.sh
@@ -2,17 +2,17 @@
 
 set -x
 
 source $(dirname $0)/sm-tooltool-config.sh
 
 : ${PYTHON:=python2.7}
 
 # Run the script
-export MOZ_UPLOAD_DIR="$UPLOAD_DIR"
+export MOZ_UPLOAD_DIR="$(cd "$UPLOAD_DIR"; pwd)"
 AUTOMATION=1 $PYTHON $SRCDIR/js/src/devtools/automation/autospider.py ${SPIDERMONKEY_PLATFORM:+--platform=$SPIDERMONKEY_PLATFORM} $SPIDERMONKEY_VARIANT
 BUILD_STATUS=$?
 
 # Ensure upload dir exists
 mkdir -p $UPLOAD_DIR
 
 # Copy artifacts for upload by TaskCluster
 cp -rL $SRCDIR/obj-spider/dist/bin/{js,jsapi-tests,js-gdb.py} $UPLOAD_DIR