Run tests on OS X

We import the scripts from ycmd with a couple of modifications:
 - don't set YCM_CORES=1 as we didn't before, and this makes the build a lot faster
 - don't install gcc-4.8 as we didn't before
 - install argparse as it is not available in python2.6
This commit is contained in:
Ben Jackson 2015-11-08 20:21:30 +00:00
parent 59b91817a0
commit 0639200153
5 changed files with 83 additions and 6 deletions

View File

@ -1,9 +1,28 @@
language: python language: generic
python: os:
- "2.6" - linux
- "2.7" - osx
sudo: false
before_install: before_install:
- git submodule update --init --recursive - git submodule update --init --recursive
install: install:
- pip install -r python/test_requirements.txt # source because it sets up env vars on some platforms
- source travis/travis_install.sh
script: ./run_tests.py script: ./run_tests.py
env:
matrix:
- YCMD_PYTHON_VERSION=2.7
- YCMD_PYTHON_VERSION=2.6
addons:
apt:
sources:
- deadsnakes
packages:
- python2.6
- python2.6-dev
- python2.7
- python2.7-dev
- python-virtualenv
cache:
directories:
- $HOME/.cache/pip

View File

@ -2,4 +2,4 @@ flake8>=2.0
mock>=1.0.1 mock>=1.0.1
nose>=1.3.0 nose>=1.3.0
PyHamcrest>=1.8.0 PyHamcrest>=1.8.0
argparse>=1.4.0

View File

@ -0,0 +1,3 @@
# Linux installation
virtualenv -p python${YCMD_PYTHON_VERSION} ${YCMD_VENV_DIR}

View File

@ -0,0 +1,19 @@
# OS X installation
# OS X comes with 2 versions of python by default, and a neat system
# (versioner) to switch between them:
# /usr/bin/python2.7 - python 2.7
# /usr/bin/python2.6 - python 2.6
#
# We just set the system default to match it
# http://stackoverflow.com/q/6998545
defaults write com.apple.versioner.python Version ${YCMD_PYTHON_VERSION}
# virtualenv is not installed by default on OS X under python2.6, and we don't
# have sudo, so we install it manually. There is no "latest" link, so we have
# to install a specific version.
VENV_VERSION=13.1.2
curl -O https://pypi.python.org/packages/source/v/virtualenv/virtualenv-${VENV_VERSION}.tar.gz
tar xvfz virtualenv-${VENV_VERSION}.tar.gz
python virtualenv-${VENV_VERSION}/virtualenv.py -p python${YCMD_PYTHON_VERSION} ${YCMD_VENV_DIR}

36
travis/travis_install.sh Normal file
View File

@ -0,0 +1,36 @@
#!/bin/bash
set -ev
YCMD_VENV_DIR=${HOME}/venvs/ycmd_test
# Requirements of OS-specific install:
# - install any software which is not installed by Travis configuration
# - create (but don't activate) a virtualenv for the python version
# ${YCMD_PYTHON_VERSION} in the directory ${YCMD_VENV_DIR}, e.g.
# virtualenv -p python${YCMD_PYTHON_VERSION} ${YCMD_VENV_DIR}
source travis/travis_install.${TRAVIS_OS_NAME}.sh
# virtualenv doesn't copy python-config https://github.com/pypa/virtualenv/issues/169
# but our build system uses it
cp /usr/bin/python${YCMD_PYTHON_VERSION}-config ${YCMD_VENV_DIR}/bin/python-config
# virtualenv script is noisy, so don't print every command
set +v
source ${YCMD_VENV_DIR}/bin/activate
set -v
# It is quite easy to get the above series of steps wrong. Verify that the
# version of python actually in the path and used is the version that was
# requested, and fail the build if we broke the travis setup
python_version=$(python -c 'import sys; print "{0}.{1}".format( sys.version_info[0], sys.version_info[1] )')
echo "Checking python version (actual ${python_version} vs expected ${YCMD_PYTHON_VERSION})"
test ${python_version} == ${YCMD_PYTHON_VERSION}
pip install -U pip wheel setuptools
pip install -r python/test_requirements.txt
# The build infrastructure prints a lot of spam after this script runs, so make
# sure to disable printing, and failing on non-zero exit code after this script
# finishes
set +ev