test-masters.sh
author Nick Thomas <nthomas@mozilla.com>
Mon, 04 Nov 2013 11:31:58 +1300
changeset 9366 8e5ddb9c06fa9659c18a059edd2c454681f7e84a
parent 9167 24c750586403a7cd28441f48c6492e466cd97437
child 9611 55f2f42a07f650ed48fd1deccb92a4e3f65214e0
permissions -rwxr-xr-x
Bug 913197 followup, update active thunderbird release branches for dev masters

#!/bin/bash
# This script has been rewritten in setup_master.py using
# the -t option.  We use that now
exit=0

WORK=test-output
mkdir $WORK 2>/dev/null

actioning="Checking"
MASTERS_JSON_URL="${MASTERS_JSON_URL:-http://hg.mozilla.org/build/tools/raw-file/tip/buildfarm/maintenance/production-masters.json}"

atexit=()
trap 'for cmd in "${atexit[@]}"; do eval $cmd; done' EXIT

# I have had problems where a whole bunch of parallel HTTP requests caused
# errors (?), so fetch it once here and pass it in.
MASTERS_JSON=$(mktemp $WORK/tmp.masters.XXXXXXXXXX)
wget -q -O$MASTERS_JSON "$MASTERS_JSON_URL" || exit 1
atexit+=("rm $MASTERS_JSON")

FAILFILE=$(mktemp $WORK/tmp.failfile.XXXXXXXXXX)
atexit+=("rm $FAILFILE")

# Construct the set of masters that we will test.
MASTERS=($(./setup-master.py -l -j "$MASTERS_JSON" --tested-only "$@"))

# Fire off all the tests in parallel.
for MASTER in ${MASTERS[*]}; do (
    OUTFILE=$(mktemp $WORK/tmp.testout.XXXXXXXXXX)

    ./setup-master.py -t -j "$MASTERS_JSON" "$@" $MASTER > $OUTFILE 2>&1 || echo "$MASTER" >> $FAILFILE
    cat $OUTFILE # Make the output a little less interleaved
    rm $OUTFILE
) &
atexit+=("[ -e /proc/$! ] && kill $!")
done

echo "$actioning ${#MASTERS[*]} masters..."
echo "${MASTERS[*]}"
wait

if [ -s $FAILFILE ]; then
    echo "*** $(wc -l < $FAILFILE) master tests failed ***" >&2
    echo "Failed masters:" >&2
    sed -e 's/^/  /' "$FAILFILE" >&2
    exit 1
fi

for dir in mozilla mozilla-tests; do
  cd $dir
  for f in test/*.py; do
    trial $f || exit=1
  done
  rm -rf _trial_temp
  cd ..
done

exit $exit