Bug 1455201 - Propagate failure out of set -e region and add verbose logging to autospider.py, r=jonco
authorSteve Fink <sfink@mozilla.com>
Thu, 19 Apr 2018 11:20:26 -0700
changeset 414742 5a4670484c173ba69108168666cc49526721d3fb
parent 414741 6b86063d752831d485d3f61596c653d00b87fb79
child 414743 d9f508d0e46e29c30a74d17820de3db933978324
push id102418
push usersfink@mozilla.com
push dateFri, 20 Apr 2018 20:27:32 +0000
treeherdermozilla-inbound@5a4670484c17 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjonco
bugs1455201
milestone61.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 1455201 - Propagate failure out of set -e region and add verbose logging to autospider.py, r=jonco
js/src/devtools/automation/autospider.py
taskcluster/scripts/builder/sm-tooltool-config.sh
--- a/js/src/devtools/automation/autospider.py
+++ b/js/src/devtools/automation/autospider.py
@@ -1,21 +1,23 @@
 #!/usr/bin/env python
 
 import argparse
 import json
+import logging
 import re
 import os
 import platform
 import posixpath
 import shutil
 import subprocess
 import sys
 
 from collections import Counter, namedtuple
+from logging import info
 from os import environ as env
 from subprocess import Popen
 from threading import Timer
 
 Dirs = namedtuple('Dirs', ['scripts', 'js_src', 'source', 'tooltool'])
 
 
 def directories(pathmodule, cwd, fixup=lambda s: s):
@@ -29,18 +31,22 @@ def directories(pathmodule, cwd, fixup=l
 # Some scripts will be called with sh, which cannot use backslashed
 # paths. So for direct subprocess.* invocation, use normal paths from
 # DIR, but when running under the shell, use POSIX style paths.
 DIR = directories(os.path, os.getcwd())
 PDIR = directories(posixpath, os.environ["PWD"],
                    fixup=lambda s: re.sub(r'^(\w):', r'/\1', s))
 env['CPP_UNIT_TESTS_DIR_JS_SRC'] = DIR.js_src
 
+AUTOMATION = env.get('AUTOMATION', False)
+
 parser = argparse.ArgumentParser(
     description='Run a spidermonkey shell build job')
+parser.add_argument('--verbose', action='store_true', default=AUTOMATION,
+                    help="display additional logging info")
 parser.add_argument('--dep', action='store_true',
                     help='do not clobber the objdir before building')
 parser.add_argument('--keep', action='store_true',
                     help='do not delete the sanitizer output directory (for testing)')
 parser.add_argument('--platform', '-p', type=str, metavar='PLATFORM',
                     default='', help='build platform, including a suffix ("-debug" or "") used by buildbot to override the variant\'s "debug" setting. The platform can be used to specify 32 vs 64 bits.')
 parser.add_argument('--timeout', '-t', type=int, metavar='TIMEOUT',
                     default=10800,
@@ -82,23 +88,26 @@ parser.add_argument('--build-only', '--b
 parser.add_argument('--noconf', action='store_true',
                     help="skip running configure when doing a build")
 parser.add_argument('--nobuild', action='store_true',
                     help='Do not do a build. Rerun tests on existing build.')
 parser.add_argument('variant', type=str,
                     help='type of job requested, see variants/ subdir')
 args = parser.parse_args()
 
+logging.basicConfig(level=logging.INFO, format='%(message)s')
+
 OBJDIR = args.objdir
 OUTDIR = os.path.join(OBJDIR, "out")
 POBJDIR = posixpath.join(PDIR.source, args.objdir)
-AUTOMATION = env.get('AUTOMATION', False)
 MAKE = env.get('MAKE', 'make')
 MAKEFLAGS = env.get('MAKEFLAGS', '-j6' + ('' if AUTOMATION else ' -s'))
 
+for d in ('scripts', 'js_src', 'source', 'tooltool'):
+    info("DIR.{name} = {dir}".format(name=d, dir=getattr(DIR, d)))
 
 def set_vars_from_script(script, vars):
     '''Run a shell script, then dump out chosen environment variables. The build
        system uses shell scripts to do some configuration that we need to
        borrow. On Windows, the script itself must output the variable settings
        (in the form "export FOO=<value>"), since otherwise there will be
        problems with mismatched Windows/POSIX formats.
     '''
@@ -120,17 +129,17 @@ def set_vars_from_script(script, vars):
             var = tograb.pop(0)
             env[var] = line
         elif parse_state == 'parsing exports':
             m = re.match(r'export (\w+)=(.*)', line)
             if m:
                 var, value = m.groups()
                 if var in tograb:
                     env[var] = value
-                    print("Setting %s = %s" % (var, value))
+                    info("Setting %s = %s" % (var, value))
                 if var.startswith("ORIGINAL_"):
                     originals[var[9:]] = value
 
     # An added wrinkle: on Windows developer systems, the sourced script will
     # blow away current settings for eg LIBS, to point to the ones that would
     # be installed via automation. So we will append the original settings. (On
     # an automation system, the original settings will be empty or point to
     # nonexistent stuff.)
@@ -191,16 +200,17 @@ if opt is not None:
 opt = args.jemalloc
 if opt is not None:
     CONFIGURE_ARGS += (" --enable-jemalloc" if opt else " --disable-jemalloc")
 
 # Any jobs that wish to produce additional output can save them into the upload
 # directory if there is such a thing, falling back to OBJDIR.
 env.setdefault('MOZ_UPLOAD_DIR', OBJDIR)
 ensure_dir_exists(env['MOZ_UPLOAD_DIR'], clobber=False, creation_marker_filename=None)
+info("MOZ_UPLOAD_DIR = {}".format(env['MOZ_UPLOAD_DIR']))
 
 # Some of the variants request a particular word size (eg ARM simulators).
 word_bits = variant.get('bits')
 
 # On Linux and Windows, we build 32- and 64-bit versions on a 64 bit
 # host, so the caller has to specify what is desired.
 if word_bits is None and args.platform:
     platform_arch = args.platform.split('-')[0]
@@ -217,32 +227,38 @@ if 'compiler' in variant:
     compiler = variant['compiler']
 elif platform.system() == 'Darwin':
     compiler = 'clang'
 elif platform.system() == 'Windows':
     compiler = 'cl'
 else:
     compiler = 'gcc'
 
+info("using compiler '{}'".format(compiler))
+
 cxx = {'clang': 'clang++', 'gcc': 'g++', 'cl': 'cl'}.get(compiler)
 
 compiler_dir = env.get('GCCDIR', os.path.join(DIR.tooltool, compiler))
+info("looking for compiler under {}/".format(compiler_dir))
 if os.path.exists(os.path.join(compiler_dir, 'bin', compiler)):
     env.setdefault('CC', os.path.join(compiler_dir, 'bin', compiler))
     env.setdefault('CXX', os.path.join(compiler_dir, 'bin', cxx))
     platlib = 'lib64' if word_bits == 64 else 'lib'
     env.setdefault('LD_LIBRARY_PATH', os.path.join(compiler_dir, platlib))
 else:
     env.setdefault('CC', compiler)
     env.setdefault('CXX', cxx)
 
 bindir = os.path.join(OBJDIR, 'dist', 'bin')
 env['LD_LIBRARY_PATH'] = ':'.join(
     p for p in (bindir, env.get('LD_LIBRARY_PATH')) if p)
 
+for v in ('CC', 'CXX', 'LD_LIBRARY_PATH'):
+    info("default {name} = {value}".format(name=v, value=env[v]))
+
 rust_dir = os.path.join(DIR.tooltool, 'rustc')
 if os.path.exists(os.path.join(rust_dir, 'bin', 'rustc')):
     env.setdefault('RUSTC', os.path.join(rust_dir, 'bin', 'rustc'))
     env.setdefault('CARGO', os.path.join(rust_dir, 'bin', 'cargo'))
 else:
     env.setdefault('RUSTC', 'rustc')
     env.setdefault('CARGO', 'cargo')
 
@@ -296,16 +312,17 @@ timer.daemon = True
 timer.start()
 
 ensure_dir_exists(OBJDIR, clobber=not args.dep and not args.nobuild)
 ensure_dir_exists(OUTDIR, clobber=not args.keep)
 
 
 def run_command(command, check=False, **kwargs):
     kwargs.setdefault('cwd', OBJDIR)
+    info("in directory {}, running {}".format(kwargs['cwd'], command))
     proc = Popen(command, **kwargs)
     ACTIVE_PROCESSES.add(proc)
     stdout, stderr = None, None
     try:
         stdout, stderr = proc.communicate()
     finally:
         ACTIVE_PROCESSES.discard(proc)
     status = proc.wait()
@@ -337,17 +354,23 @@ if use_minidump:
     injector_lib = None
     if platform.system() == 'Linux':
         injector_lib = os.path.join(DIR.tooltool, 'breakpad-tools', 'libbreakpadinjector.so')
         env.setdefault('MINIDUMP_STACKWALK',
                        os.path.join(DIR.tooltool, 'breakpad-tools', 'minidump_stackwalk'))
     elif platform.system() == 'Darwin':
         injector_lib = os.path.join(DIR.tooltool, 'breakpad-tools', 'breakpadinjector.dylib')
     if not injector_lib or not os.path.exists(injector_lib):
-        use_minidump=False
+        use_minidump = False
+
+    info("use_minidump is {}".format(use_minidump))
+    info("  MINIDUMP_SAVE_PATH={}".format(env['MINIDUMP_SAVE_PATH']))
+    info("  injector lib is {}".format(injector_lib))
+    info("  MINIDUMP_STACKWALK={}".format(env.get('MINIDUMP_STACKWALK')))
+
 
 def need_updating_configure(configure):
     if not os.path.exists(configure):
         return True
 
     dep_files = [
         os.path.join(DIR.js_src, 'configure.in'),
         os.path.join(DIR.js_src, 'old-configure.in'),
@@ -473,17 +496,17 @@ if 'jsapitests' in test_suites:
         print("Return code: {}".format(st))
     results.append(st)
 if 'jstests' in test_suites:
     results.append(run_test_command([MAKE, 'check-jstests']))
 
 # FIXME bug 1291449: This would be unnecessary if we could run msan with -mllvm
 # -msan-keep-going, but in clang 3.8 it causes a hang during compilation.
 if variant.get('ignore-test-failures'):
-    print("Ignoring test results %s" % (results,))
+    logging.warning("Ignoring test results %s" % (results,))
     results = [0]
 
 if args.variant in ('tsan', 'msan'):
     files = filter(lambda f: f.startswith("sanitize_log."), os.listdir(OUTDIR))
     fullfiles = [os.path.join(OUTDIR, f) for f in files]
 
     # Summarize results
     sites = Counter()
--- a/taskcluster/scripts/builder/sm-tooltool-config.sh
+++ b/taskcluster/scripts/builder/sm-tooltool-config.sh
@@ -1,20 +1,19 @@
 #!/bin/bash
 
 set -x
 
-: ${TOOLTOOL_SERVER:=https://tooltool.mozilla-releng.net/}
-: ${SPIDERMONKEY_VARIANT:=plain}
-: ${UPLOAD_DIR:=$HOME/artifacts/}
-: ${WORK:=$HOME/workspace}
-: ${SRCDIR:=$WORK/build/src}
+TOOLTOOL_SERVER=${TOOLTOOL_SERVER:-https://tooltool.mozilla-releng.net/}
+SPIDERMONKEY_VARIANT=${SPIDERMONKEY_VARIANT:-plain}
+UPLOAD_DIR=${UPLOAD_DIR:-$HOME/artifacts/}
+WORK=${WORK:-$HOME/workspace}
+SRCDIR=${SRCDIR:-$WORK/build/src}
 
-: ${TOOLTOOL_CHECKOUT:=$WORK}
-export TOOLTOOL_CHECKOUT
+export TOOLTOOL_CHECKOUT=${TOOLTOOL_CHECKOUT:-$WORK}
 
 ( # Create scope for set -e
 set -e
 mkdir -p $WORK
 cd $WORK
 
 # Need to install things from tooltool. Figure out what platform to use.
 
@@ -55,14 +54,14 @@ fi
 
 # Install everything needed for the browser on this platform. Not all of it is
 # necessary for the JS shell, but it's less duplication to share tooltool
 # manifests.
 BROWSER_PLATFORM=$PLATFORM_OS$BITS
 
 (cd $TOOLTOOL_CHECKOUT && ${SRCDIR}/mach artifact toolchain${TOOLTOOL_MANIFEST:+ -v $TOOLTOOL_AUTH_FLAGS --tooltool-url $TOOLTOOL_SERVER --tooltool-manifest $SRCDIR/$TOOLTOOL_MANIFEST}${TOOLTOOL_CACHE:+ --cache-dir $TOOLTOOL_CACHE}${MOZ_TOOLCHAINS:+ ${MOZ_TOOLCHAINS}})
 
-) # end of set -e scope
+) || exit 1 # end of set -e scope
 
 # Add all the tooltool binaries to our $PATH.
 for bin in $TOOLTOOL_CHECKOUT/*/bin $TOOLTOOL_CHECKOUT/VC/bin/Hostx64/x86; do
     export PATH="$bin:$PATH"
 done