create-test-environment
author Connor Sheehan <sheehan@mozilla.com>
Wed, 03 Jul 2019 11:28:49 -0400
changeset 7093 1e55b3601d0a82bb1003aa495b3b296407640b14
parent 6620 d3c8a3520df44b3fa5f68ec15e2db144543cb03a
permissions -rwxr-xr-x
readonly: print `hg serve` error log at end of test When something fails inside the `hg serve` process, this will cause it to be printed out in the test.

#!/bin/bash

set +e
# Quick and dirty check for SSL support provided with this Python.  We check
# this way because some distros have backported the necessary SSL support
# into early Python versions, and we can't tell if we have what we need from
# the Python version alone.
python -c 'import ssl; ssl.SSLContext; ssl.PROTOCOL_TLSv1_2'
sslcheck=$?
set -e

if [ "$sslcheck" -ne 0 ]; then
  echo "Python version does not support verifying SSL certificates for secure"
  echo "downloads!  Please upgrade your version of Python."
  exit 1
fi

ROOT=`pwd`
VENV=${ROOT}/venv

if [ ! -d ${VENV}/lib ]; then
  # There is a bug in pycrypto where it tries to invoke `configure` instead
  # of a path qualified configure. So if there is a "configure" on $PATH
  # it will invoke the wrong one.
  configure=which configure &>/dev/null || true
  if [ "x" != "x${configure}" ]; then
    echo "configure in PATH; pycrypto install will fail!"
    echo "Remove the path containing ${configure} from PATH"
    exit 1
  fi

  . ${ROOT}/testing/create-virtualenv
fi

cd ${ROOT}
source ${VENV}/bin/activate

pip install --upgrade --require-hashes -r test-requirements.txt

cd hgserver/hgmolib
python setup.py develop
cd ../..

cd pylib/Bugsy
python setup.py develop
cd ../..

cd pylib/mozansible
python setup.py develop
cd ../..

cd pylib/mozhg
python setup.py develop
cd ../..

cd pylib/mozhginfo
python setup.py develop
cd ../..

cd pylib/mozautomation
python setup.py develop
cd ../..

cd pylib/vcsreplicator
python setup.py develop
cd ../..

cd hghooks
python setup.py develop
cd ..

cd testing
python setup.py develop
cd ..

# Collect code coverage from all Python processes if environment variable
# is set.
cat > venv/bin/sitecustomize.py << EOF
import os

if os.environ.get('CODE_COVERAGE', False):
    import uuid
    import coverage

    covpath = os.path.join(os.environ['COVERAGE_DIR'],
        'coverage.%s' % uuid.uuid1())
    cov = coverage.coverage(data_file=covpath, auto_data=True)
    cov._warn_no_data = False
    cov._warn_unimported_source = False
    cov.start()
EOF

python -m vcttesting.environment install-mercurials

if [ ! -d venv/git-cinnabar ]; then
  echo "Cloning git-cinnabar"
  git clone --branch release https://github.com/glandium/git-cinnabar.git venv/git-cinnabar
fi

cd venv/git-cinnabar
git pull
git submodule update --init
make -j4 helper NO_OPENSSL=1 NO_GETTEXT=1
cd ../..

if [ -z "${NO_DOCKER}" ]; then
  echo ""
  echo "Building Docker images."
  echo "This could take a while and may consume a lot of internet bandwidth."
  echo "If you don't want Docker images, it is safe to hit CTRL+c to abort this."

  ./d0cker build-all || {
    echo "You will not be able to run tests that require Docker.";
    echo "Please see https://docs.docker.com/installation/ for how to install Docker.";
    echo "When Docker is installed, re-run this script";
    exit 1
  }
else
  echo "Not building Docker images because NO_DOCKER is set."
fi

echo finished creating test environment!